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/grep.tests | |
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/grep.tests')
-rw-r--r-- | testsuite/grep.tests | 82 |
1 files changed, 82 insertions, 0 deletions
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 | ||