summaryrefslogtreecommitdiffstats
path: root/src/grep/tests/empty
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:21:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:21:29 +0000
commit29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc (patch)
tree63ef546b10a81d461e5cf5ed9e98a68cd7dee1aa /src/grep/tests/empty
parentInitial commit. (diff)
downloadkbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.tar.xz
kbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.zip
Adding upstream version 1:0.1.9998svn3589+dfsg.upstream/1%0.1.9998svn3589+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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