]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add more tests for line(1)
authorRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 13 Jun 2017 13:33:58 +0000 (15:33 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 14 Jun 2017 09:48:22 +0000 (11:48 +0200)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tests/expected/misc/line
tests/ts/misc/line

index fa7dcebb0fc0fa75f59e2830fa216cbc0a775577..783ef801f5f2bec66f221bb790057a87cc805531 100644 (file)
@@ -1,7 +1,25 @@
+# usually behave like "head -n 1"
 a
 ret: 0
+# never consume more than one line
 1
 2
 ret: 0
+# add a newline
+abc
+ret: 1
+# print one newline on empty input
 
 ret: 1
+# add a newline, return 1 when EOF
+xyz
+ret: 1
+# print one newline on empty input, return 1 when EOF
+
+ret: 1
+# large line of zero bytes
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00100000  0a                                                |.|
+00100001
+ret: 0
index 71d5c0424782c54a768d4ba9e86d9368dcbbea9e..186a78958fcd29a3d11f3f1039fb225ce68ad708 100755 (executable)
@@ -19,19 +19,40 @@ TS_DESC="line"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_LINE"
+ts_check_test_command "$TS_CMD_HEXDUMP"
 
-# usually behave like "head -n 1"
+ts_log '# usually behave like "head -n 1"'
 printf "a\nb\n" |
-       $TS_CMD_LINE > $TS_OUTPUT 2>&1
+       $TS_CMD_LINE >> $TS_OUTPUT 2>&1
 echo "ret: $?" >> $TS_OUTPUT
 
-# never consume more than one line
+ts_log '# never consume more than one line'
 printf "1\n2\n" |
        ($TS_CMD_LINE && $TS_CMD_LINE) >> $TS_OUTPUT 2>&1
 echo "ret: $?" >> $TS_OUTPUT
 
-# always print one newline, return 1 on EOF
+ts_log '# add a newline'
+printf "abc" |
+       $TS_CMD_LINE >> $TS_OUTPUT 2>&1
+echo "ret: $?" >> $TS_OUTPUT
+
+ts_log '# print one newline on empty input'
+printf "" |
+       $TS_CMD_LINE >> $TS_OUTPUT 2>&1
+echo "ret: $?" >> $TS_OUTPUT
+
+ts_log '# add a newline, return 1 when EOF'
+(printf "xyz" && cat </dev/null) |
+       $TS_CMD_LINE >> $TS_OUTPUT 2>&1
+echo "ret: $?" >> $TS_OUTPUT
+
+ts_log '# print one newline on empty input, return 1 when EOF'
 $TS_CMD_LINE </dev/null >> $TS_OUTPUT 2>&1
 echo "ret: $?" >> $TS_OUTPUT
 
+ts_log '# large line of zero bytes'
+dd if=/dev/zero  bs=1k count=1k 2>/dev/null |
+       $TS_CMD_LINE line | $TS_CMD_HEXDUMP -C >> $TS_OUTPUT 2>&1
+echo "ret: $?" >> $TS_OUTPUT
+
 ts_finalize