summaryrefslogtreecommitdiffstats
path: root/src/grep/tests/empty
diff options
context:
space:
mode:
Diffstat (limited to 'src/grep/tests/empty')
-rwxr-xr-xsrc/grep/tests/empty82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/grep/tests/empty b/src/grep/tests/empty
new file mode 100755
index 0000000..92f50bb
--- /dev/null
+++ b/src/grep/tests/empty
@@ -0,0 +1,82 @@
+#! /bin/sh
+# test that the empty file means no pattern
+# and an empty pattern means match all.
+#
+# Copyright (C) 2001, 2006, 2009-2021 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