From 280855019f13e21c5e804f1cd8673a2d96066fb8 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Thu, 13 Mar 2014 16:42:49 +0100 Subject: [PATCH] tests: try hard to create swaplabel's test image Signed-off-by: Ruediger Meier --- tests/ts/misc/swaplabel | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/ts/misc/swaplabel b/tests/ts/misc/swaplabel index e8768741cc..ef0f0ff0bd 100755 --- a/tests/ts/misc/swaplabel +++ b/tests/ts/misc/swaplabel @@ -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 \ -- 2.47.3