From: William D. <wdo...@us...> - 2006-08-21 16:09:37
|
Update of /cvsroot/flexml/flexml/testbed In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv2980/testbed Added Files: CompareOut.pl Makefile mixed1.act mixed1.dtd mixed1.in mixed1.stdout.expected Log Message: Initial revision: regression testbed. --- NEW FILE: mixed1.dtd --- <!ELEMENT foo (#PCDATA|bar)*> <!ELEMENT bar (#PCDATA)> <!-- <!ATTLIST bar batt CDATA #REQUIRED> --> --- NEW FILE: mixed1.act --- <!DOCTYPE actions SYSTEM "flexml-act.dtd"> <actions> <top><![CDATA[ #include "stdio.h" ]]></top> <end tag='bar'><![CDATA[ printf("bar pcdata: %s\n", pcdata); ]]></end> <end tag='foo'><![CDATA[ printf("foo pcdata: %s\n", pcdata); ]]></end> <main><![CDATA[ int main(int argc, char **argv) { int retval = yylex(); printf("retval = %d\n", retval); return retval; } ]]></main> </actions> --- NEW FILE: Makefile --- # $Source: /cvsroot/flexml/flexml/testbed/Makefile,v $ # regression testbed Makefile ##################################################### # Fixed definitions -- do not modify for new tests ##################################################### include ../Makefile.defs MAKEUTILS_DIR = . # If UNIT_TESTS is test_foo # and test_foo_out is bar baz # Then the created files (that need to be deleted by 'make clean' # will be # test_foo foo.std{err,out} foo.std{err,out}.diff bar baz bar.diff baz.diff TEST_INTERMEDIATES = \ $(UNIT_TESTS) \ $(UNIT_TESTS:test_%=%.stdout) $(UNIT_TESTS:test_%=%.stdout.diff) \ $(UNIT_TESTS:test_%=.test_%.stdout.expected) \ $(UNIT_TESTS:test_%=%.stderr) $(UNIT_TESTS:test_%=%.stderr.diff) \ $(UNIT_TESTS:test_%=.test_%.stderr.expected) \ $(foreach var,$(UNIT_TESTS:%=%_out),$(foreach o,$($(var)),$o $(o).diff)) # Compares test.out.std[out,err] with expected values COMPARE_OUT = $(MAKEUTILS_DIR)/CompareOut.pl CC = /usr/bin/gcc-3.3 -Wall -ansi CFLAGS = -O2 -g #FLEXDEBUG = -d FLEXML = /proj/flexml/flexml-from-cvs-20060821/flexml -s /proj/flexml/flexml-from-cvs-20060821/skel .PHONY : test .PHONY : clean ##################################################### # test definitions -- add new tests here ##################################################### EXES = mixed1 INTERMEDIATES = $(EXES) $(EXES:%=%.c) $(EXES:%=%.l) UNIT_TESTS = \ test_mixed1 test : $(UNIT_TESTS) # Test mixed1 test_mixed1_cmd = ./mixed1 < mixed1.in test_mixed1_deps = mixed1 mixed1.in ##################################################### # test build rules -- add new build rules here ##################################################### mixed1: mixed1.dtd mixed1.act $(FLEXML) -b 1000 -A -amixed1.act mixed1.dtd $(FLEX) -s -L -t mixed1.l > mixed1.c $(CC) $(CFLAGS) -o $@ mixed1.c ##################################################### # test infrastructure -- do not modify for new tests ##################################################### clean : rm -f $(TEST_INTERMEDIATES) $(INTERMEDIATES) # When we are building test_foo, the variable $(TEST_BASE) is "foo" test_% : TEST_BASE = $(@:test_%=%) ifndef distribute_deps # This will take a target and dependency list, and evaluate each dependency # individually. This only needs to be used on dependency lists that are to # be in an $(eval ...) function. This is a work-around for a bug in GNU Make # 3.80, which fails when $(eval)'ing dependency lists longer than about 160 # characters. # 1. target # 2. dependency list define distribute_deps $(foreach dep,$(2),$(eval $(1) : $(dep))) endef endif define unit_test_deps_t $(1) : .$(1).stdout.expected $(1) : .$(1).stderr.expected $$(call distribute_deps,$(1),$($(1)_deps)) endef $(foreach test,$(UNIT_TESTS),$(eval $(call unit_test_deps_t,$(test)))) # To build .test_foo.std{err,out}.expected -- # If foo.std{err,out}.expected exists, symlink to it # Else, .test_foo.std{err,out}.expected is a new empty file # These rules are invoked from rules in the Extradeps section. # They must be two separate rules (else 'make test' not idempotent # -- see bug #105) .test_%.stderr.expected: @if [ -f $(@:.test_%=%) ]; \ then $(SYMLINK) $(@:.test_%=%) $@; \ else touch $@; \ fi .test_%.stdout.expected: @if [ -f $(@:.test_%=%) ]; \ then $(SYMLINK) $(@:.test_%=%) $@; \ else touch $@; \ fi # Unit test rule. Expects: # UNIT_TESTS = test_foo test_bar (test_ prefix is necessary) # test_foo_cmd = command to run # test_foo_deps = dependencies (i.e. inputs to the test, and the executable) # test_foo_out = files and directories created by running the command # with corresponding .expected files for comparison $(UNIT_TESTS) : @$(test_$(@:test_%=%)_cmd) > $(@:test_%=%).stdout \ 2>$(@:test_%=%).stderr || true @$(PERL) $(COMPARE_OUT) -p '$($(@)_diff_prog)' -- \ $($(@)_diff_opts) $(@:test_%=%) $($(@)_out) | tee $@ --- NEW FILE: mixed1.stdout.expected --- bar pcdata: 456789ab foo pcdata: 012cdefghijklmn retval = 0 --- NEW FILE: mixed1.in --- <!DOCTYPE foo SYSTEM "mixed1.dtd"> <foo>012<bar>456789ab</bar>cdefghijklmn</foo> --- NEW FILE: CompareOut.pl --- #!/usr/bin/env perl # Assume ARGV is ($basename @REST). Print "passed" or "failed" based on the # following comparisons: # Compare $basename.stderr with $basename.stderr.expected # pass if no difference or # $basename.stderr is empty and $basename.stderr.expected doesn't exist; # Compare $basename.stdout with $basename.stdout.expected # pass if no difference or # $basename.stdout is empty and $basename.stdout.expected doesn't exist; # For each file $foo in @REST # Compare $foo with $foo.expected # pass if no difference; # Print "passed" if all tests pass, otherwise print # "failed <file-that-failed>" # NOTES # In order to compare directories, GNU diff must be used. There # should probably be a test to ensure this. # $Id: CompareOut.pl,v 1.1 2006/08/21 16:09:32 wdowling Exp $ # $Source: /cvsroot/flexml/flexml/testbed/CompareOut.pl,v $ # $Log: CompareOut.pl,v $ # Revision 1.1 2006/08/21 16:09:32 wdowling # Initial revision: regression testbed. # # Revision 1.4 2006/07/14 19:28:41 jye # Change the hash-bang at the beginning of the perl script # # Revision 1.3 2003/11/25 21:07:21 wdowling # Do comparison of stderr before stdout. (If both are different from # expected, the stderr file is usually mor informative.) # # Revision 1.2 2003/11/18 17:37:28 jaross # Minor Change to change the string: "failed:" to "failed". Not only is this # more consistent with the passed string, but it was causing # errors in the nightly linksadm cronjob: verifybuilds.sh. # # Revision 1.1 2003/06/16 20:26:16 rlange # Moved BuildDepend.pl from liblocal to makeutils. # Moved CompareOut.pl and hack_swig_output.pl from # liblocal/scripts to makeutils. # # Revision 1.4 2002/06/24 20:45:52 wdowling # Send output sdterr output from diff command (diff or cmp) to /dev/null. # # Revision 1.3 2002/06/18 15:42:23 cliscum # Add ability to specify comparison program on command line with '-p xxx'. # # Revision 1.2 2001/12/07 21:13:42 wdowling # Accommodate use of diff_opts as 1st command line parameter, and pass # into system call of diff if present. Print basename in case of passing test. # # Revision 1.1 2001/12/06 20:45:12 wdowling # Initial check. Support module for 'make test'. See # liblocal/Makefile.{header, trailer} for usage. # use strict; use Getopt::Std; my %args; getopts('p:', \%args); my $diff_prog = $args{'p'} || 'diff'; my $diff_opt = ""; if ($ARGV[0] =~ /^-/) { $diff_opt = shift; } my $basename = shift; my $diff_cmd = "$diff_prog $diff_opt"; my $retcode; my $fail_file; my $made_stdout = 0; my $made_stderr = 0; # Compare basename.stderr to basename.stderr.expected if (! -f "$basename.stderr.expected") { system("touch $basename.stderr.expected"); $made_stderr = 1; } $retcode = system("$diff_cmd $basename.stderr $basename.stderr.expected " . "> $basename.stderr.diff 2>/dev/null"); system("rm -f $basename.stderr.expected") if $made_stderr; $fail_file = "$basename.stderr" if $retcode; # Compare basename.stdout to basename.stdout.expected if ($retcode == 0) { if (! -f "$basename.stdout.expected") { system("touch $basename.stdout.expected"); $made_stdout = 1; } $retcode = system("$diff_cmd $basename.stdout $basename.stdout.expected " . "> $basename.stdout.diff 2>/dev/null"); system("rm -f $basename.stdout.expected") if $made_stdout; $fail_file = "$basename.stdout" if $retcode; } while (($retcode == 0) && @ARGV) { my $file = shift; # compare file with file.expected $retcode = system("$diff_cmd $file $file.expected >$file.diff 2>/dev/null"); $fail_file = $file if $retcode; } print ($retcode ? "failed $fail_file\n" : "passed $basename\n"); |