7 |
VERBOSE= # empty or "1" |
VERBOSE= # empty or "1" |
8 |
failures=0 |
failures=0 |
9 |
|
|
10 |
# grep_test INPUT EXPECTED_OUTPUT PATTERN [OPTION...] |
# grep_test INPUT EXPECTED_OUTPUT PATTERN_AND_OPTIONS... |
11 |
# Run "grep" with the given INPUT, PATTERN and OPTIONs, and check that |
# Run "grep" with the given INPUT, pattern and options, and check that |
12 |
# the output is EXPECTED_OUTPUT. If not, print a message and set 'failures'. |
# the output is EXPECTED_OUTPUT. If not, print a message and set 'failures'. |
13 |
# "/" represents a newline within INPUT and EXPECTED_OUTPUT. |
# "/" represents a newline within INPUT and EXPECTED_OUTPUT. |
14 |
grep_test () |
grep_test () |
15 |
{ |
{ |
16 |
INPUT="$1" |
INPUT="$1" |
17 |
EXPECT="$2" |
EXPECT="$2" |
18 |
PATTERN="$3" |
shift 2 |
19 |
shift 3 |
OUTPUT=`echo -n "$INPUT" | tr "/" "\n" | "$GREP" "$@" | tr "\n" "/"` |
|
OUTPUT=`echo -n "$INPUT" | tr "/" "\n" | "$GREP" "$@" "$PATTERN" | tr "\n" "/"` |
|
20 |
if test "$OUTPUT" != "$EXPECT" || test "$VERBOSE" == "1"; then |
if test "$OUTPUT" != "$EXPECT" || test "$VERBOSE" == "1"; then |
21 |
echo "Testing: $GREP $@ \"$PATTERN\"" |
echo "Testing: $GREP $@" |
22 |
echo " input: \"$INPUT\"" |
echo " input: \"$INPUT\"" |
23 |
echo " output: \"$OUTPUT\"" |
echo " output: \"$OUTPUT\"" |
24 |
fi |
fi |
60 |
grep_test "4/444/" "4/444/" "4$" -m1 -A99 |
grep_test "4/444/" "4/444/" "4$" -m1 -A99 |
61 |
|
|
62 |
|
|
63 |
|
# Test for "-F -w" bugs. Thanks to Gordon Lack for these two. |
64 |
|
grep_test "A/CX/B/C/" "A/B/C/" -wF -e A -e B -e C |
65 |
|
grep_test "LIN7C 55327/" "" -wF -e 5327 -e 5532 |
66 |
|
|
67 |
|
|
68 |
exit $failures |
exit $failures |