summaryrefslogtreecommitdiffstats
path: root/tools/regression/usr.bin
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2010-03-05 15:23:01 +0000
committerjh <jh@FreeBSD.org>2010-03-05 15:23:01 +0000
commitba646ecd6fecd8f82a5df041fa3818b1f49cb375 (patch)
tree411318be07df3cec7aa3f6855cc1e38c3aea5ee5 /tools/regression/usr.bin
parent94e741a5e69d24673cb9820a57dd0397eb65f6ce (diff)
downloadFreeBSD-src-ba646ecd6fecd8f82a5df041fa3818b1f49cb375.zip
FreeBSD-src-ba646ecd6fecd8f82a5df041fa3818b1f49cb375.tar.gz
- Use errx(3) instead of err(3) when checking if snprintf(3) succeeded.
snprintf(3) doesn't set errno in the tested cases. - If the same argument reference (for example %1) was specified more than once, the command didn't necessarily fit to the final command buffer. Fix this using a dynamic sbuf buffer. Add a few regression tests for the case. PR: bin/95079 No objections: freebsd-hackers
Diffstat (limited to 'tools/regression/usr.bin')
-rw-r--r--tools/regression/usr.bin/Makefile3
-rw-r--r--tools/regression/usr.bin/apply/Makefile4
-rw-r--r--tools/regression/usr.bin/apply/regress.00.in1
-rw-r--r--tools/regression/usr.bin/apply/regress.00.out1
-rw-r--r--tools/regression/usr.bin/apply/regress.01.out1
-rw-r--r--tools/regression/usr.bin/apply/regress.01.sh15
-rw-r--r--tools/regression/usr.bin/apply/regress.sh10
-rw-r--r--tools/regression/usr.bin/apply/regress.t6
8 files changed, 40 insertions, 1 deletions
diff --git a/tools/regression/usr.bin/Makefile b/tools/regression/usr.bin/Makefile
index 364741b..da4549a 100644
--- a/tools/regression/usr.bin/Makefile
+++ b/tools/regression/usr.bin/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
-SUBDIR= calendar comm file2c join jot m4 printf sed tr uudecode uuencode xargs
+SUBDIR= apply calendar comm file2c join jot m4 printf sed tr \
+ uudecode uuencode xargs
.if !defined(AUTOMATED)
SUBDIR+= lastcomm
.endif
diff --git a/tools/regression/usr.bin/apply/Makefile b/tools/regression/usr.bin/apply/Makefile
new file mode 100644
index 0000000..b937d41
--- /dev/null
+++ b/tools/regression/usr.bin/apply/Makefile
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+ @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff --git a/tools/regression/usr.bin/apply/regress.00.in b/tools/regression/usr.bin/apply/regress.00.in
new file mode 100644
index 0000000..8282be7
--- /dev/null
+++ b/tools/regression/usr.bin/apply/regress.00.in
@@ -0,0 +1 @@
+12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
diff --git a/tools/regression/usr.bin/apply/regress.00.out b/tools/regression/usr.bin/apply/regress.00.out
new file mode 100644
index 0000000..c725cb2
--- /dev/null
+++ b/tools/regression/usr.bin/apply/regress.00.out
@@ -0,0 +1 @@
+12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
diff --git a/tools/regression/usr.bin/apply/regress.01.out b/tools/regression/usr.bin/apply/regress.01.out
new file mode 100644
index 0000000..bcf5ab2
--- /dev/null
+++ b/tools/regression/usr.bin/apply/regress.01.out
@@ -0,0 +1 @@
+apply: Argument list too long
diff --git a/tools/regression/usr.bin/apply/regress.01.sh b/tools/regression/usr.bin/apply/regress.01.sh
new file mode 100644
index 0000000..db5f1d4
--- /dev/null
+++ b/tools/regression/usr.bin/apply/regress.01.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+# $FreeBSD$
+
+SHELL=/bin/sh; export SHELL
+
+ARG_MAX=$(getconf ARG_MAX)
+ARG_MAX_HALF=$((ARG_MAX / 2))
+
+apply 'echo %1 %1 %1' $(jot $ARG_MAX_HALF 1 1 | tr -d '\n') 2>&1
+
+if [ $? -eq 0 ]; then
+ return 1
+else
+ return 0
+fi
diff --git a/tools/regression/usr.bin/apply/regress.sh b/tools/regression/usr.bin/apply/regress.sh
new file mode 100644
index 0000000..7cbaae3
--- /dev/null
+++ b/tools/regression/usr.bin/apply/regress.sh
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+echo 1..2
+
+REGRESSION_START($1)
+
+REGRESSION_TEST(`00', `apply "echo %1 %1 %1 %1" $(cat regress.00.in)')
+REGRESSION_TEST(`01', `sh regress.01.sh')
+
+REGRESSION_END()
diff --git a/tools/regression/usr.bin/apply/regress.t b/tools/regression/usr.bin/apply/regress.t
new file mode 100644
index 0000000..a82aacd
--- /dev/null
+++ b/tools/regression/usr.bin/apply/regress.t
@@ -0,0 +1,6 @@
+#!/bin/sh
+# $FreeBSD$
+
+cd `dirname $0`
+
+m4 ../regress.m4 regress.sh | sh
OpenPOWER on IntegriCloud