Annotation of /trunk/mkinitrd-magellan/busybox/testsuite/grep.tests
Parent Directory | Revision Log
Revision 816 -
(hide annotations)
(download)
Fri Apr 24 18:33:46 2009 UTC (15 years ago) by niro
File size: 3418 byte(s)
Fri Apr 24 18:33:46 2009 UTC (15 years ago) by niro
File size: 3418 byte(s)
-updated to busybox-1.13.4
1 | niro | 532 | #!/bin/sh |
2 | |||
3 | # Copyright 2005 by Rob Landley <rob@landley.net> | ||
4 | # Licensed under GPL v2, see file LICENSE for details. | ||
5 | |||
6 | # AUDIT: | ||
7 | |||
8 | . testing.sh | ||
9 | |||
10 | # testing "test name" "options" "expected result" "file input" "stdin" | ||
11 | # file input will be file called "input" | ||
12 | # test can create a file "actual" instead of writing to stdout | ||
13 | |||
14 | # Test exit status | ||
15 | |||
16 | testing "grep (exit with error)" "grep nonexistent 2> /dev/null ; echo \$?" \ | ||
17 | "1\n" "" "" | ||
18 | testing "grep (exit success)" "grep grep $0 > /dev/null 2>&1 ; echo \$?" "0\n" \ | ||
19 | "" "" | ||
20 | # Test various data sources and destinations | ||
21 | |||
22 | testing "grep (default to stdin)" "grep two" "two\n" "" \ | ||
23 | "one\ntwo\nthree\nthree\nthree\n" | ||
24 | testing "grep - (specify stdin)" "grep two -" "two\n" "" \ | ||
25 | "one\ntwo\nthree\nthree\nthree\n" | ||
26 | testing "grep input (specify file)" "grep two input" "two\n" \ | ||
27 | "one\ntwo\nthree\nthree\nthree\n" "" | ||
28 | |||
29 | niro | 816 | # GNU grep 2.5.3 outputs a new line character after the located string |
30 | # even if there is no new line character in the input | ||
31 | testing "grep (no newline at EOL)" "grep bug input" "bug\n" "bug" "" | ||
32 | niro | 532 | |
33 | niro | 816 | >empty |
34 | testing "grep two files" "grep two input empty 2>/dev/null" \ | ||
35 | niro | 532 | "input:two\n" "one\ntwo\nthree\nthree\nthree\n" "" |
36 | niro | 816 | rm empty |
37 | niro | 532 | |
38 | testing "grep - infile (specify stdin and file)" "grep 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 | "grep 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 | "grep -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 | "grep -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 | "grep -s nomatch nonexistent ; echo \$?" "2\n" "" "" | ||
61 | testing "grep -s nofile - (stdin and nonexisting file, match)" \ | ||
62 | "grep -s domatch nonexistent - ; echo \$?" \ | ||
63 | "(standard input):domatch\n2\n" "" "nomatch\ndomatch\nend\n" | ||
64 | |||
65 | niro | 816 | testing "grep handles NUL in files" "grep -a foo input" "\0foo\n" "\0foo\n\n" "" |
66 | testing "grep handles NUL on stdin" "grep -a foo" "\0foo\n" "" "\0foo\n\n" | ||
67 | niro | 532 | |
68 | testing "grep matches NUL" "grep . input > /dev/null 2>&1 ; echo \$?" \ | ||
69 | "0\n" "\0\n" "" | ||
70 | |||
71 | # -e regex | ||
72 | testing "grep handles multiple regexps" "grep -e one -e two input ; echo \$?" \ | ||
73 | "one\ntwo\n0\n" "one\ntwo\n" "" | ||
74 | niro | 816 | testing "grep -F handles multiple expessions" "grep -F -e one -e two input ; echo \$?" \ |
75 | "one\ntwo\n0\n" "one\ntwo\n" "" | ||
76 | niro | 532 | |
77 | niro | 816 | # -f file/- |
78 | testing "grep can read regexps from stdin" "grep -f - input ; echo \$?" \ | ||
79 | "two\nthree\n0\n" "tw\ntwo\nthree\n" "tw.\nthr\n" | ||
80 | |||
81 | niro | 532 | optional FEATURE_GREP_EGREP_ALIAS |
82 | testing "grep -E supports extended regexps" "grep -E fo+" "foo\n" "" \ | ||
83 | "b\ar\nfoo\nbaz" | ||
84 | testing "grep is also egrep" "egrep foo" "foo\n" "" "foo\nbar\n" | ||
85 | testing "egrep is not case insensitive" \ | ||
86 | "egrep foo ; [ \$? -ne 0 ] && echo yes" "yes\n" "" "FOO\n" | ||
87 | |||
88 | exit $FAILCOUNT |
Properties
Name | Value |
---|---|
svn:executable | * |