tests: fix resize test tmpfs max-file-size checking

Old distros may not have the "truncate" tool, so use "dd" instead.

If tmpfs cannot handle a 2GB temp file (e.g. old RHEL5 and SLES 11
kernels) then skip the test instead of failing it.  If this fails,
try to report better error messages instead of failing silently.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
maint-test
Andreas Dilger 2014-04-14 12:48:16 -04:00 committed by Theodore Ts'o
parent d8f401b135
commit 5bb66e37d6
6 changed files with 31 additions and 12 deletions

View File

@ -10,13 +10,17 @@ E2FSCK=../e2fsck/e2fsck
. $cmd_dir/scripts/resize_test . $cmd_dir/scripts/resize_test
if resize_test resize_test
then RC=$?
if [ $RC -eq 0 ]; then
echo "$test_name: $test_description: ok" echo "$test_name: $test_description: ok"
touch $test_name.ok touch $test_name.ok
elif [ $RC -eq 111 ]; then
echo "$test_name: $test_description: skipped"
touch $test_name.ok
else else
echo "$test_name: $test_description: failed" echo "$test_name: $test_description: failed"
touch $test_name.failed ln $LOG $test_name.failed
fi fi
unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK

View File

@ -20,7 +20,7 @@ elif [ $RC -eq 111 ]; then
touch $test_name.ok touch $test_name.ok
else else
echo "$test_name: $test_description: failed" echo "$test_name: $test_description: failed"
touch $test_name.failed ln $LOG $test_name.failed
fi fi
unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK

View File

@ -20,7 +20,7 @@ elif [ $RC -eq 111 ]; then
touch $test_name.ok touch $test_name.ok
else else
echo "$test_name: $test_description: failed" echo "$test_name: $test_description: failed"
touch $test_name.failed ln $LOG $test_name.failed
fi fi
unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK

View File

@ -20,7 +20,7 @@ elif [ $RC -eq 111 ]; then
touch $test_name.ok touch $test_name.ok
else else
echo "$test_name: $test_description: failed" echo "$test_name: $test_description: failed"
touch $test_name.failed ln $LOG $test_name.failed
fi fi
unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK

View File

@ -10,13 +10,17 @@ E2FSCK=../e2fsck/e2fsck
. $cmd_dir/scripts/resize_test . $cmd_dir/scripts/resize_test
if resize_test resize_test
then RC=$?
if [ $RC -eq 0 ]; then
echo "$test_name: $test_description: ok" echo "$test_name: $test_description: ok"
touch $test_name.ok touch $test_name.ok
elif [ $RC -eq 111 ]; then
echo "$test_name: $test_description: skipped"
touch $test_name.ok
else else
echo "$test_name: $test_description: failed" echo "$test_name: $test_description: failed"
touch $test_name.failed ln $LOG $test_name.failed
fi fi
unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK unset FEATURES SIZE_1 SIZE_2 LOG E2FSCK

View File

@ -1,25 +1,36 @@
#!/bin/sh #!/bin/sh
# old distros are missing "truncate", emulate it with "dd"
truncate()
{
[ "$1" = "-s" ] && size=$2 && shift 2
dd if=/dev/zero of=$1 bs=1 count=0 seek=$size >> $LOG 2>&1
}
resize_test () { resize_test () {
echo $test_description starting > $LOG
rm -f $TMPFILE rm -f $TMPFILE
touch $TMPFILE touch $TMPFILE
# Verify that the $TMP filesystem handles $SIZE_2 sparse files. # Verify that the $TMP filesystem handles $SIZE_2 sparse files.
# If that fails, try the local filesystem instead. # If that fails, try the local filesystem instead.
if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then
> $TMPFILE echo "using $TMPFILE" >> $LOG
else else
rm $TMPFILE rm $TMPFILE
export TMPFILE=$(TMPDIR=. mktemp -t $test_name.XXXXXX.tmp) export TMPFILE=$(TMPDIR=. mktemp -t $test_name.XXXXXX.tmp)
touch $TMPFILE touch $TMPFILE
if ! truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then echo "using $TMPFILE" >> $LOG
if ! truncate -s $SIZE_2 $TMPFILE >> $LOG 2>&1; then
rm $TMPFILE rm $TMPFILE
return 111 return 111
fi fi
fi fi
> $TMPFILE
echo $MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 > $LOG echo $MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG
$MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG $MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG
OUT_TMP=$(mktemp -t csum-tmp.XXXXXX) OUT_TMP=$(mktemp -t csum-tmp.XXXXXX)