VirtualBox

source: kBuild/vendor/grep/2.12/tests/status@ 2595

Last change on this file since 2595 was 2595, checked in by bird, 12 years ago

gnu grep version 2.12 (grep-2.12.tar.xz, md5sum=8d2f0346d08b13c18afb81f0e8aa1e2f)

File size: 2.1 KB
Line 
1#! /bin/sh
2# Test for status code for GNU grep.
3# status code
4# 0 match found
5# 1 no match
6# 2 file not found
7#
8# Copyright (C) 2001, 2006, 2009-2012 Free Software Foundation, Inc.
9#
10# Copying and distribution of this file, with or without modification,
11# are permitted in any medium without royalty provided the copyright
12# notice and this notice are preserved.
13
14. "${srcdir=.}/init.sh"; path_prepend_ ../src
15
16fail=0
17
18# should return 0 found a match
19echo "abcd" | grep -E -e 'abc' > /dev/null 2>&1
20if test $? -ne 0 ; then
21 echo "Status: Wrong status code, test \#1 failed"
22 fail=1
23fi
24
25# should return 1 found no match
26echo "abcd" | grep -E -e 'zbc' > /dev/null 2>&1
27if test $? -ne 1 ; then
28 echo "Status: Wrong status code, test \#2 failed"
29 fail=1
30fi
31
32# the filename MMMMMMMM.MMM should not exist hopefully
33if test -r MMMMMMMM.MMM; then
34 echo "Please remove MMMMMMMM.MMM to run check"
35else
36 # should return 2 file not found
37 grep -E -e 'abc' MMMMMMMM.MMM > /dev/null 2>&1
38 if test $? -ne 2 ; then
39 echo "Status: Wrong status code, test \#3 failed"
40 fail=1
41 fi
42
43 # should return 2 file not found
44 grep -E -s -e 'abc' MMMMMMMM.MMM > /dev/null 2>&1
45 if test $? -ne 2 ; then
46 echo "Status: Wrong status code, test \#4 failed"
47 fail=1
48 fi
49
50 # should return 2 file not found
51 echo "abcd" | grep -E -s 'abc' - MMMMMMMM.MMM > /dev/null 2>&1
52 if test $? -ne 2 ; then
53 echo "Status: Wrong status code, test \#5 failed"
54 fail=1
55 fi
56
57 # should return 0 found a match
58 echo "abcd" | grep -E -q -s 'abc' MMMMMMMM.MMM - > /dev/null 2>&1
59 if test $? -ne 0 ; then
60 echo "Status: Wrong status code, test \#6 failed"
61 fail=1
62 fi
63
64 # should still return 0 found a match
65 echo "abcd" | grep -E -q 'abc' MMMMMMMM.MMM - > /dev/null 2>&1
66 if test $? -ne 0 ; then
67 echo "Status: Wrong status code, test \#7 failed"
68 fail=1
69 fi
70fi
71
72Exit $fail
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette