OSDN Git Service

Merge remote-tracking branch 'toybox/master' into HEAD
[android-x86/external-toybox.git] / tests / dd.test
index 42cd170..9da2108 100755 (executable)
@@ -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" \
@@ -43,6 +49,9 @@ unlink softlink && rm -f file
 
 testing "if=file of=file (same file)" "dd if=input of=input $opt &&
    [ -f input ] && cat input && echo 'yes'" "yes\n" "I WANT\n" ""
+testing "same file notrunc" \
+  "dd if=input of=input conv=notrunc $opt && cat input" \
+  "I WANT\n" "I WANT\n" ""
 
 testing "with ibs obs bs" "dd ibs=2 obs=5 bs=9 $opt" "I WANT\n" "" "I WANT\n"
 testing "with ibs obs bs if" "dd ibs=2 obs=5 bs=9 if=input $opt" \
@@ -61,9 +70,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 +87,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" ""