diff options
author | Rob Landley <rob@landley.net> | 2006-03-16 15:20:45 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-03-16 15:20:45 +0000 |
commit | 4bb1b04fd1d7d6fe410e1af14816d11da456aac5 (patch) | |
tree | 601a54598057fc267def41fce1acecfb8e5a2845 /testsuite/grep.tests | |
parent | ea9a471acd94f604f360ea16df5896e795361ac7 (diff) | |
download | busybox-w32-4bb1b04fd1d7d6fe410e1af14816d11da456aac5.tar.gz busybox-w32-4bb1b04fd1d7d6fe410e1af14816d11da456aac5.tar.bz2 busybox-w32-4bb1b04fd1d7d6fe410e1af14816d11da456aac5.zip |
Redo test suite to be able to test more than one command at a time. Eliminate
$COMMAND environment variable, instead put full command line (including
command to run) in second argument. Modify $PATH to have test versions of
commands at start of path. (Also more infrastructure for testing as root,
work in progress...)
Diffstat (limited to 'testsuite/grep.tests')
-rwxr-xr-x | testsuite/grep.tests | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/testsuite/grep.tests b/testsuite/grep.tests index 2a7a7b901..cc9520e90 100755 --- a/testsuite/grep.tests +++ b/testsuite/grep.tests | |||
@@ -6,7 +6,6 @@ | |||
6 | 6 | ||
7 | # AUDIT: | 7 | # AUDIT: |
8 | 8 | ||
9 | [ ${#COMMAND} -eq 0 ] && COMMAND=grep | ||
10 | . testing.sh | 9 | . testing.sh |
11 | 10 | ||
12 | # testing "test name" "options" "expected result" "file input" "stdin" | 11 | # testing "test name" "options" "expected result" "file input" "stdin" |
@@ -15,64 +14,69 @@ | |||
15 | 14 | ||
16 | # Test exit status | 15 | # Test exit status |
17 | 16 | ||
18 | testing "grep (exit with error)" "nonexistent 2> /dev/null ; echo \$?" \ | 17 | testing "grep (exit with error)" "grep nonexistent 2> /dev/null ; echo \$?" \ |
19 | "1\n" "" "" | 18 | "1\n" "" "" |
20 | testing "grep (exit success)" "grep $0 > /dev/null 2>&1 ; echo \$?" "0\n" \ | 19 | testing "grep (exit success)" "grep grep $0 > /dev/null 2>&1 ; echo \$?" "0\n" \ |
21 | "" "" | 20 | "" "" |
22 | # Test various data sources and destinations | 21 | # Test various data sources and destinations |
23 | 22 | ||
24 | testing "grep (default to stdin)" "two" "two\n" "" \ | 23 | testing "grep (default to stdin)" "grep two" "two\n" "" \ |
25 | "one\ntwo\nthree\nthree\nthree\n" | 24 | "one\ntwo\nthree\nthree\nthree\n" |
26 | testing "grep - (specify stdin)" "two -" "two\n" "" \ | 25 | testing "grep - (specify stdin)" "grep two -" "two\n" "" \ |
27 | "one\ntwo\nthree\nthree\nthree\n" | 26 | "one\ntwo\nthree\nthree\nthree\n" |
28 | testing "grep input (specify file)" "two input" "two\n" \ | 27 | testing "grep input (specify file)" "grep two input" "two\n" \ |
29 | "one\ntwo\nthree\nthree\nthree\n" "" | 28 | "one\ntwo\nthree\nthree\nthree\n" "" |
30 | 29 | ||
31 | # Note that this assumes actual is empty. | 30 | # Note that this assumes actual is empty. |
32 | testing "grep input actual (two files)" "two input actual 2> /dev/null" \ | 31 | testing "grep input actual (two files)" "grep two input actual 2> /dev/null" \ |
33 | "input:two\n" "one\ntwo\nthree\nthree\nthree\n" "" | 32 | "input:two\n" "one\ntwo\nthree\nthree\nthree\n" "" |
34 | 33 | ||
35 | testing "grep - infile (specify stdin and file)" "two - input" \ | 34 | testing "grep - infile (specify stdin and file)" "grep two - input" \ |
36 | "(standard input):two\ninput:two\n" "one\ntwo\nthree\n" \ | 35 | "(standard input):two\ninput:two\n" "one\ntwo\nthree\n" \ |
37 | "one\ntwo\ntoo\nthree\nthree\n" | 36 | "one\ntwo\ntoo\nthree\nthree\n" |
38 | 37 | ||
39 | # Check if we see the correct return value if both stdin and non-existing file | 38 | # Check if we see the correct return value if both stdin and non-existing file |
40 | # are given. | 39 | # are given. |
41 | testing "grep - nofile (specify stdin and nonexisting file)" \ | 40 | testing "grep - nofile (specify stdin and nonexisting file)" \ |
42 | "two - nonexistent 2> /dev/null ; echo \$?" \ | 41 | "grep two - nonexistent 2> /dev/null ; echo \$?" \ |
43 | "(standard input):two\n(standard input):two\n2\n" \ | 42 | "(standard input):two\n(standard input):two\n2\n" \ |
44 | "" "one\ntwo\ntwo\nthree\nthree\nthree\n" | 43 | "" "one\ntwo\ntwo\nthree\nthree\nthree\n" |
45 | testing "grep -q - nofile (specify stdin and nonexisting file, no match)" \ | 44 | testing "grep -q - nofile (specify stdin and nonexisting file, no match)" \ |
46 | "-q nomatch - nonexistent 2> /dev/null ; echo \$?" \ | 45 | "grep -q nomatch - nonexistent 2> /dev/null ; echo \$?" \ |
47 | "2\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" | 46 | "2\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" |
48 | # SUSv3: If the -q option is specified, the exit status shall be zero | 47 | # SUSv3: If the -q option is specified, the exit status shall be zero |
49 | # if an input line is selected, even if an error was detected. | 48 | # if an input line is selected, even if an error was detected. |
50 | testing "grep -q - nofile (specify stdin and nonexisting file, match)" \ | 49 | testing "grep -q - nofile (specify stdin and nonexisting file, match)" \ |
51 | "-q two - nonexistent ; echo \$?" \ | 50 | "grep -q two - nonexistent ; echo \$?" \ |
52 | "0\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" | 51 | "0\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" |
53 | 52 | ||
54 | # Test various command line options | 53 | # Test various command line options |
55 | # -s no error messages | 54 | # -s no error messages |
56 | testing "grep -s nofile (nonexisting file, no match)" \ | 55 | testing "grep -s nofile (nonexisting file, no match)" \ |
57 | "-s nomatch nonexistent ; echo \$?" "2\n" "" "" | 56 | "grep -s nomatch nonexistent ; echo \$?" "2\n" "" "" |
58 | testing "grep -s nofile - (stdin and nonexisting file, match)" \ | 57 | testing "grep -s nofile - (stdin and nonexisting file, match)" \ |
59 | "-s domatch nonexistent - ; echo \$?" "(standard input):domatch\n2\n" \ | 58 | "grep -s domatch nonexistent - ; echo \$?" \ |
60 | "" "nomatch\ndomatch\nend\n" | 59 | "(standard input):domatch\n2\n" "" "nomatch\ndomatch\nend\n" |
61 | 60 | ||
62 | # This doesn't match GNU behaviour (Binary file input matches) | 61 | # This doesn't match GNU behaviour (Binary file input matches) |
63 | # acts like GNU grep -a | 62 | # acts like GNU grep -a |
64 | testing "grep handles binary files" "foo input" "foo\n" "\0foo\n\n" "" | 63 | testing "grep handles binary files" "grep foo input" "foo\n" "\0foo\n\n" "" |
65 | # This doesn't match GNU behaviour (Binary file (standard input) matches) | 64 | # This doesn't match GNU behaviour (Binary file (standard input) matches) |
66 | # acts like GNU grep -a | 65 | # acts like GNU grep -a |
67 | testing "grep handles binary stdin" "foo" "foo\n" "" "\0foo\n\n" | 66 | testing "grep handles binary stdin" "grep foo" "foo\n" "" "\0foo\n\n" |
68 | 67 | ||
69 | testing "grep matches NUL" ". input > /dev/null 2>&1 ; echo \$?" "0\n" "\0\n" "" | 68 | testing "grep matches NUL" "grep . input > /dev/null 2>&1 ; echo \$?" \ |
69 | "0\n" "\0\n" "" | ||
70 | 70 | ||
71 | # -e regex | 71 | # -e regex |
72 | testing "grep handles multiple regexps" "-e one -e two input ; echo \$?" \ | 72 | testing "grep handles multiple regexps" "grep -e one -e two input ; echo \$?" \ |
73 | "one\ntwo\n0\n" "one\ntwo\n" "" | 73 | "one\ntwo\n0\n" "one\ntwo\n" "" |
74 | 74 | ||
75 | optional FEATURE_GREP_EGREP_ALIAS | 75 | optional FEATURE_GREP_EGREP_ALIAS |
76 | testing "grep -E supports extended regexps" "-E fo+" "foo\n" "" "b\ar\nfoo\nbaz" | 76 | testing "grep -E supports extended regexps" "grep -E fo+" "foo\n" "" \ |
77 | "b\ar\nfoo\nbaz" | ||
78 | testing "grep is also egrep" "egrep foo" "foo\n" "" "foo\nbar\n" | ||
79 | testing "egrep is not case insensitive" \ | ||
80 | "egrep foo ; [ \$? -ne 0 ] && echo yes" "yes\n" "" "FOO\n" | ||
77 | 81 | ||
78 | exit $FAILCOUNT | 82 | exit $FAILCOUNT |