]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
tests: don't use a sparse test file
authorAndreas Dilger <adilger@dilger.ca>
Fri, 22 Jun 2018 15:42:14 +0000 (11:42 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 22 Jun 2018 15:42:14 +0000 (11:42 -0400)
If the TEST_BITS file is sparse, then the "debugfs -R write"
command may skip holes in the file when copying it into the
test image (depending on whether SEEK_HOLE/SEEK_DATA and/or
FIEMAP are available in the copy_file() function).

This was causing test failures on MacOS in the f_dup_resize
and d_loaddump tests because the TEST_BITS file was the
compiled "debugfs" binary, which apparently has holes when
built on MacOS, and the number of blocks allocated in the
test image was reduced as a result.  This caused the expect
output to differ in the summary line and resulted in failure.

Instead of using the debugfs binary for TEST_BITS, generate
a temporary file using /dev/urandom, if available.  If not,
fall back to the old behaviour or using debugfs.

[ Fixed up use of non-POSIX /bin/sh constructs and add test_data.tmp to
  .gitignore and files to be deleted on a make clean. --tytso ]

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
.gitignore
tests/Makefile.in
tests/test_config

index ac5c2c1d95166a6d7b3dcd326e02b7d654d7f8ee..df4021c9088f57a3b50b1ee405b93f820683cdd3 100644 (file)
@@ -223,6 +223,7 @@ tests/*.failed
 tests/*.log
 tests/*.tmp
 tests/*.slow
+tests/test_data.tmp
 tests/mke2fs.conf
 tests/test_script
 tests/test_one
index 7b9df62a80082357ab58ecaf230123acea73834a..4a19758947cb0ead6dc041e78c27c95c65066182 100644 (file)
@@ -94,7 +94,7 @@ testend: test_one ${TDIR}/image
 
 clean::
        $(RM) -f *~ *.log *.new *.failed *.ok *.tmp *.slow
-       $(RM) -f test_one test_script mke2fs.conf
+       $(RM) -f test_one test_script mke2fs.conf test_data.tmp
 
 distclean:: clean
        $(RM) -f Makefile
index c13aa74ddf644bbd0e633660a544c7063284e56a..595567fc5af42d4aab8f829d16fc1ea0ca0f3c62 100644 (file)
@@ -13,7 +13,14 @@ E2IMAGE="$USE_VALGRIND ../misc/e2image"
 E2IMAGE_EXE="../misc/e2image"
 DEBUGFS="$USE_VALGRIND ../debugfs/debugfs"
 DEBUGFS_EXE="../debugfs/debugfs"
-TEST_BITS="../debugfs/debugfs"
+TEST_BITS="test_data.tmp"
+if [ ! -s $TEST_BITS ]; then
+       # create a non-sparse test file if possible, since debugfs may be
+       # sparse and cause "debugfs write" (using copy_file()) to skip holes
+       # during testing if SEEK_DATA/SEEK_HOLE or FS_IOC_FIEMAP are available
+       dd if=/dev/urandom of=$TEST_BITS bs=128k count=1 > /dev/null 2>&1 ||
+               TEST_BITS="$DEFBUGFS_EXE"
+fi
 RESIZE2FS_EXE="../resize/resize2fs"
 RESIZE2FS="$USE_VALGRIND $RESIZE2FS_EXE"
 E2UNDO_EXE="../misc/e2undo"