summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/Makefile4
-rw-r--r--regress/usr.bin/xargs/Makefile9
-rw-r--r--regress/usr.bin/xargs/showargs.c19
-rwxr-xr-xregress/usr.bin/xargs/xargs-L.sh97
4 files changed, 127 insertions, 2 deletions
diff --git a/regress/usr.bin/Makefile b/regress/usr.bin/Makefile
index 3e4374d107a..67983733e09 100644
--- a/regress/usr.bin/Makefile
+++ b/regress/usr.bin/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.20 2008/10/10 14:34:06 millert Exp $
+# $OpenBSD: Makefile,v 1.21 2010/03/25 01:43:47 schwarze Exp $
# $NetBSD: Makefile,v 1.1 1997/12/30 23:27:11 cgd Exp $
SUBDIR+= basename bc cap_mkdb dc diff diff3 dirname grep gzip gzsig
-SUBDIR+= m4 make patch rcs sdiff sed sort ssh tsort
+SUBDIR+= m4 make patch rcs sdiff sed sort ssh tsort xargs
.include <bsd.subdir.mk>
diff --git a/regress/usr.bin/xargs/Makefile b/regress/usr.bin/xargs/Makefile
new file mode 100644
index 00000000000..667b3557e94
--- /dev/null
+++ b/regress/usr.bin/xargs/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2010/03/25 01:43:47 schwarze Exp $
+
+regress: showargs
+ @sh ${.CURDIR}/xargs-L.sh
+
+clean:
+ rm -f showargs
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/xargs/showargs.c b/regress/usr.bin/xargs/showargs.c
new file mode 100644
index 00000000000..d30f7030f35
--- /dev/null
+++ b/regress/usr.bin/xargs/showargs.c
@@ -0,0 +1,19 @@
+/* $OpenBSD: showargs.c,v 1.1 2010/03/25 01:43:47 schwarze Exp $ */
+
+/*
+ * written by Ingo Schwarze <schwarze@openbsd.org> 2010
+ * and placed in the public domain
+ */
+
+#include <stdio.h>
+
+int
+main(int argc, char *argv[]) {
+ int i;
+
+ for (i = 1; i < argc; i++)
+ printf("%s|", argv[i]);
+ putchar('\n');
+
+ return 0;
+}
diff --git a/regress/usr.bin/xargs/xargs-L.sh b/regress/usr.bin/xargs/xargs-L.sh
new file mode 100755
index 00000000000..b95aadd505c
--- /dev/null
+++ b/regress/usr.bin/xargs/xargs-L.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+#
+# $OpenBSD: xargs-L.sh,v 1.1 2010/03/25 01:43:47 schwarze Exp $
+#
+# written by Ingo Schwarze <schwarze@openbsd.org> 2010
+# and placed in the public domain
+
+test_xargs()
+{
+ printf 'Testing %13.13s with options "%s"\n' "\"$1\"" "$2"
+ expect=`printf "$3"`
+ result=`printf "$1" | xargs $2 ./showargs`
+ if [ "$result" != "$expect" ]; then
+ printf 'Expected "%s", but got "%s"\n' "$expect" "$result"
+ exit 1
+ fi
+}
+
+test_xargs 'a b' '' 'a|b|'
+test_xargs 'a b' '' 'a|b|'
+test_xargs 'a\nb' '' 'a|b|'
+test_xargs 'a\n\nb' '' 'a|b|'
+test_xargs 'a \nb' '' 'a|b|'
+test_xargs 'a\n b' '' 'a|b|'
+test_xargs 'a \n b' '' 'a|b|'
+test_xargs 'a\n \nb' '' 'a|b|'
+test_xargs 'a \n\nb' '' 'a|b|'
+
+test_xargs 'a\\ b' '' 'a b|'
+test_xargs 'a\\ \nb' '' 'a |b|'
+test_xargs 'a\n\\ b' '' 'a| b|'
+
+test_xargs 'a\\\nb' '' 'a\nb|'
+test_xargs 'a\n\\\nb' '' 'a|\nb|'
+test_xargs 'a \\\nb' '' 'a|\nb|'
+test_xargs 'a\\\n b' '' 'a\n|b|'
+test_xargs 'a \\\n b' '' 'a|\n|b|'
+
+test_xargs 'a b' '-L 1' 'a|b|'
+test_xargs 'a b' '-L 1' 'a|b|'
+test_xargs 'a\nb' '-L 1' 'a|\nb|'
+test_xargs 'a\n\nb' '-L 1' 'a|\nb|'
+test_xargs 'a \nb' '-L 1' 'a|b|'
+test_xargs 'a\n b' '-L 1' 'a|\nb|'
+test_xargs 'a \n b' '-L 1' 'a|b|'
+test_xargs 'a\n \nb' '-L 1' 'a|\nb|'
+test_xargs 'a \n\nb' '-L 1' 'a|b|'
+
+test_xargs 'a\\ b' '-L 1' 'a b|'
+test_xargs 'a\\ \nb' '-L 1' 'a |\nb|'
+test_xargs 'a\n\\ b' '-L 1' 'a|\n b|'
+
+test_xargs 'a\\\nb' '-L 1' 'a\nb|'
+test_xargs 'a\n\\\nb' '-L 1' 'a|\n\nb|'
+test_xargs 'a \\\nb' '-L 1' 'a|\nb|'
+test_xargs 'a\\\n b' '-L 1' 'a\n|b|'
+test_xargs 'a \\\n b' '-L 1' 'a|\n|b|'
+
+test_xargs 'a b' '-0' 'a b|'
+test_xargs 'a b' '-0' 'a b|'
+test_xargs 'a\nb' '-0' 'a\nb|'
+test_xargs 'a\n\nb' '-0' 'a\n\nb|'
+test_xargs 'a \nb' '-0' 'a \nb|'
+test_xargs 'a\n b' '-0' 'a\n b|'
+test_xargs 'a \n b' '-0' 'a \n b|'
+test_xargs 'a\n \nb' '-0' 'a\n \nb|'
+test_xargs 'a \n\nb' '-0' 'a \n\nb|'
+
+test_xargs 'a\\ b' '-0' 'a\\ b|'
+test_xargs 'a\\ \nb' '-0' 'a\\ \nb|'
+test_xargs 'a\n\\ b' '-0' 'a\n\\ b|'
+
+test_xargs 'a\\\nb' '-0' 'a\\\nb|'
+test_xargs 'a\n\\\nb' '-0' 'a\n\\\nb|'
+test_xargs 'a \\\nb' '-0' 'a \\\nb|'
+test_xargs 'a\\\n b' '-0' 'a\\\n b|'
+test_xargs 'a \\\n b' '-0' 'a \\\n b|'
+
+test_xargs 'a b\0c' '-0 -L 1' 'a b|c|'
+test_xargs 'a b\0c' '-0 -L 1' 'a b|c|'
+test_xargs 'a\nb\0c' '-0 -L 1' 'a\nb|\nc|'
+test_xargs 'a\n\nb\0c' '-0 -L 1' 'a\n\nb|\nc|'
+test_xargs 'a \nb\0c' '-0 -L 1' 'a \nb|c|'
+test_xargs 'a\n b\0c' '-0 -L 1' 'a\n b|\nc|'
+test_xargs 'a \n b\0c' '-0 -L 1' 'a \n b|c|'
+test_xargs 'a\n \nb\0c' '-0 -L 1' 'a\n \nb|\nc|'
+test_xargs 'a \n\nb\0c' '-0 -L 1' 'a \n\nb|c|'
+
+test_xargs 'a\\ b\0c' '-0 -L 1' 'a\\ b|c|'
+test_xargs 'a\\ \nb\0c' '-0 -L 1' 'a\\ \nb|c|'
+test_xargs 'a\n\\ b\0c' '-0 -L 1' 'a\n\\ b|\nc|'
+
+test_xargs 'a\\\nb\0c' '-0 -L 1' 'a\\\nb|\nc|'
+test_xargs 'a\n\\\nb\0c' '-0 -L 1' 'a\n\\\nb|\nc|'
+test_xargs 'a \\\nb\0c' '-0 -L 1' 'a \\\nb|\nc|'
+test_xargs 'a\\\n b\0c' '-0 -L 1' 'a\\\n b|\nc|'
+test_xargs 'a \\\n b\0c' '-0 -L 1' 'a \\\n b|\nc|'