summaryrefslogtreecommitdiff
path: root/yarns/implementations.yarn
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-06-09 15:54:41 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2014-06-09 15:54:41 +0100
commitf3bf7bbef3927dfb2a2eb12131b7b935659425e6 (patch)
treef46cc17d3c074e1e6997adc7d25a7a2a4b8d9912 /yarns/implementations.yarn
parentb6f37209fc277883c983b1602d3a98b4045f6dee (diff)
parent5bbf49ceeaeae07cc8bf165a047f0a4800ecb51a (diff)
downloadmorph-f3bf7bbef3927dfb2a2eb12131b7b935659425e6.tar.gz
Merge branch 'baserock/richardmaw/S11226/yarns-v2'
Reviewed-by: Sam Thursfield and Richard Ipsum
Diffstat (limited to 'yarns/implementations.yarn')
-rw-r--r--yarns/implementations.yarn43
1 files changed, 43 insertions, 0 deletions
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index 0635af72..66d47bfd 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -724,6 +724,49 @@ Check attributes of a file on the filesystem
IMPLEMENTS THEN file (\S+) is empty
stat -c %s "$DATADIR/$MATCH_1" | grep -Fx 0
+ IMPLEMENTS THEN file (\S+) matches (.*)
+ grep -q "$MATCH_2" "$DATADIR/$MATCH_1"
+
+Disk image manipulation
+-----------------------
+
+We need to test disk images we create. In the absence of tools for
+inspecting disks without mounting them, we need commands to handle this.
+
+ IMPLEMENTS WHEN disk image (\S+) is mounted at (.*)
+ mkdir -p "$DATADIR/$MATCH_2"
+ mount -o loop "$DATADIR/$MATCH_1" "$DATADIR/$MATCH_2"
+
+ IMPLEMENTS FINALLY (\S+) is unmounted
+ umount -d "$DATADIR/$MATCH_1"
+
+We may not have enough space to run some tests that have disk images.
+
+ IMPLEMENTS ASSUMING there is space for (\d+) (\d+)(\S*) disk images?
+ # Count is included as an argument, so that if we change the disk
+ # image sizes then it's more obvious when we need to change the
+ # assumption, since it's the same value.
+ count="$MATCH_1"
+ case "$MATCH_3" in
+ '')
+ size="$MATCH_2"
+ ;;
+ M)
+ size=$(expr "$MATCH_2" '*' 1024 '*' 1024 )
+ ;;
+ G)
+ size=$(expr "$MATCH_2" '*' 1024 '*' 1024 '*' 1024 )
+ ;;
+ *)
+ echo Unrecognized size suffix: "$MATCH_3" >&2
+ exit 1
+ esac
+ total_image_size="$(expr "$size" '*' "$count" )"
+ blocks="$(stat -f -c %a "$DATADIR")"
+ block_size="$(stat -f -c %S "$DATADIR")"
+ disk_free=$(expr "$blocks" '*' "$block_size" )
+ test "$disk_free" -gt "$total_image_size"
+
Check contents of a file
------------------------