Whamcloud - gitweb
Search for GNU-compatible dd for self-tests.
authorMatthias Andree <matthias.andree@gmx.de>
Tue, 29 Aug 2017 05:02:36 +0000 (01:02 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 29 Aug 2017 05:05:58 +0000 (01:05 -0400)
This checks for a dd that supports iflag=fullblock oflag=append,
and looks at gdd and dd for now, and warns of failing self-tests
if neither supports these two flags.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
configure
configure.ac
tests/Makefile.in
tests/f_detect_junk/script
tests/m_offset/script
tests/r_expand_full/script
tests/test_one.in
tests/u_mke2fs_opt_offset/script

index 5318e2f..870a766 100755 (executable)
--- a/configure
+++ b/configure
@@ -655,6 +655,7 @@ SIZEOF_LONG_LONG
 SIZEOF_LONG
 SIZEOF_INT
 SIZEOF_SHORT
+DD
 BUILD_CC
 MAKEINFO
 STRIP
 
 done
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a dd(1) program that supports iflag=fullblock" >&5
+$as_echo_n "checking for a dd(1) program that supports iflag=fullblock... " >&6; }
+DD=
+for i in dd gdd ; do
+       if "$i" if=/dev/null of=/dev/null count=1 bs=10k 2>/dev/null iflag=fullblock oflag=append ; then
+               DD=$i
+               break
+       fi
+done
+if test -n "$DD" ; then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DD" >&5
+$as_echo "$DD" >&6; }
+else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found, using dd" >&5
+$as_echo "not found, using dd" >&6; }
+       DD=dd
+       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: No GNU-compatible dd(1) program found, expect some self-test failures." >&5
+$as_echo "$as_me: WARNING: No GNU-compatible dd(1) program found, expect some self-test failures." >&2;}
+fi
+
+
 for ac_header in net/if.h
 do :
   ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "
index 4ede01c..f69a193 100644 (file)
@@ -945,6 +945,25 @@ AC_CHECK_HEADERS(m4_flatten([
        sys/un.h
        sys/wait.h
 ]))
