summaryrefslogtreecommitdiff
path: root/tests/empty
blob: c653fb5ca72d880105c9f17ed788be8b2c837fd2 (plain)
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
#! /bin/sh
# test that the empty file means no pattern
# and an empty pattern means match all.
#
# Copyright (C) 2001, 2006, 2009-2011 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=.}/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

    for options in '-E -w' '-E -x' '-E -w -x' '-F -w' '-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