diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-26 05:38:20 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-26 05:38:20 +0000 |
commit | 4e1e7205235510b3adeb415b4d8997932276cb81 (patch) | |
tree | e2d874580db07b436cbb0e6b326adbf0438a3e3e | |
parent | ed270a5f32e4fee0d4b30595c888df54ac878fba (diff) | |
download | busybox-w32-4e1e7205235510b3adeb415b4d8997932276cb81.tar.gz busybox-w32-4e1e7205235510b3adeb415b4d8997932276cb81.tar.bz2 busybox-w32-4e1e7205235510b3adeb415b4d8997932276cb81.zip |
testsuite: add tests for cut and grep;
slight improvements to infrastructure
-rw-r--r-- | testsuite/cut.tests | 19 | ||||
-rwxr-xr-x | testsuite/grep.tests | 7 | ||||
-rwxr-xr-x | testsuite/runtest | 10 | ||||
-rwxr-xr-x | testsuite/testing.sh | 2 |
4 files changed, 33 insertions, 5 deletions
diff --git a/testsuite/cut.tests b/testsuite/cut.tests new file mode 100644 index 000000000..e332e801d --- /dev/null +++ b/testsuite/cut.tests | |||
@@ -0,0 +1,19 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # grep tests. | ||
4 | # Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com> | ||
5 | # Licensed under GPL v2, see file LICENSE for details. | ||
6 | |||
7 | . testing.sh | ||
8 | |||
9 | # testing "test name" "options" "expected result" "file input" "stdin" | ||
10 | # file input will be file called "input" | ||
11 | # test can create a file "actual" instead of writing to stdout | ||
12 | |||
13 | testing "cut '-' (stdin) and multi file handling" \ | ||
14 | "cut -d' ' -f2 - input" \ | ||
15 | "over\n""quick\n" \ | ||
16 | "the quick brown fox\n" \ | ||
17 | "jumps over the lazy dog\n" \ | ||
18 | |||
19 | exit $FAILCOUNT | ||
diff --git a/testsuite/grep.tests b/testsuite/grep.tests index ef0de482b..afbe8e7c9 100755 --- a/testsuite/grep.tests +++ b/testsuite/grep.tests | |||
@@ -29,9 +29,10 @@ testing "grep input (specify file)" "grep two input" "two\n" \ | |||
29 | 29 | ||
30 | testing "grep (no newline at EOL)" "grep bug" "bug" "bug" "" | 30 | testing "grep (no newline at EOL)" "grep bug" "bug" "bug" "" |
31 | 31 | ||
32 | # Note that this assumes actual is empty. | 32 | >empty |
33 | testing "grep input actual (two files)" "grep two input actual 2> /dev/null" \ | 33 | testing "grep two files" "grep two input empty 2>/dev/null" \ |
34 | "input:two\n" "one\ntwo\nthree\nthree\nthree\n" "" | 34 | "input:two\n" "one\ntwo\nthree\nthree\nthree\n" "" |
35 | rm empty | ||
35 | 36 | ||
36 | testing "grep - infile (specify stdin and file)" "grep two - input" \ | 37 | testing "grep - infile (specify stdin and file)" "grep two - input" \ |
37 | "(standard input):two\ninput:two\n" "one\ntwo\nthree\n" \ | 38 | "(standard input):two\ninput:two\n" "one\ntwo\nthree\n" \ |
@@ -73,6 +74,8 @@ testing "grep matches NUL" "grep . input > /dev/null 2>&1 ; echo \$?" \ | |||
73 | # -e regex | 74 | # -e regex |
74 | testing "grep handles multiple regexps" "grep -e one -e two input ; echo \$?" \ | 75 | testing "grep handles multiple regexps" "grep -e one -e two input ; echo \$?" \ |
75 | "one\ntwo\n0\n" "one\ntwo\n" "" | 76 | "one\ntwo\n0\n" "one\ntwo\n" "" |
77 | testing "grep -F handles multiple expessions" "grep -F -e one -e two input ; echo \$?" \ | ||
78 | "one\ntwo\n0\n" "one\ntwo\n" "" | ||
76 | 79 | ||
77 | optional FEATURE_GREP_EGREP_ALIAS | 80 | optional FEATURE_GREP_EGREP_ALIAS |
78 | testing "grep -E supports extended regexps" "grep -E fo+" "foo\n" "" \ | 81 | testing "grep -E supports extended regexps" "grep -E fo+" "foo\n" "" \ |
diff --git a/testsuite/runtest b/testsuite/runtest index 0f081f9a5..92cbfdf4e 100755 --- a/testsuite/runtest +++ b/testsuite/runtest | |||
@@ -127,7 +127,7 @@ for applet in $applets; do | |||
127 | echo "SKIPPED: $applet (not built)" | 127 | echo "SKIPPED: $applet (not built)" |
128 | continue | 128 | continue |
129 | fi | 129 | fi |
130 | if PATH="$LINKSDIR":$tsdir:$bindir:$PATH \ | 130 | if PATH="$LINKSDIR:$tsdir:$bindir:$PATH" \ |
131 | "${tsdir:-.}/$applet".tests | 131 | "${tsdir:-.}/$applet".tests |
132 | then | 132 | then |
133 | : | 133 | : |
@@ -137,5 +137,11 @@ for applet in $applets; do | |||
137 | fi | 137 | fi |
138 | 138 | ||
139 | done | 139 | done |
140 | rm -rf "$LINKSDIR" | 140 | |
141 | # Leaving the dir makes it somewhat easier to run failed test by hand | ||
142 | #rm -rf "$LINKSDIR" | ||
143 | |||
144 | if [ $status != 0 -a x"$VERBOSE" = x ]; then | ||
145 | echo "Failures detected, running with VERBOSE=1 will give more info" | ||
146 | fi | ||
141 | exit $status | 147 | exit $status |
diff --git a/testsuite/testing.sh b/testsuite/testing.sh index a886a76eb..94e90d77e 100755 --- a/testsuite/testing.sh +++ b/testsuite/testing.sh | |||
@@ -58,7 +58,7 @@ testing() | |||
58 | 58 | ||
59 | if [ $# -ne 5 ] | 59 | if [ $# -ne 5 ] |
60 | then | 60 | then |
61 | echo "Test $NAME has the wrong number of arguments ($# $*)" >&2 | 61 | echo "Test $NAME has wrong number of arguments (must be 5) ($# $*)" >&2 |
62 | exit | 62 | exit |
63 | fi | 63 | fi |
64 | 64 | ||