From d5088a059649daf34e729995bb3daa3eb64fa432 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 7 Jul 2016 21:48:33 -0700 Subject: dd improvements. Support hex (requested by users). Support status=noxfer and status=none (requested by users). Fix status output. Clarify large numbers in --help output. Use O_TRUNC rather than ftruncate unless we're also seeking. New tests. Also partial cleanup (reuse of existing code, removal of non-GLOBALS globals, and merge dd_main and do_dd). --- tests/dd.test | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/dd.test b/tests/dd.test index 42cd170a..82214506 100755 --- a/tests/dd.test +++ b/tests/dd.test @@ -10,6 +10,12 @@ opt="2>/dev/null" #testing "name" "command" "result" "infile" "stdin" +# Test suffixed number parsing; `count` is representative. +testing "count=2" "dd if=input count=2 ibs=1 $opt" "hi" "high\n" "" +testing "count= 2" "dd if=input 'count= 2' ibs=1 $opt" "hi" "high\n" "" +testing "count=0x2" "dd if=input 'count=0x2' ibs=1 $opt" "hi" "high\n" "" +testing "count=-2" "dd if=input 'count=-2' ibs=1 2>&1" "dd: invalid number '-2'\n" "" "" + testing "if=(file)" "dd if=input $opt" "I WANT\n" "I WANT\n" "" testing "of=(file)" "dd of=file $opt && cat file" "I WANT\n" "" "I WANT\n" testing "if=file of=file" "dd if=input of=foo $opt && cat foo && rm -f foo" \ @@ -61,9 +67,6 @@ testing "with skip if" "dd skip=0 if=input $opt" "I WANT\n" "I WANT\n" "" testing "with seek" "dd seek=0 $opt" "I WANT\n" "" "I WANT\n" testing "with seek if" "dd seek=0 if=input $opt" "I WANT\n" "I WANT\n" "" -# These type of conv is not supported in toybox: 'ascii', 'ebcdic', 'ibm', -# 'block', 'unblock', 'nocreat', 'notronc', 'lcase', 'ucase', 'excl', 'swab' - # Testing only 'notrunc', 'noerror', 'fsync', 'sync' testing "conv=notrunc" "dd conv=notrunc $opt" "I WANT\n" "" "I WANT\n" @@ -81,3 +84,7 @@ testing "conv=fsync with IF" "dd conv=fsync if=input $opt" "I WANT\n" \ testing "conv=sync" "dd conv=sync $opt | head -n 1" "I WANT\n" "" "I WANT\n" testing "conv=sync with IF" "dd conv=sync if=input $opt | head -n 1" "I WANT\n" \ "I WANT\n" "" + +# status=noxfer|none +testing "status=noxfer" "dd if=input status=noxfer ibs=1 2>&1" "input\n6+0 records in\n0+1 records out\n" "input\n" "" +testing "status=none" "dd if=input status=none ibs=1 2>&1" "input\n" "input\n" "" -- cgit v1.2.3