]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: try hard to create swaplabel's test image
authorRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 13 Mar 2014 15:42:49 +0000 (16:42 +0100)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Fri, 14 Mar 2014 08:51:45 +0000 (09:51 +0100)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tests/ts/misc/swaplabel

index e8768741cce14fdc5fdf72efe89e1624847ec05f..ef0f0ff0bd0a655f0893a591306ca60e5dc4cd2a 100755 (executable)
@@ -18,21 +18,29 @@ TS_DESC="swaplabel"
 . $TS_TOPDIR/functions.sh
 ts_init "$*"
 
-#ts_check_test_command "$TS_CMD_FALLOCATE"
-#ts_check_test_command "$TS_CMD_MKSWAP"
-#ts_check_test_command "$TS_CMD_SWAPLABEL"
+ts_check_test_command "$TS_CMD_MKSWAP"
+ts_check_test_command "$TS_CMD_SWAPLABEL"
+
+# fallocate does not work on most file systems
+function fallocate_or_skip()
+{
+       $TS_CMD_FALLOCATE -l $1 $2 2>/dev/null || \
+       truncate -s $1 $2 || \
+       ts_skip "no way to create test image"
+}
 
 IMAGE=${TS_OUTDIR}/${TS_TESTNAME}.file
 
 rm -f $IMAGE
-$TS_CMD_FALLOCATE -l 40959 $IMAGE > $TS_OUTPUT 2>&1
+
+fallocate_or_skip 40959 $IMAGE
 $TS_CMD_MKSWAP \
        --label 1234567890abcdef \
        --uuid 12345678-abcd-abcd-abcd-1234567890ab \
        $IMAGE >> $TS_OUTPUT 2>&1
 
 rm -f $IMAGE
-$TS_CMD_FALLOCATE -l 40960 $IMAGE >> $TS_OUTPUT 2>&1
+fallocate_or_skip 40960 $IMAGE
 $TS_CMD_MKSWAP \
        --label 1234567890abcdef \
        --uuid 12345678-abcd-abcd-abcd-1234567890ab \