[PATCH 4/5] tests: handle dd errors in fincore/count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>

On dd error the test will fail earlier and the test diff will be
more useful.

Signed-off-by: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>
---
 tests/ts/fincore/count | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/tests/ts/fincore/count b/tests/ts/fincore/count
index be81552..fd50ff8 100755
--- a/tests/ts/fincore/count
+++ b/tests/ts/fincore/count
@@ -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"
 
-- 
1.8.5.6

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux