summaryrefslogtreecommitdiff
path: root/build/httpdunit_gen_cases.pl
blob: 8e492a664df49f99153cd0167ad7f394100c2bbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /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;

use Getopt::Long;

my $print_declaration = 0;

GetOptions("declaration" => \$print_declaration)
    or die("unknown option");

while (my $line = <>) {
    if ($line =~ /^HTTPD_BEGIN_TEST_CASE(?:\w+)?\((\w+)/) {
        my $name = "$1_test_case";

        if ($print_declaration) {
            print "TCase *$name(void);\n";
        } else {
            print "suite_add_tcase(suite, $name());\n";
        }
    }
}