annotate tests/grep.test @ 1753:0f940c4f9658 draft

Promote runcon to android (and add an android menu).
author Rob Landley <rob@landley.net>
date Mon, 23 Mar 2015 13:45:47 -0500
parents 8700cbe1cb29
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
980
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
1 #!/bin/bash
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
2
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
4
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
5 # Copyright 2013 by Kyungsu Kim <kaspyx@gmail.com>
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
6 # Copyright 2013 by Kyungwan Han <asura321@gmail.com>
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
7
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
8 #testing "name" "command" "result" "infile" "stdin"
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
9
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
10 testing "grep -c" "grep -c 123 input" "3\n" "123\ncount 123\n123\nfasdfasdf" ""
980
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
11
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
12 echo -e "this is test" > foo
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
13 echo -e "this is test2" > foo2
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
14 echo -e "this is foo3" > foo3
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
15 testing "grep -l" "grep -l test foo foo2 foo3" "foo\nfoo2\n" "" ""
980
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
16 rm foo foo2 foo3
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
17
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
18 testing "grep -q" "grep -q test input && echo yes" "yes\n" "this is a test\n" ""
1002
4226645d3388 More grep tests, remove obsolete comment.
Rob Landley <rob@landley.net>
parents: 996
diff changeset
19 testing "grep -E" "grep -E '[0-9]' input" "1234123asdfas123123\n1\n" \
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
20 "1234123asdfas123123\nabc\n1\nabcde" ""
1002
4226645d3388 More grep tests, remove obsolete comment.
Rob Landley <rob@landley.net>
parents: 996
diff changeset
21 testing "grep -e" "grep -e '[0-9]' input" "1234123asdfas123123\n1\n" \
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
22 "1234123asdfas123123\nabc\n1\nabcde" ""
1002
4226645d3388 More grep tests, remove obsolete comment.
Rob Landley <rob@landley.net>
parents: 996
diff changeset
23 testing "grep -e -e" "grep -e one -e two -e three input" \
4226645d3388 More grep tests, remove obsolete comment.
Rob Landley <rob@landley.net>
parents: 996
diff changeset
24 "two\ntwo\nthree\none\n" "two\ntwo\nthree\nand\none\n" ""
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
25 testing "grep -F" "grep -F is input" "this is test\nthis is test2\n" \
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
26 "this is test\nthis is test2\ntest case" ""
980
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
27
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
28 echo -e "this is test\nthis is test2\ntest case" > foo
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
29 echo -e "hello this is test" > foo2
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
30 echo -e "hi hello" > foo3
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
31 testing "grep -H" "grep -H is foo foo2 foo3" "foo:this is test\nfoo:this is test2\nfoo2:hello this is test\n" "" ""
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
32 rm foo foo2 foo3
980
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
33
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
34 testing "grep -b" "grep -b is input" "0:this is test\n13:this is test2\n" \
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
35 "this is test\nthis is test2\ntest case" ""
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
36 testing "grep -i" "grep -i is input" "thisIs test\nthis is test2\n" \
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
37 "thisIs test\nthis is test2\ntest case" ""
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
38 testing "grep -n" "grep -n is input" "1:this is test\n2:this is test2\n" \
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
39 "this is test\nthis is test2\ntest case" ""
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
40 testing "grep -o" "grep -o is input" "is\nis\nis\nis\n" \
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
41 "this is test\nthis is test2\ntest case" ""
988
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
42 testing "grep -s" "grep -hs hello asdf input 2>&1" "hello\n" "hello\n" ""
981
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
43 testing "grep -v" "grep -v abc input" "1234123asdfas123123\n1ABa\n" \
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
44 "1234123asdfas123123\n1ABabc\nabc\n1ABa\nabcde" ""
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
45 testing "grep -w" "grep -w abc input" "abc\n" \
a1a04ea38db2 Clean up grep.test to use "infile" properly, and not try to work around the $PATH behavior of scripts/test.sh. Tested with both TEST_HOST=1 and normal.
Rob Landley <rob@landley.net>
parents: 980
diff changeset
46 "1234123asdfas123123\n1ABabc\nabc\n1ABa\nabcde" ""
988
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
47 testing "grep -x" "grep -x abc input" "abc\n" \
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
48 "aabcc\nabc\n" ""
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
49
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
50 testing "grep -H (standard input)" "grep -H abc" "(standard input):abc\n" \
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
51 "" "abc\n"
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
52 testing "grep -l (standard input)" "grep -l abc" "(standard input)\n" \
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
53 "" "abc\n"
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
54 testing "grep -n two inputs" "grep -hn def - input" "2:def\n2:def\n" \
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
55 "abc\ndef\n" "abc\ndef\n"
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
56
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
57 testing "grep pattern with newline" "grep 'abc
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
58 def' input" "aabcc\nddeff\n" \
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
59 "aaaa\naabcc\n\dddd\nddeff\nffff\n" ""
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
60
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
61 testing "grep -lH" "grep -lH abc input" "input\n" "abc\n" ""
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
62 testing "grep -cn" "grep -cn abc input" "1\n" "abc\n" ""
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
63 testing "grep -qs" "grep -qs abc none input && echo yes" "yes\n" "abc\n" ""
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
64 testing "grep -hl" "grep -hl abc input" "input\n" "abc\n" ""
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
65 testing "grep -b stdin" "grep -b one" "0:one\n4:one\n8:one\n" "" "one\none\none\n"
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
66 testing "grep -o overlap" "grep -bo aaa" "1:aaa\n" "" "baaaa\n"
1002
4226645d3388 More grep tests, remove obsolete comment.
Rob Landley <rob@landley.net>
parents: 996
diff changeset
67 # nonobvious: -co counts lines, not matches
4226645d3388 More grep tests, remove obsolete comment.
Rob Landley <rob@landley.net>
parents: 996
diff changeset
68 testing "grep -co" "grep -co one input" "1\n" "one one one\n" ""
988
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
69 testing "grep -nom" "grep -nom 2 one" "1:one\n1:one\n1:one\n2:one\n2:one\n" \
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
70 "" "one one one\none one\none"
1017
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
71 testing "grep -vo" "grep -vo one input" "two\nthree\n" "onetwoonethreeone\n" ""
988
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
72 testing "grep no newline" "grep -h one input -" \
77cba4e36d48 Fluff out grep test suite some more, including lots of things we don't pass yet.
Rob Landley <rob@landley.net>
parents: 981
diff changeset
73 "hello one\nthere one\n" "hello one" "there one"
996
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
74
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
75 testing "grep -e multi" "grep -e one -ethree input" \
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
76 "three\none\n" "three\ntwo\none\n" ""
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
77 # Suppress filenames for recursive test because dunno order they'd occur in
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
78 mkdir sub
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
79 echo -e "one\ntwo\nthree" > sub/one
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
80 echo -e "three\ntwo\none" > sub/two
1017
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
81 testing "grep -hr" "grep -hr one sub" "one\none\n" "" ""
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
82 testing "grep -r file" "grep -r three sub/two" "three\n" "" ""
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
83 testing "grep -r dir" "grep -r one sub | sort" "sub/one:one\nsub/two:one\n" \
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
84 "" ""
996
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
85 rm -rf sub
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
86
1017
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
87 # Not sure if -Fx '' should do? Posix is unclear, '' match every line but does
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
88 # it match every _byte_ in that line?
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
89 testing "grep -Fx ''" "grep -Fx '' input" "one one one\n" "one one one\n" ""
996
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
90 testing "grep -F ''" "grep -F '' input" "one one one\n" "one one one\n" ""
1017
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
91 testing "grep -F -e blah -e ''" "grep -F -e blah -e '' input" "one one one\n" \
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
92 "one one one\n" ""
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
93 testing "grep -e blah -e ''" "grep -e blah -e '' input" "one one one\n" \
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
94 "one one one\n" ""
996
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
95 testing "grep -w ''" "grep -w '' input" "" "one one one\n" ""
bd8be96cd43d More grep tests.
Rob Landley <rob@landley.net>
parents: 988
diff changeset
96 testing "grep -o ''" "grep -o '' input" "" "one one one\n" ""
1017
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
97 testing "grep backref" 'grep -e "a\(b\)" -e "b\(c\)\1"' "bcc\nab\n" \
059e1f30b80b Finish grep rewrite and fleshing out test suite. Several of the grep tests fail with the ubuntu version, I _think_ these are upstream bugs? (Second opinions welcome...)
Rob Landley <rob@landley.net>
parents: 1002
diff changeset
98 "" "bcc\nbcb\nab\n"