VirtualBox

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

Last change on this file was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:executable set to *
File size: 2.6 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-2021 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 \
36 | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e abcd
37 if test $? -ne 0 ; then
38 echo "Status: Wrong status code, test \#3 failed ($options $locale)"
39 failures=1
40 fi
41
42 # should return 0 found a match
43 echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
44 if test $? -ne 0 ; then
45 echo "Status: Wrong status code, test \#4 failed ($options $locale)"
46 failures=1
47 fi
48
49 # should return 0 found a match
50 echo abcd | LC_ALL=$locale timeout 10s grep $options -e ''
51 if test $? -ne 0 ; then
52 echo "Status: Wrong status code, test \#5 failed ($options $locale)"
53 failures=1
54 fi
55 done
56
57 for options in '-E -w' '-E -x' '-E -w -x' '-F -w' '-F -x' '-F -w -x'; do
58
59 # should return 0 found a match
60 echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
61 if test $? -ne 0 ; then
62 echo "Status: Wrong status code, test \#6 failed ($options $locale)"
63 failures=1
64 fi
65
66 # should return 1 found no match
67 echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null
68 if test $? -ne 1 ; then
69 echo "Status: Wrong status code, test \#7 failed ($options $locale)"
70 failures=1
71 fi
72
73 # should return 1 found no match
74 echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e ""
75 if test $? -ne 1 ; then
76 echo "Status: Wrong status code, test \#8 failed ($options $locale)"
77 failures=1
78 fi
79 done
80done
81
82Exit $failures
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