From 305f7674b741a8c7ffcc9d78e351ee1b59fc2362 Mon Sep 17 00:00:00 2001 From: thurston Date: Sat, 7 Apr 2007 03:50:01 +0000 Subject: [PATCH] Some cleanup and fixes to the runtests script. The -P option will be changing. Its use from runtests is currently disabled. git-svn-id: http://svn.complang.org/ragel/trunk@175 052ea7fc-9027-0410-9066-f65837a77df0 --- test/Makefile.in | 2 +- test/cppscan1.rl | 3 +- test/eofact.rl | 3 +- test/mailbox1.rl | 3 +- test/rlscan.rl | 3 +- test/runtests | 160 +++++++++++++++++++++++++++---------------------------- test/strings2.rl | 4 +- 7 files changed, 90 insertions(+), 88 deletions(-) diff --git a/test/Makefile.in b/test/Makefile.in index 4dafdc0..eeedf1f 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -24,7 +24,7 @@ test: clean: rm -f *.c *.cpp *.m *.d *.java *.bin *.class *.exp \ - *.out *_c.rl *_d.rl *_java.rl + *.out *_c.rl *_d.rl *_java.rl *_ruby.rl distclean: clean rm -f Makefile diff --git a/test/cppscan1.rl b/test/cppscan1.rl index 623af28..9c92a1c 100644 --- a/test/cppscan1.rl +++ b/test/cppscan1.rl @@ -1,6 +1,7 @@ /* * @LANG: c++ - * @ALLOW_GENFLAGS: -T0 -T1 -F0 -F1 -G0 -G1 -G2 -P + * + * Test works with split code gen. */ #include "cppscan1.h" diff --git a/test/eofact.rl b/test/eofact.rl index 890b73c..eeb91b8 100644 --- a/test/eofact.rl +++ b/test/eofact.rl @@ -1,6 +1,7 @@ /* * @LANG: indep - * @ALLOW_GENFLAGS: -T0 -T1 -F0 -F1 -G0 -G1 -G2 -P + * + * Test works with split code gen. */ %% %%{ diff --git a/test/mailbox1.rl b/test/mailbox1.rl index 89e8775..a2bbea9 100644 --- a/test/mailbox1.rl +++ b/test/mailbox1.rl @@ -1,7 +1,8 @@ /* * @LANG: c++ * @CFLAGS: -I../aapl - * @ALLOW_GENFLAGS: -T0 -T1 -F0 -F1 -G0 -G1 -G2 -P + * + * Test works with split code gen. */ /* diff --git a/test/rlscan.rl b/test/rlscan.rl index 943c4f5..24861b6 100644 --- a/test/rlscan.rl +++ b/test/rlscan.rl @@ -2,7 +2,8 @@ * Lexes Ragel input files. * * @LANG: c++ - * @ALLOW_GENFLAGS: -T0 -T1 -F0 -F1 -G0 -G1 -G2 -P + * + * Test works with split code gen. */ #include diff --git a/test/runtests b/test/runtests index 1f21ad4..b647dcd 100755 --- a/test/runtests +++ b/test/runtests @@ -67,6 +67,67 @@ function test_error exit 1; } +# split_objs="" +# if test $split_iters != "$gen_opt"; then +# n=0; +# while test $n -lt $split_iters; do +# part_root=${root}_`awk 'BEGIN { +# width = 0; +# high = '$split_iters' - 1; +# while ( high > 0 ) { +# width = width + 1; +# high = int(high / 10); +# } +# suffFormat = "%" width "." width "d\n"; +# printf( suffFormat, '$n' ); +# exit 0; +# }'` +# part_src=${part_root}.c +# part_bin=${part_root}.o +# echo "$compiler -c $cflags -o $part_bin $part_src" +# if ! $compiler -c $cflags -o $part_bin $part_src; then +# test_error; +# fi +# split_objs="$split_objs $part_bin" +# n=$((n+1)) +# done +# fi + +function run_test() +{ + echo "$ragel $min_opt $lang_opt $test_case | $codegen $gen_opt -o $code_src" + if ! $ragel $min_opt $lang_opt $test_case | $codegen $gen_opt -o $code_src; then + test_error; + fi + + out_args="" + [ $lang != java ] && out_args="-o ${binary}"; + + # Ruby doesn't need to be compiled. + if [ $lang != ruby ]; then + echo "$compiler ${cflags} ${out_args} ${code_src}" + if ! $compiler ${cflags} ${out_args} ${code_src}; then + test_error; + fi + fi + + if [ "$compile_only" != "true" ]; then + echo -n "running $root ... "; + + exec_cmd=./$binary + [ $lang = java ] && exec_cmd="java $root" + [ $lang = ruby ] && exec_cmd="ruby ${code_src}" + + $exec_cmd 2>&1 > $output; + if diff $expected_out $output > /dev/null; then + echo "passed"; + else + echo "FAILED"; + test_error; + fi; + fi +} + for test_case; do root=${test_case%.rl}; @@ -188,96 +249,31 @@ for test_case; do allow_minflags=`sed '/@ALLOW_MINFLAGS:/s/^.*: *//p;d' $test_case` [ -z "$allow_minflags" ] && allow_minflags="-n -m -l -e" - - # If we are in java or ruby then we are not interested in genflags case $lang in c|c++|objc|d) # Using genflags, get the allowed gen flags from the test case. If the # test case doesn't specify assume that all gen flags are allowed. allow_genflags=`sed '/@ALLOW_GENFLAGS:/s/^.*: *//p;d' $test_case` [ -z "$allow_genflags" ] && allow_genflags="-T0 -T1 -F0 -F1 -G0 -G1 -G2" - ;; - *) - # Not interested in gen flags. - allow_genflags=noflags - genflags=noflags - ;; - esac - for min_opt in $minflags; do - for gen_opt in $genflags; do + for min_opt in $minflags; do echo "$allow_minflags" | grep -e $min_opt >/dev/null || continue - grep_gen_opt=${gen_opt} - split_iters=${gen_opt#-P} - if test $split_iters != $gen_opt; then - grep_gen_opt="-P"; - fi - echo "$allow_genflags" | grep -e $grep_gen_opt >/dev/null || continue - - if [ "$genflags" == noflags ]; then - be_gen_opt="" - else - be_gen_opt=$gen_opt - fi - - echo "$ragel $min_opt $lang_opt $test_case | $codegen $be_gen_opt -o $code_src" - if ! $ragel $min_opt $lang_opt $test_case | $codegen $be_gen_opt -o $code_src; then - test_error; - fi - - split_objs="" - if test $split_iters != "$gen_opt"; then - n=0; - while test $n -lt $split_iters; do - part_root=${root}_`awk 'BEGIN { - width = 0; - high = '$split_iters' - 1; - while ( high > 0 ) { - width = width + 1; - high = int(high / 10); - } - suffFormat = "%" width "." width "d\n"; - printf( suffFormat, '$n' ); - exit 0; - }'` - part_src=${part_root}.c - part_bin=${part_root}.o - echo "$compiler -c $cflags -o $part_bin $part_src" - if ! $compiler -c $cflags -o $part_bin $part_src; then - test_error; - fi - split_objs="$split_objs $part_bin" - n=$((n+1)) - done - fi - - out_args="" - [ $lang != java ] && out_args="-o ${binary}"; - - # Ruby doesn't need to be compiled. - if [ $lang != ruby ]; then - echo "$compiler ${cflags} ${out_args} ${code_src}" - if ! $compiler ${cflags} ${out_args} ${code_src}; then - test_error; - fi - fi - - if [ "$compile_only" != "true" ]; then - echo -n "running $root ... "; - - exec_cmd=./$binary - [ $lang = java ] && exec_cmd="java $root" - [ $lang = ruby ] && exec_cmd="ruby ${code_src}" - - $exec_cmd 2>&1 > $output; - if diff $expected_out $output > /dev/null; then - echo "passed"; - else - echo "FAILED"; - test_error; - fi; - fi + for gen_opt in $genflags; do + echo "$allow_genflags" | grep -e $gen_opt >/dev/null || continue + run_test + done done - done + ;; + + java|ruby) + # Not interested in gen opt. + gen_opt="" + for min_opt in $minflags; do + echo "$allow_minflags" | grep -e $min_opt >/dev/null || continue + run_test + done + ;; + esac + done diff --git a/test/strings2.rl b/test/strings2.rl index ad4dd40..6307a2b 100644 --- a/test/strings2.rl +++ b/test/strings2.rl @@ -1,7 +1,9 @@ /* * @LANG: c - * @ALLOW_GENFLAGS: -T0 -T1 -F0 -F1 -P + * @ALLOW_GENFLAGS: -T0 -T1 -F0 -F1 * @ALLOW_MINFLAGS: -n -m -l + * + * Test works with split code gen. */ #include -- 2.7.4