aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2021-07-28 23:56:08 -0400
committerTheodore Ts'o <tytso@mit.edu>2021-07-28 23:56:08 -0400
commit4d988e1bba91d6a69d4c34c709084e0e39cb6b2c (patch)
tree575133c66457e02c9f3d222867b6e732c3ad3ffd
parent9aba05286c492927b81844193f941386f71ba829 (diff)
downloade2fsprogs-4d988e1bba91d6a69d4c34c709084e0e39cb6b2c.tar.gz
tests: try using truncate command before falling back to using dd
On the GNU Hurd, dd seems to be buggy and hangs if seeking beyond 4G. Fortunately the GNU Hurd does have the truncate command, which does work correctly. So try using the truncate command first, and fall back to using dd only if the truncate command doesn't work. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rwxr-xr-xtests/scripts/resize_test12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/scripts/resize_test b/tests/scripts/resize_test
index 3c5e260bf..fc9d1c246 100755
--- a/tests/scripts/resize_test
+++ b/tests/scripts/resize_test
@@ -1,11 +1,13 @@
#!/bin/sh
-# old distros are missing "truncate", emulate it with "dd"
-truncate()
+# old distros are missing "truncate", emulate it with "dd" if necessary
+do_truncate()
{
[ "$1" = "-s" ] && size=$2 && shift 2
- dd if=/dev/zero of=$1 bs=1 count=0 seek=$size >> $LOG 2>&1
+ if ! truncate -s $size $1 >> $LOG 2>&1 ; then
+ dd if=/dev/zero of=$1 bs=1 count=0 seek=$size >> $LOG 2>&1
+ fi
}
resize_test () {
@@ -17,14 +19,14 @@ touch $TMPFILE
# Verify that the $TMP filesystem handles $SIZE_2 sparse files.
# If that fails, try the local filesystem instead.
-if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then
+if do_truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then
echo "using $TMPFILE" >> $LOG
else
rm $TMPFILE
export TMPFILE=$(mktemp ./$test_name.tmp.XXXXXX)
touch $TMPFILE
echo "using $TMPFILE" >> $LOG
- if ! truncate -s $SIZE_2 $TMPFILE >> $LOG 2>&1; then
+ if ! do_truncate -s $SIZE_2 $TMPFILE >> $LOG 2>&1; then
rm $TMPFILE
return 111
fi