diff options
author | Jacob Champion <jchampion@apache.org> | 2017-05-25 23:18:32 +0200 |
---|---|---|
committer | Jacob Champion <jchampion@apache.org> | 2017-05-25 23:18:32 +0200 |
commit | d3289c73ee5f053dc99ccb8546624017e83cca8b (patch) | |
tree | b6bd7bc9e87d1f33c41294a8dbdeb255ad52f569 /build | |
parent | configure: don't overwrite other_targets when mod_suexec is enabled (diff) | |
download | apache2-d3289c73ee5f053dc99ccb8546624017e83cca8b.tar.xz apache2-d3289c73ee5f053dc99ccb8546624017e83cca8b.zip |
httpdunit: a Check-based unit test suite
Add a unit test suite based on Check:
https://libcheck.github.io/check/
The suite depends on the build system to automatically generate the code
stubs that call every test case.
httpdunit is automatically enabled in the build if configure is able to
find Check via pkg-config. At the moment pkg-config is the only official
(non-deprecated) way to build and link against Check with an autoconf
system, since platforms may distribute Check as a static library.
Note that Check is an LGPL'd library, so we can't distribute test
objects and binaries. Building and running the suite remains optional
and is not required to run the server.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpdunit@1796202 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'build')
-rwxr-xr-x | build/httpdunit_gen_cases.pl | 23 | ||||
-rwxr-xr-x | build/httpdunit_gen_stubs.pl | 22 |
2 files changed, 45 insertions, 0 deletions
diff --git a/build/httpdunit_gen_cases.pl b/build/httpdunit_gen_cases.pl new file mode 100755 index 0000000000..a40d12c773 --- /dev/null +++ b/build/httpdunit_gen_cases.pl @@ -0,0 +1,23 @@ +#! /usr/bin/env perl + +# +# Generates a list of test cases to be pulled into the httpdunit main test +# suite. +# +# Supply all the test cases' source file contents on stdin; the resulting code +# will be printed to stdout. Normally you will want to call this twice: once +# with --declaration to print the function declarations of all the test cases, +# and once without any options to produce the code that actually adds each test +# case to the main suite. +# + +use strict; +use warnings; + +while (my $line = <>) { + if ($line =~ /^HTTPD_BEGIN_TEST_CASE(?:\w+)?\((\w+)/) { + my $name = "$1_test_case"; + print "TCase *$name(void); "; + print "suite_add_tcase(suite, $name());\n"; + } +} diff --git a/build/httpdunit_gen_stubs.pl b/build/httpdunit_gen_stubs.pl new file mode 100755 index 0000000000..abb640c6bf --- /dev/null +++ b/build/httpdunit_gen_stubs.pl @@ -0,0 +1,22 @@ +#! /usr/bin/env perl + +# +# Generates a code stub that adds unit tests to a Check test case. +# +# Supply the test case's source file contents on stdin; the resulting code will +# be printed to stdout. This code is designed to be included as part of the +# boilerplate at the end of each test case. +# + +use strict; +use warnings; + +while (my $line = <>) { + # FIXME: this does not correctly handle macro invocations that are split + # over multiple lines. + if ($line =~ /^HTTPD_START_LOOP_TEST\((\w+),(.*)\)/) { + print "tcase_add_loop_test(testcase, $1, 0, ($2));\n"; + } elsif ($line =~ /^START_TEST\((\w+)\)/) { + print "tcase_add_test(testcase, $1);\n" + } +} |