summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rwxr-xr-xbuild/httpdunit_gen_cases.pl23
-rwxr-xr-xbuild/httpdunit_gen_stubs.pl22
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"
+ }
+}