]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: handle dd errors in fincore/count
authorRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 6 Apr 2017 07:56:04 +0000 (09:56 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 6 Apr 2017 10:30:10 +0000 (12:30 +0200)
On dd error the test will fail earlier and the test diff will be
more useful.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tests/ts/fincore/count

index be815527e72fdabc3daedf460169db8a2516d9b0..fd50ff8c91cda0d7f56a5d2866bd694095b22587 100755 (executable)
@@ -17,6 +17,20 @@ function make_input_name
     echo ${prefix}$(sed -e "s/[^-+a-zA-Z0-9_]/_/g"<<<"$header")
 }
 
+function _dd
+{
+       local msg
+       local ret=0
+
+       msg=$(dd "$@" 2>&1)
+       ret=$?
+       if [ $ret != 0 ]; then
+               echo "failed: dd $@" >&2
+               echo "$msg" >&2
+       fi
+       return $ret
+}
+
 function run_dd_test
 {
     header=$1
@@ -25,11 +39,12 @@ function run_dd_test
 
     input=$(make_input_name "$header")
     INPUT="${INPUT} ${input}"
+       rm -f "$input"
 
     if [ "$bs" = 0 ]; then
-       touch $input
+               touch $input
     else
-       $DD if=/dev/zero of=$input count=1 bs=$bs $flags &> /dev/null
+               _dd if=/dev/zero of=$input count=1 bs=$bs $flags || return
     fi
 
     $TS_CMD_FINCORE --output $COLUMNS  --bytes --noheadings $input
@@ -47,9 +62,10 @@ function run_dd_dd_test
 
     input=$(make_input_name "$header")
     INPUT="${INPUT} ${input}"
+       rm -f "$input"
 
-    $DD if=/dev/zero of=$input count=1 bs=$bs $flags0 &> /dev/null
-    $DD if=/dev/zero of=$input count=1 bs=$bs $flags1 &> /dev/null
+    _dd if=/dev/zero of=$input count=1 bs=$bs $flags0 || return
+    _dd if=/dev/zero of=$input count=1 bs=$bs $flags1 || return
 
     $TS_CMD_FINCORE --output $COLUMNS --bytes --noheadings $input
 
@@ -75,13 +91,6 @@ else
 fi
 
 
-# seems unsupported by some dd(1) version
-#DD_FLAGS="status=none"
-
-DD_FLAGS=
-DD="dd $DD_FLAGS"
-
-
 ts_check_test_command "$TS_CMD_FINCORE"
 ts_cd "$TS_OUTDIR"