VirtualBox

source: kBuild/vendor/grep/2.12/tests/empty

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

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

File size: 2.7 KB
Line 
1#! /bin/sh
2# test that the empty file means no pattern
3# and an empty pattern means match all.
4#
5# Copyright (C) 2001, 2006, 2009-2012 Free Software Foundation, Inc.
6#
7# Copying and distribution of this file, with or without modification,
8# are permitted in any medium without royalty provided the copyright
9# notice and this notice are preserved.
10
11. "${srcdir=.}/init.sh"; path_prepend_ ../src
12
13require_timeout_
14
15failures=0
16
17for locale in C en_US.UTF-8; do
18 for options in '-E' '-F'; do
19
20 # should return 0 found a match
21 echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
22 if test $? -ne 0 ; then
23 echo "Status: Wrong status code, test \#1 failed ($options $locale)"
24 failures=1
25 fi
26
27 # should return 1 found no match
28 echo "abcd" | LC_ALL=$locale timeout 10s grep $options -f /dev/null
29 if test $? -ne 1 ; then
30 echo "Status: Wrong status code, test \#2 failed ($options $locale)"
31 failures=1
32 fi
33
34 # should return 0 found a match
35 echo "abcd" | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e "abcd"
36 if test $? -ne 0 ; then
37 echo "Status: Wrong status code, test \#3 failed ($options $locale)"
38 failures=1
39 fi
40
41 # should return 0 found a match
42 echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
43 if test $? -ne 0 ; then
44 echo "Status: Wrong status code, test \#4 failed ($options $locale)"
45 failures=1
46 fi
47
48 # should return 0 found a match
49 echo "abcd" | LC_ALL=$locale timeout 10s grep $options -e ''
50 if test $? -ne 0 ; then
51 echo "Status: Wrong status code, test \#5 failed ($options $locale)"
52 failures=1
53 fi
54 done
55
56 for options in '-E -w' '-E -x' '-E -w -x' '-F -w' '-F -x' '-F -w -x'; do
57
58 # should return 0 found a match
59 echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
60 if test $? -ne 0 ; then
61 echo "Status: Wrong status code, test \#6 failed ($options $locale)"
62 failures=1
63 fi
64
65 # should return 1 found no match
66 echo "abcd" | LC_ALL=$locale timeout 10s grep $options -f /dev/null
67 if test $? -ne 1 ; then
68 echo "Status: Wrong status code, test \#7 failed ($options $locale)"
69 failures=1
70 fi
71
72 # should return 1 found no match
73 echo "abcd" | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e ""
74 if test $? -ne 1 ; then
75 echo "Status: Wrong status code, test \#8 failed ($options $locale)"
76 failures=1
77 fi
78 done
79done
80
81Exit $failures
Note: See TracBrowser for help on using the repository browser.

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