# HG changeset patch # User David A. Holland # Date 1364707065 14400 # Node ID a52f0229f22b2870ada72e7e9a0a943e5f5d5cda # Parent 0cd5a1d55ed665d8dbe91743e35c1a9da8f85b75# Parent 8a204d1533980e8c4aae983a87fb5eb5cc73d513 Merge. diff -r 8a204d153398 -r a52f0229f22b tests/Makefile --- a/tests/Makefile Sun Mar 31 01:04:43 2013 -0400 +++ b/tests/Makefile Sun Mar 31 01:17:45 2013 -0400 @@ -1,6 +1,9 @@ -TRADCPP=../obj/tradcpp # XXX +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 +TESTS=\ + t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 \ + t17 t18 t19 all: run-tests .WAIT show-diffs @@ -31,3 +34,11 @@ .endfor .PHONY: all run-tests show-diffs clean good + +############################################################ + +.if defined(ALLOW_BROKEN_ATF_POLLUTION) +TESTDIR= ${TESTSBASE}/usr.bin/tradcpp +TESTS_SH+= tradcpp +.include +.endif diff -r 8a204d153398 -r a52f0229f22b tests/subdir/test.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/subdir/test.h Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,1 @@ +hello diff -r 8a204d153398 -r a52f0229f22b tests/t16.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t16.c Sun Mar 31 01:17:45 2013 -0400 @@ -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 diff -r 8a204d153398 -r a52f0229f22b tests/t16.good --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t16.good Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,11 @@ +x +x +x1x +x1x +xx +x12x +t16.c:10:1: Wrong number of arguments for macro c; found 1, expected 2 +x1x +t16.c:11:1: Wrong number of arguments for macro c; found 0, expected 2 +xx +FAILED diff -r 8a204d153398 -r a52f0229f22b tests/t17.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t17.c Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,2 @@ +#define file "subdir/test.h" +#include file diff -r 8a204d153398 -r a52f0229f22b tests/t17.good --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t17.good Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,1 @@ +hello diff -r 8a204d153398 -r a52f0229f22b tests/t18.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t18.c Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,2 @@ +#if FOO /* ignore me */ +#endif diff -r 8a204d153398 -r a52f0229f22b tests/t18.good diff -r 8a204d153398 -r a52f0229f22b tests/t19.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t19.c Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,3 @@ +#define foo /* comment continues + into the next line */ baz +baz diff -r 8a204d153398 -r a52f0229f22b tests/t19.good --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t19.good Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,1 @@ +baz diff -r 8a204d153398 -r a52f0229f22b tests/tradcpp.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/tradcpp.sh Sun Mar 31 01:17:45 2013 -0400 @@ -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 +}