annotate scripts/test/grep.test @ 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.
author Rob Landley <rob@landley.net>
date Thu, 01 Aug 2013 15:22:52 -0500
parents ba241693c282
children 77cba4e36d48
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 # This one's tricky both because echo is a shell builtin (so $PATH is
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
9 # irrelevant) and because the "result" field is parsed with echo -e.
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
10 # To make it work, "$CMD" is an explicit path to the command being tested,
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
11 # so "result" keeps using the shell builtin but we test the one in toybox.
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
12
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
13 #testing "name" "command" "result" "infile" "stdin"
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
14
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 -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
16
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
17 echo -e "this is test" > foo
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
18 echo -e "this is test2" > foo2
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
19 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
20 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
21 rm foo foo2 foo3
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
22
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
23 testing "grep -q" "grep -q test input && echo yes" "yes\n" "this is a 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
24 testing "grep -E" "grep -E [0-9] input" "1234123asdfas123123\n1\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
25 "1234123asdfas123123\nabc\n1\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
26 testing "grep -e" "grep -e [0-9] input" "1234123asdfas123123\n1\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
27 "1234123asdfas123123\nabc\n1\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
28 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
29 "this is test\nthis is test2\ntest case" ""
980
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
30
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
31 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
32 echo -e "hello this is test" > foo2
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
33 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
34 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
35 rm foo foo2 foo3
980
ba241693c282 I add testsuite for grep.
Ashwini Sharma <ak.ashwini@gmail.com>
parents:
diff changeset
36
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
37 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
38 "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
39 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
40 "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
41 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
42 "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
43 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
44 "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
45 testing "grep -s" "grep -s hello asdf 2>&1" "" "" ""
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 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
47 "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
48 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
49 "1234123asdfas123123\n1ABabc\nabc\n1ABa\nabcde" ""