diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2005-09-23 15:44:46 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2005-09-23 15:44:46 +0000 |
commit | b47a74f4e773dee93c60116dd34c002c7c118d0b (patch) | |
tree | 7adcb31fbbb5e204ab577cbe31c2f72cb3b5387f /testsuite | |
parent | 0a44c1777134281be6b00c69b8d6b8668ea1dbf9 (diff) | |
download | busybox-w32-b47a74f4e773dee93c60116dd34c002c7c118d0b.tar.gz busybox-w32-b47a74f4e773dee93c60116dd34c002c7c118d0b.tar.bz2 busybox-w32-b47a74f4e773dee93c60116dd34c002c7c118d0b.zip |
- introduce variable _BB_CONFIG_DEP to the new test harness.
This is used to see if given tests should be run (are available) or not.
Print "UNTESTED: descr" if the applet or feature is not available.
- add _BB_CONFIG_DEP to existing new.tests
- move old grep test to new test infrastructure and add a few more test for
grep.
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/busybox.tests | 3 | ||||
-rwxr-xr-x | testsuite/egrep.tests | 20 | ||||
-rw-r--r-- | testsuite/grep.tests | 82 | ||||
-rw-r--r-- | testsuite/grep/egrep-is-not-case-insensitive | 2 | ||||
-rw-r--r-- | testsuite/grep/egrep-supports-extended-regexps | 2 | ||||
-rw-r--r-- | testsuite/grep/grep-handles-binary-files | 1 | ||||
-rw-r--r-- | testsuite/grep/grep-handles-multiple-regexps | 1 | ||||
-rw-r--r-- | testsuite/grep/grep-is-also-egrep | 2 | ||||
-rw-r--r-- | testsuite/grep/grep-matches-NUL | 8 | ||||
-rwxr-xr-x | testsuite/runtest | 11 | ||||
-rwxr-xr-x | testsuite/sort.tests | 3 | ||||
-rwxr-xr-x | testsuite/testing.sh | 21 | ||||
-rwxr-xr-x | testsuite/uniq.tests | 3 |
13 files changed, 137 insertions, 22 deletions
diff --git a/testsuite/busybox.tests b/testsuite/busybox.tests index 91dbc797e..7595d061f 100755 --- a/testsuite/busybox.tests +++ b/testsuite/busybox.tests | |||
@@ -7,6 +7,9 @@ | |||
7 | if [ ${#COMMAND} -eq 0 ]; then COMMAND=busybox; fi | 7 | if [ ${#COMMAND} -eq 0 ]; then COMMAND=busybox; fi |
8 | . testing.sh | 8 | . testing.sh |
9 | 9 | ||
10 | # Depends on nothing | ||
11 | _BB_CONFIG_DEP="" | ||
12 | |||
10 | # We'll assume "cat" is built in, because we need some other command to test. | 13 | # We'll assume "cat" is built in, because we need some other command to test. |
11 | 14 | ||
12 | HELPDUMP=`$COMMAND` | 15 | HELPDUMP=`$COMMAND` |
diff --git a/testsuite/egrep.tests b/testsuite/egrep.tests new file mode 100755 index 000000000..b634649bb --- /dev/null +++ b/testsuite/egrep.tests | |||
@@ -0,0 +1,20 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # egrep tests. | ||
4 | # Copyright 2005 by Rob Landley <rob@landley.net> | ||
5 | # Licensed under GPL v2, see file LICENSE for details. | ||
6 | |||
7 | # AUDIT: | ||
8 | |||
9 | [ ${#COMMAND} -eq 0 ] && COMMAND=egrep | ||
10 | . testing.sh | ||
11 | |||
12 | # Depends on FEATURE_GREP_EGREP_ALIAS | ||
13 | _BB_CONFIG_DEP=FEATURE_GREP_EGREP_ALIAS | ||
14 | |||
15 | testing "grep is also egrep" "foo" "foo\n" "" "foo\nbar\n" | ||
16 | testing "egrep is not case insensitive" "foo ; [ \$? -ne 0 ] && echo yes" \ | ||
17 | "yes\n" "" "FOO\n" | ||
18 | |||
19 | |||
20 | exit $FAILCOUNT | ||
diff --git a/testsuite/grep.tests b/testsuite/grep.tests new file mode 100644 index 000000000..c4f534d1a --- /dev/null +++ b/testsuite/grep.tests | |||
@@ -0,0 +1,82 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # grep tests. | ||
4 | # Copyright 2005 by Rob Landley <rob@landley.net> | ||
5 | # Licensed under GPL v2, see file LICENSE for details. | ||
6 | |||
7 | # AUDIT: | ||
8 | |||
9 | [ ${#COMMAND} -eq 0 ] && COMMAND=grep | ||
10 | . testing.sh | ||
11 | |||
12 | # Depends on grep | ||
13 | _BB_CONFIG_DEP=grep | ||
14 | |||
15 | # testing "test name" "options" "expected result" "file input" "stdin" | ||
16 | # file input will be file called "input" | ||
17 | # test can create a file "actual" instead of writing to stdout | ||
18 | |||
19 | # Test exit status | ||
20 | |||
21 | testing "grep (exit with error)" "nonexistent 2> /dev/null ; echo \$?" \ | ||
22 | "1\n" "" "" | ||
23 | testing "grep (exit success)" "grep $0 > /dev/null 2>&1 ; echo \$?" "0\n" \ | ||
24 | "" "" | ||
25 | # Test various data sources and destinations | ||
26 | |||
27 | testing "grep (default to stdin)" "two" "two\n" "" \ | ||
28 | "one\ntwo\nthree\nthree\nthree\n" | ||
29 | testing "grep - (specify stdin)" "two -" "two\n" "" \ | ||
30 | "one\ntwo\nthree\nthree\nthree\n" | ||
31 | testing "grep input (specify file)" "two input" "two\n" \ | ||
32 | "one\ntwo\nthree\nthree\nthree\n" "" | ||
33 | |||
34 | # Note that this assumes actual is empty. | ||
35 | testing "grep input actual (two files)" "two input actual 2> /dev/null" \ | ||
36 | "input:two\n" "one\ntwo\nthree\nthree\nthree\n" "" | ||
37 | |||
38 | testing "grep - infile (specify stdin and file)" "two - input" \ | ||
39 | "(standard input):two\ninput:two\n" "one\ntwo\nthree\n" \ | ||
40 | "one\ntwo\ntoo\nthree\nthree\n" | ||
41 | |||
42 | # Check if we see the correct return value if both stdin and non-existing file | ||
43 | # are given. | ||
44 | testing "grep - nofile (specify stdin and nonexisting file)" \ | ||
45 | "two - nonexistent 2> /dev/null ; echo \$?" \ | ||
46 | "(standard input):two\n(standard input):two\n2\n" \ | ||
47 | "" "one\ntwo\ntwo\nthree\nthree\nthree\n" | ||
48 | testing "grep -q - nofile (specify stdin and nonexisting file, no match)" \ | ||
49 | "-q nomatch - nonexistent 2> /dev/null ; echo \$?" \ | ||
50 | "2\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" | ||
51 | # SUSv3: If the -q option is specified, the exit status shall be zero | ||
52 | # if an input line is selected, even if an error was detected. | ||
53 | testing "grep -q - nofile (specify stdin and nonexisting file, match)" \ | ||
54 | "-q two - nonexistent ; echo \$?" \ | ||
55 | "0\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" | ||
56 | |||
57 | # Test various command line options | ||
58 | # -s no error messages | ||
59 | testing "grep -s nofile (nonexisting file, no match)" \ | ||
60 | "-s nomatch nonexistent ; echo \$?" "2\n" "" "" | ||
61 | testing "grep -s nofile - (stdin and nonexisting file, match)" \ | ||
62 | "-s domatch nonexistent - ; echo \$?" "(standard input):domatch\n2\n" \ | ||
63 | "" "nomatch\ndomatch\nend\n" | ||
64 | |||
65 | # This doesn't match GNU behaviour (Binary file input matches) | ||
66 | # acts like GNU grep -a | ||
67 | testing "grep handles binary files" "foo input" "foo\n" "\0foo\n\n" "" | ||
68 | # This doesn't match GNU behaviour (Binary file (standard input) matches) | ||
69 | # acts like GNU grep -a | ||
70 | testing "grep handles binary stdin" "foo" "foo\n" "" "\0foo\n\n" | ||
71 | |||
72 | testing "grep matches NUL" ". input > /dev/null 2>&1 ; echo \$?" "0\n" "\0\n" "" | ||
73 | |||
74 | # -e regex | ||
75 | testing "grep handles multiple regexps" "-e one -e two input ; echo \$?" \ | ||
76 | "one\ntwo\n0\n" "one\ntwo\n" "" | ||
77 | |||
78 | # Depends on FEATURE_GREP_EGREP_ALIAS | ||
79 | _BB_CONFIG_DEP=FEATURE_GREP_EGREP_ALIAS | ||
80 | testing "grep -E supports extended regexps" "-E fo+" "foo\n" "" "b\ar\nfoo\nbaz" | ||
81 | |||
82 | exit $FAILCOUNT | ||
diff --git a/testsuite/grep/egrep-is-not-case-insensitive b/testsuite/grep/egrep-is-not-case-insensitive deleted file mode 100644 index 881607393..000000000 --- a/testsuite/grep/egrep-is-not-case-insensitive +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | # FEATURE: CONFIG_FEATURE_GREP_EGREP_ALIAS | ||
2 | test x`echo foo | busybox egrep FOO` = x | ||
diff --git a/testsuite/grep/egrep-supports-extended-regexps b/testsuite/grep/egrep-supports-extended-regexps deleted file mode 100644 index 6ef8b9159..000000000 --- a/testsuite/grep/egrep-supports-extended-regexps +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | # FEATURE: CONFIG_FEATURE_GREP_EGREP_ALIAS | ||
2 | echo foo | busybox egrep fo+ | ||
diff --git a/testsuite/grep/grep-handles-binary-files b/testsuite/grep/grep-handles-binary-files deleted file mode 100644 index edb2042e7..000000000 --- a/testsuite/grep/grep-handles-binary-files +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | echo -e '\0foo' | busybox grep foo | ||
diff --git a/testsuite/grep/grep-handles-multiple-regexps b/testsuite/grep/grep-handles-multiple-regexps deleted file mode 100644 index 5c1b8de1f..000000000 --- a/testsuite/grep/grep-handles-multiple-regexps +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | echo foo | busybox grep -e foo -e bar | ||
diff --git a/testsuite/grep/grep-is-also-egrep b/testsuite/grep/grep-is-also-egrep deleted file mode 100644 index 2e6977c28..000000000 --- a/testsuite/grep/grep-is-also-egrep +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | # FEATURE: CONFIG_FEATURE_GREP_EGREP_ALIAS | ||
2 | echo foo | busybox egrep foo | ||
diff --git a/testsuite/grep/grep-matches-NUL b/testsuite/grep/grep-matches-NUL deleted file mode 100644 index 082bd8700..000000000 --- a/testsuite/grep/grep-matches-NUL +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | set +e | ||
2 | echo -e '\0' | busybox grep . | ||
3 | if [ $? != 0 ] ; then | ||
4 | exit 0; | ||
5 | fi | ||
6 | |||
7 | exit 1; | ||
8 | |||
diff --git a/testsuite/runtest b/testsuite/runtest index 7411aec64..32ff462d7 100755 --- a/testsuite/runtest +++ b/testsuite/runtest | |||
@@ -90,21 +90,22 @@ else | |||
90 | fi | 90 | fi |
91 | 91 | ||
92 | for applet in $applets; do | 92 | for applet in $applets; do |
93 | if [ "$applet" == links ]; then continue; fi | 93 | if [ "$applet" = "links" ]; then continue; fi |
94 | if [ "$applet" != CVS -a -d "$srcdir/$applet" ]; then | 94 | if [ "$applet" != "CVS" -a -d "$srcdir/$applet" ]; then |
95 | if run_applet_tests $applet; then | 95 | if run_applet_tests $applet; then |
96 | : | 96 | : |
97 | else | 97 | else |
98 | status=1 | 98 | status=1 |
99 | fi | 99 | fi |
100 | fi | 100 | fi |
101 | applet=`echo "$applet" | sed -n 's/\.tests$//p'` | 101 | applet=$(echo "$applet" | sed -n 's/\.tests$//p') |
102 | if [ ${#applet} != 0 ] | 102 | if [ ${#applet} -ne 0 ] |
103 | then | 103 | then |
104 | mkdir links 2>/dev/null | 104 | mkdir links 2>/dev/null |
105 | rm -f links/"$applet" | 105 | rm -f links/"$applet" |
106 | ln -s ${bindir:-../..}/busybox links/"$applet" | 106 | ln -s ${bindir:-../..}/busybox links/"$applet" |
107 | PATH="$srcdir:$PATH" COMMAND="links/$applet" "${srcdir:-.}/$applet".tests | 107 | PATH="$srcdir:$PATH" COMMAND="links/$applet" \ |
108 | "${srcdir:-.}/$applet".tests | ||
108 | if [ $? -ne 0 ]; then status=1; fi | 109 | if [ $? -ne 0 ]; then status=1; fi |
109 | fi | 110 | fi |
110 | 111 | ||
diff --git a/testsuite/sort.tests b/testsuite/sort.tests index b23cf4312..04d75cfe2 100755 --- a/testsuite/sort.tests +++ b/testsuite/sort.tests | |||
@@ -7,6 +7,9 @@ | |||
7 | if [ ${#COMMAND} -eq 0 ]; then COMMAND=sort; fi | 7 | if [ ${#COMMAND} -eq 0 ]; then COMMAND=sort; fi |
8 | . testing.sh | 8 | . testing.sh |
9 | 9 | ||
10 | # Depends on sort | ||
11 | _BB_CONFIG_DEP=sort | ||
12 | |||
10 | # The basic tests. These should work even with the small busybox. | 13 | # The basic tests. These should work even with the small busybox. |
11 | 14 | ||
12 | testing "sort" "input" "a\nb\nc\n" "c\na\nb\n" "" | 15 | testing "sort" "input" "a\nb\nc\n" "c\na\nb\n" "" |
diff --git a/testsuite/testing.sh b/testsuite/testing.sh index 0925d090d..420cfa1ef 100755 --- a/testsuite/testing.sh +++ b/testsuite/testing.sh | |||
@@ -28,9 +28,19 @@ fi | |||
28 | 28 | ||
29 | export FAILCOUNT=0 | 29 | export FAILCOUNT=0 |
30 | 30 | ||
31 | # Helper functions | ||
32 | |||
33 | config_is_set () | ||
34 | { | ||
35 | local uc_what=$(echo ${1?} | tr a-z A-Z) | ||
36 | grep -q "^[ ]*CONFIG_${uc_what}" ${bindir:-..}/.config || \ | ||
37 | grep -q "^[ ]*BB_CONFIG_${uc_what}" ${bindir:-..}/.config | ||
38 | return $? | ||
39 | } | ||
40 | |||
31 | # The testing function | 41 | # The testing function |
32 | 42 | ||
33 | function testing() | 43 | testing() |
34 | { | 44 | { |
35 | if [ $# -ne 5 ] | 45 | if [ $# -ne 5 ] |
36 | then | 46 | then |
@@ -38,6 +48,15 @@ function testing() | |||
38 | exit | 48 | exit |
39 | fi | 49 | fi |
40 | 50 | ||
51 | if [ ${force_tests:-0} -ne 1 -a -n "$_BB_CONFIG_DEP" ] | ||
52 | then | ||
53 | if ! config_is_set "$_BB_CONFIG_DEP" | ||
54 | then | ||
55 | echo "UNTESTED: $1" | ||
56 | return 0 | ||
57 | fi | ||
58 | fi | ||
59 | |||
41 | f=$FAILCOUNT | 60 | f=$FAILCOUNT |
42 | echo -ne "$3" > expected | 61 | echo -ne "$3" > expected |
43 | echo -ne "$4" > input | 62 | echo -ne "$4" > input |
diff --git a/testsuite/uniq.tests b/testsuite/uniq.tests index 95764740b..27d9561e1 100755 --- a/testsuite/uniq.tests +++ b/testsuite/uniq.tests | |||
@@ -9,6 +9,9 @@ | |||
9 | if [ ${#COMMAND} -eq 0 ]; then COMMAND=uniq; fi | 9 | if [ ${#COMMAND} -eq 0 ]; then COMMAND=uniq; fi |
10 | . testing.sh | 10 | . testing.sh |
11 | 11 | ||
12 | # Depends on uniq | ||
13 | _BB_CONFIG_DEP=uniq | ||
14 | |||
12 | # testing "test name" "options" "expected result" "file input" "stdin" | 15 | # testing "test name" "options" "expected result" "file input" "stdin" |
13 | # file input will be file called "input" | 16 | # file input will be file called "input" |
14 | # test can create a file "actual" instead of writing to stdout | 17 | # test can create a file "actual" instead of writing to stdout |