summaryrefslogtreecommitdiffstats
path: root/src/grep/tests/pcre-z
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/pcre-z
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/pcre-z')
-rwxr-xr-xsrc/grep/tests/pcre-z28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/grep/tests/pcre-z b/src/grep/tests/pcre-z
new file mode 100755
index 0000000..4ce9a93
--- /dev/null
+++ b/src/grep/tests/pcre-z
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Test Perl regex with NUL-separated input
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+require_pcre_
+require_en_utf8_locale_
+
+REGEX=a
+
+printf '%s\n\0' abc def ghi aaa gah > in || framework_failure_
+
+grep -z "$REGEX" in > exp 2>err || fail_ 'Cannot do BRE (grep -z) match.'
+compare /dev/null err || fail_ 'stderr not empty on grep -z.'
+
+# Sanity check the output
+test "$(grep -cz $REGEX in 2>err)" = 3 \
+ || fail_ 'Incorrect BRE (grep -cz) match.'
+compare /dev/null err || fail_ 'stderr not empty on grep -cz.'
+
+fail=0
+grep -Pz "$REGEX" in > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+printf '\303\200\0' >in0 # "À" followed by a NUL.
+LC_ALL=en_US.UTF-8 grep -z . in0 >out || fail=1
+cmp in0 out || fail=1
+
+Exit $fail