changeset 67:737ffe27b4bd

Merge
author Joerg Sonnenberger <joerg@bec.de>
date Sun, 31 Mar 2013 07:19:49 +0200
parents 8a204d153398 (current diff) a3dd0db23b0c (diff)
children 8eee66a25533
files tests/Makefile tests/t13.c tests/t13.good tests/t14.c tests/t14.good tests/t15.c tests/t15.good tests/t17.c tests/t17.good tests/t18.c tests/t18.good tests/t19.c tests/t19.good
diffstat 11 files changed, 83 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/Makefile	Sun Mar 31 01:04:43 2013 -0400
+++ b/tests/Makefile	Sun Mar 31 07:19:49 2013 +0200
@@ -1,9 +1,19 @@
-TRADCPP=../obj/tradcpp  # XXX
-
-TESTS=t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15
+#	$NetBSD$
 
 all: run-tests .WAIT show-diffs
 
+TESTDIR=	${TESTSBASE}/usr.bin/tradcpp
+
+TESTS_SH+=	tradcpp
+
+.include <bsd.test.mk>
+
+TRADCPP_OBJDIR!=	${MAKE} -C .. -V .OBJDIR
+TRADCPP=	${TRADCPP_OBJDIR}/tradcpp
+
+TESTS=t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 \
+      t17 t18 t19
+
 .for T in $(TESTS)
 run-tests: $(T).diff
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/subdir/test.h	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,1 @@
+hello
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t16.c	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,3 @@
+#define foo /* comment continues
+               into the next line */ baz
+baz
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t16.good	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,1 @@
+baz
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t17.c	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,11 @@
+#define a() x
+a()
+a ()
+#define b(p) p
+x/**/b(1)/**/x
+x/**/b (1)/**/x
+x/**/b()/**/x
+#define c(p,q) p/**/q
+x/**/c(1,2)/**/x
+x/**/c(1)/**/x
+x/**/c()/**/x
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t17.good	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,11 @@
+x
+x
+x1x
+x1x
+xx
+x12x
+t17.c:10:1: Wrong number of arguments for macro c; found 1, expected 2
+x1x
+t17.c:11:1: Wrong number of arguments for macro c; found 0, expected 2
+xx
+FAILED
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t18.c	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,2 @@
+#define file "subdir/test.h"
+#include file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t18.good	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,1 @@
+hello
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t19.c	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,2 @@
+#if FOO /* ignore me */
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t19.good	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,2 @@
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tradcpp.sh	Sun Mar 31 07:19:49 2013 +0200
@@ -0,0 +1,36 @@
+test_case() {
+	local name="$1"
+	local source="$2"
+	local tradcpp="$3"
+	local descr="Test tradcpp behavior"
+	atf_test_case ${name}
+	if [ -e "$(atf_get_srcdir)/${name}.txt" ]; then
+		descr=$(cat "$(atf_get_srcdir)/${name}.txt")
+	fi
+	eval "${name}_head() { \
+		atf_set descr \"${descr}\"; \
+		atf_set require.progs \"/usr/bin/tradcpp\"; \
+	}"
+	local stdout="file:$(atf_get_srcdir)/${name}.good"
+	local options=""
+	local options_file="$(atf_get_srcdir)/${name}.cmdline"
+	if [ -e ${options_file} ]; then
+		options=$(cat ${options_file})
+	fi
+	eval "${name}_body() { \
+		atf_check -s eq:0 -o ${stdout} -x '${tradcpp} ${options} ${source} 2>&1 || echo FAILED'; \
+	}"
+}
+
+atf_init_test_cases() {
+	local tradcpp=$(make -V .OBJDIR -C $(atf_get_srcdir)/..)/tradcpp
+	if [ ! -x ${tradcpp} ]; then
+		tradcpp=/usr/bin/tradcpp
+	fi
+	cd $(atf_get_srcdir)
+	for testfile in t*.c; do
+		local name=${testfile%%.c}
+		test_case ${name} ${testfile} ${tradcpp}
+		atf_add_test_case ${name}
+	done
+}