From: Thomas Weißschuh Date: Sat, 1 Nov 2025 15:50:49 +0000 (+0100) Subject: tests: (swaplabel) don't create test image with truncate(1) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccb00ea5efe064b265104fbd19b36883172d9700;p=thirdparty%2Futil-linux.git tests: (swaplabel) don't create test image with truncate(1) truncate(1) can create holes in the file. These will trigger a warning in mkswap(1), failing the testsuite. Given that fallocate(1) now alway supports posix_fallocate() which works on all filesystems, truncate(1) is unnecessary anyways. Reported-by: Christian Hesse Signed-off-by: Thomas Weißschuh --- diff --git a/tests/ts/misc/swaplabel b/tests/ts/misc/swaplabel index 9db7d2b80..6e777ac2a 100755 --- a/tests/ts/misc/swaplabel +++ b/tests/ts/misc/swaplabel @@ -21,14 +21,7 @@ ts_init "$*" ts_check_test_command "$TS_CMD_MKSWAP" ts_check_test_command "$TS_CMD_SWAPLABEL" ts_check_test_command "$TS_HELPER_SYSINFO" - -# fallocate does not work on most file systems -function fallocate_or_skip() -{ - $TS_CMD_FALLOCATE -x -l $1 $2 2>/dev/null || \ - truncate -s $1 $2 || \ - ts_skip "no way to create test image" -} +ts_check_test_command "$TS_CMD_FALLOCATE" IMAGE=${TS_OUTDIR}/${TS_TESTNAME}.file @@ -38,7 +31,7 @@ MIN_SWAP_SIZE=$(( 10 * $PAGE_SIZE )) MIN_SWAP_SIZE_KB=$(( MIN_SWAP_SIZE / 1024 )) rm -f $IMAGE -fallocate_or_skip $(( $MIN_SWAP_SIZE - 1 )) $IMAGE +$TS_CMD_FALLOCATE -x -l $(( $MIN_SWAP_SIZE - 1 )) $IMAGE 2> /dev/null $TS_CMD_MKSWAP \ --label 1234567890abcdef \ --uuid 12345678-abcd-abcd-abcd-1234567890ab \ @@ -50,7 +43,7 @@ sed -i -e "s/ $MIN_SWAP_SIZE_KB KiB/ 10 pages/" \ $TS_OUTPUT $TS_ERRLOG rm -f $IMAGE -fallocate_or_skip $MIN_SWAP_SIZE $IMAGE +$TS_CMD_FALLOCATE -x -l $MIN_SWAP_SIZE $IMAGE 2> /dev/null $TS_CMD_MKSWAP \ --label 1234567890abcdef \ --uuid 12345678-abcd-abcd-abcd-1234567890ab \