Blame tests/empty

Packit 709fb3
#! /bin/sh
Packit 709fb3
# test that the empty file means no pattern
Packit 709fb3
# and an empty pattern means match all.
Packit 709fb3
#
Packit 709fb3
# Copyright (C) 2001, 2006, 2009-2017 Free Software Foundation, Inc.
Packit 709fb3
#
Packit 709fb3
# Copying and distribution of this file, with or without modification,
Packit 709fb3
# are permitted in any medium without royalty provided the copyright
Packit 709fb3
# notice and this notice are preserved.
Packit 709fb3
Packit 709fb3
. "${srcdir=.}/init.sh"; path_prepend_ ../src
Packit 709fb3
Packit 709fb3
require_timeout_
Packit 709fb3
Packit 709fb3
failures=0
Packit 709fb3
Packit 709fb3
for locale in C en_US.UTF-8; do
Packit 709fb3
    for options in '-E' '-F'; do
Packit 709fb3
Packit 709fb3
        # should return 0 found a match
Packit 709fb3
        echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
Packit 709fb3
        if test $? -ne 0 ; then
Packit 709fb3
          echo "Status: Wrong status code, test \#1 failed ($options $locale)"
Packit 709fb3
          failures=1
Packit 709fb3
        fi
Packit 709fb3
Packit 709fb3
        # should return 1 found no match
Packit 709fb3
        echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null
Packit 709fb3
        if test $? -ne 1 ; then
Packit 709fb3
          echo "Status: Wrong status code, test \#2 failed ($options $locale)"
Packit 709fb3
          failures=1
Packit 709fb3
        fi
Packit 709fb3
Packit 709fb3
        # should return 0 found a match
Packit 709fb3
        echo abcd \
Packit 709fb3
            | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e abcd
Packit 709fb3
        if test $? -ne 0 ; then
Packit 709fb3
          echo "Status: Wrong status code, test \#3 failed ($options $locale)"
Packit 709fb3
          failures=1
Packit 709fb3
        fi
Packit 709fb3
Packit 709fb3
        # should return 0 found a match
Packit 709fb3
        echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
Packit 709fb3
        if test $? -ne 0 ; then
Packit 709fb3
          echo "Status: Wrong status code, test \#4 failed ($options $locale)"
Packit 709fb3
          failures=1
Packit 709fb3
        fi
Packit 709fb3
Packit 709fb3
        # should return 0 found a match
Packit 709fb3
        echo abcd | LC_ALL=$locale timeout 10s grep $options -e ''
Packit 709fb3
        if test $? -ne 0 ; then
Packit 709fb3
          echo "Status: Wrong status code, test \#5 failed ($options $locale)"
Packit 709fb3
          failures=1
Packit 709fb3
        fi
Packit 709fb3
    done
Packit 709fb3
Packit 709fb3
    for options in '-E -w' '-E -x' '-E -w -x' '-F -w' '-F -x' '-F -w -x'; do
Packit 709fb3
Packit 709fb3
        # should return 0 found a match
Packit 709fb3
        echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
Packit 709fb3
        if test $? -ne 0 ; then
Packit 709fb3
          echo "Status: Wrong status code, test \#6 failed ($options $locale)"
Packit 709fb3
          failures=1
Packit 709fb3
        fi
Packit 709fb3
Packit 709fb3
        # should return 1 found no match
Packit 709fb3
        echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null
Packit 709fb3
        if test $? -ne 1 ; then
Packit 709fb3
          echo "Status: Wrong status code, test \#7 failed ($options $locale)"
Packit 709fb3
          failures=1
Packit 709fb3
        fi
Packit 709fb3
Packit 709fb3
        # should return 1 found no match
Packit 709fb3
        echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e ""
Packit 709fb3
        if test $? -ne 1 ; then
Packit 709fb3
          echo "Status: Wrong status code, test \#8 failed ($options $locale)"
Packit 709fb3
          failures=1
Packit 709fb3
        fi
Packit 709fb3
    done
Packit 709fb3
done
Packit 709fb3
Packit 709fb3
Exit $failures