File: empty

package info (click to toggle)
grep 2.6.3-3%2Bsqueeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,368 kB
  • ctags: 4,688
  • sloc: ansic: 15,006; sh: 8,554; makefile: 210; awk: 71; sed: 16
file content (84 lines) | stat: -rwxr-xr-x 2,409 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#! /bin/sh
# test that the empty file means no pattern
# and an empty pattern means match all.
#
# Copyright (C) 2001, 2006, 2009-2010 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.

: ${srcdir=.}
. "$srcdir/init.sh"; path_prepend_ ../src

require_timeout_

failures=0

for locale in C en_US.UTF-8; do
    for options in '-E' '-F'; do

	# should return 0 found a match
	echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
	if test $? -ne 0 ; then
		echo "Status: Wrong status code, test \#1 failed ($options $locale)"
		failures=1
	fi

	# should return 1 found no match
	echo "abcd" | LC_ALL=$locale timeout 10s grep $options -f /dev/null
	if test $? -ne 1 ; then
		echo "Status: Wrong status code, test \#2 failed ($options $locale)"
		failures=1
	fi

	# should return 0 found a match
	echo "abcd" | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e "abcd"
	if test $? -ne 0 ; then
		echo "Status: Wrong status code, test \#3 failed ($options $locale)"
		failures=1
	fi

	# should return 0 found a match
	echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
	if test $? -ne 0 ; then
		echo "Status: Wrong status code, test \#4 failed ($options $locale)"
		failures=1
	fi

	# should return 0 found a match
	echo "abcd" | LC_ALL=$locale timeout 10s grep $options -e ''
	if test $? -ne 0 ; then
		echo "Status: Wrong status code, test \#5 failed ($options $locale)"
		failures=1
	fi
    done

    # -F -w omitted because it fails test #6, will be revisited after 2.6
    # stabilizes.
    for options in '-E -w' '-E -x' '-E -w -x' '-F -x' '-F -w -x'; do

	# should return 0 found a match
	echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
	if test $? -ne 0 ; then
		echo "Status: Wrong status code, test \#6 failed ($options $locale)"
		failures=1
	fi

	# should return 1 found no match
	echo "abcd" | LC_ALL=$locale timeout 10s grep $options -f /dev/null
	if test $? -ne 1 ; then
		echo "Status: Wrong status code, test \#7 failed ($options $locale)"
		failures=1
	fi

	# should return 1 found no match
	echo "abcd" | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e ""
	if test $? -ne 1 ; then
		echo "Status: Wrong status code, test \#8 failed ($options $locale)"
		failures=1
	fi
    done
done

Exit $failures