]> git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/misc/line
tests: split stdout and stderr
[thirdparty/util-linux.git] / tests / ts / misc / line
1 #!/bin/bash
2
3 # This file is part of util-linux.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This file is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 TS_TOPDIR="${0%/*}/../.."
16 TS_DESC="line"
17
18 . $TS_TOPDIR/functions.sh
19 ts_init "$*"
20
21 ts_check_test_command "$TS_CMD_LINE"
22 ts_check_test_command "$TS_CMD_HEXDUMP"
23
24 ts_log '# usually behave like "head -n 1"'
25 printf "a\nb\n" |
26 $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
27 echo "ret: $?" >> $TS_OUTPUT
28
29 ts_log '# never consume more than one line'
30 printf "1\n2\n" |
31 ($TS_CMD_LINE && $TS_CMD_LINE) >> $TS_OUTPUT 2>> $TS_ERRLOG
32 echo "ret: $?" >> $TS_OUTPUT
33
34 ts_log '# add a newline'
35 printf "abc" |
36 $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
37 echo "ret: $?" >> $TS_OUTPUT
38
39 ts_log '# print one newline on empty input'
40 printf "" |
41 $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
42 echo "ret: $?" >> $TS_OUTPUT
43
44 ts_log '# add a newline, return 1 when EOF'
45 (printf "xyz" && cat </dev/null) |
46 $TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
47 echo "ret: $?" >> $TS_OUTPUT
48
49 ts_log '# print one newline on empty input, return 1 when EOF'
50 $TS_CMD_LINE </dev/null >> $TS_OUTPUT 2>> $TS_ERRLOG
51 echo "ret: $?" >> $TS_OUTPUT
52
53 ts_log '# large line of zero bytes'
54 dd if=/dev/zero bs=1k count=1k 2>/dev/null |
55 $TS_CMD_LINE line | $TS_CMD_HEXDUMP -C >> $TS_OUTPUT 2>> $TS_ERRLOG
56 echo "ret: $?" >> $TS_OUTPUT
57
58 ts_finalize