2018-09-13 18:31:45 +05:30
|
|
|
#!/bin/sh
|
|
|
|
# Copyright 2018 Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
|
|
|
|
# Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
|
|
|
|
|
|
|
. ./testing.sh
|
|
|
|
|
|
|
|
# testing "test name" "command" "expected result" "file input" "stdin"
|
|
|
|
|
|
|
|
cat <<EOF > head.input
|
|
|
|
line 1
|
|
|
|
line 2
|
|
|
|
line 3
|
|
|
|
line 4
|
|
|
|
line 5
|
|
|
|
line 6
|
|
|
|
line 7
|
|
|
|
line 8
|
|
|
|
line 9
|
|
|
|
line 10
|
|
|
|
line 11
|
|
|
|
line 12
|
|
|
|
EOF
|
|
|
|
|
2018-09-13 18:31:46 +05:30
|
|
|
testing "head (without args)" \
|
|
|
|
"head head.input" \
|
|
|
|
"line 1\nline 2\nline 3\nline 4\nline 5\nline 6\nline 7\nline 8\nline 9\nline 10\n" \
|
|
|
|
"" ""
|
|
|
|
|
|
|
|
testing "head -n <positive number>" \
|
|
|
|
"head -n 2 head.input" \
|
|
|
|
"line 1\nline 2\n" \
|
|
|
|
"" ""
|
|
|
|
|
2018-12-28 03:22:13 +05:30
|
|
|
optional FEATURE_FANCY_HEAD
|
2018-09-13 18:31:45 +05:30
|
|
|
testing "head -n <negative number>" \
|
|
|
|
"head -n -9 head.input" \
|
|
|
|
"line 1\nline 2\nline 3\n" \
|
|
|
|
"" ""
|
2018-12-28 03:22:13 +05:30
|
|
|
SKIP=
|
2018-09-13 18:31:45 +05:30
|
|
|
|
|
|
|
rm head.input
|
|
|
|
|
|
|
|
exit $FAILCOUNT
|