+dnl Check where to find a dd(1) that supports iflag=fullblock
+dnl and oflag=append
+AC_MSG_CHECKING([for a dd(1) program that supports iflag=fullblock])
+DD=
+for i in dd gdd ; do
+       if "$i" if=/dev/null of=/dev/null count=1 bs=10k 2>/dev/null iflag=fullblock oflag=append ; then
+               DD=$i
+               break
+       fi
+done
+if test -n "$DD" ; then
+       AC_MSG_RESULT([$DD])
+else
+       AC_MSG_RESULT([not found, using dd])
+       DD=dd
+       AC_MSG_WARN([No GNU-compatible dd(1) program found, expect some self-test failures.])
+fi
+AC_SUBST([DD])
+
 AC_CHECK_HEADERS(net/if.h,,,
 [[
 #if HAVE_SYS_TYPES_H
index c130f4a..9b4c1b8 100644 (file)
@@ -21,6 +21,7 @@ test_one: $(srcdir)/test_one.in Makefile mke2fs.conf
        @echo "SRCDIR=@srcdir@" >> test_one
        @echo "DIFF_OPTS=@UNI_DIFF_OPTS@" >> test_one
        @echo "SIZEOF_TIME_T=@SIZEOF_TIME_T@" >> test_one
+       @echo "DD=@DD@" >>test_one
        @cat $(srcdir)/test_one.in >> test_one
        @chmod +x test_one
 
index 2721c79..429ff00 100644 (file)
@@ -6,7 +6,7 @@ FSCK_OPT=-fn
 IMAGE=$test_dir/image.bz2
 
 bzip2 -d < $IMAGE > $TMPFILE
-dd if=/dev/zero of=$TMPFILE conv=notrunc oflag=append bs=1024k count=16 > /dev/null 2>&1
+$DD if=/dev/zero of=$TMPFILE conv=notrunc oflag=append bs=1024k count=16 > /dev/null 2>&1
 
 # Run fsck to fix things?
 if [ -x $DEBUGFS_EXE ]; then
index e4bc3c4..d49e555 100755 (executable)
@@ -2,18 +2,18 @@ test_description="mke2fs with offset option (-E offset=N)"
 OUT="$test_name.log"
 
 echo "testing mke2fs with -E offset=524288 option (no fssize)" > "$OUT"
-yes a | dd of="$TMPFILE" bs=1k count=2048 iflag=fullblock 2>>"$OUT"
+yes a | $DD of="$TMPFILE" bs=1k count=2048 iflag=fullblock 2>>"$OUT"
 $MKE2FS -F -b 1024 -E offset=524288 "$TMPFILE" >> "$OUT" 2>&1
 # compute crc of the first 512 1k blocks
-crc_first1=`dd if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM`
+crc_first1=`$DD if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM`
 
 echo "testing mke2fs with -E offset=524288 option (explicit fssize)" >> "$OUT"
-yes a | dd of="$TMPFILE" bs=1k count=2048 iflag=fullblock 2>>"$OUT"
+yes a | $DD of="$TMPFILE" bs=1k count=2048 iflag=fullblock 2>>"$OUT"
 $MKE2FS -F -b 1024 -E offset=524288 "$TMPFILE" 1024 >> "$OUT" 2>&1
 # compute crc of the first and last 512 1k blocks
-crc_first2=`dd if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM`
-crc_last2=`dd if="$TMPFILE" bs=1k count=512 skip=1536 2>/dev/null | $CRCSUM`
-crc_exp=`yes a | dd bs=1k count=512 2>/dev/null | $CRCSUM`
+crc_first2=`$DD if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM`
+crc_last2=`$DD if="$TMPFILE" bs=1k count=512 skip=1536 2>/dev/null | $CRCSUM`
+crc_exp=`yes a | $DD bs=1k count=512 2>/dev/null | $CRCSUM`
 # a warning should be only emitted by the first mke2fs call
 warning=`grep -c "offset specified without an explicit file system size." \
        "$OUT"`
index a2c09db..861a68a 100644 (file)
@@ -36,7 +36,7 @@ echo Exit status is $status >> $OUT
 
 # convert it
 echo "resize2fs test.img" >> $OUT
-dd if=/dev/zero of=$TMPFILE conv=notrunc bs=1 count=1 seek=3221225471 2> /dev/null
+$DD if=/dev/zero of=$TMPFILE conv=notrunc bs=1 count=1 seek=3221225471 2> /dev/null
 $RESIZE2FS -f $TMPFILE 2>&1 >> $OUT 2>&1
 status=$?
 echo Exit status is $status >> $OUT
index fb30e57..634267d 100644 (file)
@@ -1,6 +1,8 @@
 #!/bin/sh
 # run a single regression test
 
+export DD
+
 LC_ALL=C
 export LC_ALL
 
index 036b7b4..4b34b7a 100644 (file)
@@ -12,10 +12,10 @@ test_e2undo_mke2fs_off() {
        rm -f "$TDB_FILE"
        echo "testing e2undo and mke2fs with the -E offset=$OFF option" >> "$OUT"
        # prepare $TMPFILE
-       yes a | dd of="$TMPFILE" bs="$OFF" count=1 iflag=fullblock \
+       yes a | $DD of="$TMPFILE" bs="$OFF" count=1 iflag=fullblock \
                > /dev/null 2>>"$OUT"
-       yes b | dd bs=1k count=1024 iflag=fullblock >> "$TMPFILE" 2>>"$OUT"
-       yes c | dd bs=1k count=3 iflag=fullblock >> "$TMPFILE" 2>>"$OUT"
+       yes b | $DD bs=1k count=1024 iflag=fullblock >> "$TMPFILE" 2>>"$OUT"
+       yes c | $DD bs=1k count=3 iflag=fullblock >> "$TMPFILE" 2>>"$OUT"
 
        crc_exp=`$CRCSUM "$TMPFILE"`
        $MKE2FS -F -z "$TDB_FILE" -b 1024 -E offset="$OFF" "$TMPFILE" 1024 \
@@ -69,7 +69,7 @@ supplement_test_2048() {
        # data again (this might be considered as a bug (for now,
        # this testcase just documents this behavior))
        SEEK_BLOCKS=$(((2048 + 1024 * 1024) / 1024))
-       yes d | dd of="$TMPFILE" bs=1k count=2 seek="$SEEK_BLOCKS" \
+       yes d | $DD of="$TMPFILE" bs=1k count=2 seek="$SEEK_BLOCKS" \
                iflag=fullblock > /dev/null 2>>"$OUT"
 }