6
# Given a test-arrays file, which specifies the test suite names, the
7
# names of the functions which perform those test suites, and
8
# descriptive comments, this script generates C structures for the
9
# mpi-test program. The input consists of lines of the form:
11
# suite-name:function-name:comment
13
# The output is written to the standard output. Blank lines are
14
# ignored, and comments beginning with '#' are stripped.
16
# This Source Code Form is subject to the terms of the Mozilla Public
17
# License, v. 2.0. If a copy of the MPL was not distributed with this
18
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
20
# $Id: make-test-arrays,v 1.4 2012/04/25 14:49:50 gerv%gerv.net Exp $
23
# Read parameters from the environment, if available
24
$NAMEVAR = $ENV{'NAMEVAR'} || "g_names";
25
$COUNTVAR = $ENV{'COUNTVAR'} || "g_count";
26
$FUNCVAR = $ENV{'FUNCVAR'} || "g_tests";
27
$DESCVAR = $ENV{'DESCVAR'} || "g_descs";
32
#------------------------------------------------------------------------
33
# Suck in input from the files on the command line, or standard input
39
($suite, $func, $desc) = split(/:/, $_);
41
$tmp = { "suite" => $suite,
47
$count = scalar(@item);
50
#------------------------------------------------------------------------
51
# Output the table of names
52
print "/* Table mapping test suite names to index numbers */\n";
53
printf("const int %s = %d;\n", $COUNTVAR, $count);
54
printf("const char *%s[] = {\n", $NAMEVAR);
56
foreach $elt (@item) {
57
printf(" \"%s\",%s/* %s%s */\n", $elt->{"suite"},
58
" " x ($NAMELEN - length($elt->{"suite"})),
60
" " x ($DESCLEN - length($elt->{"desc"})));
62
printf(" \"%s\" %s/* %s%s */\n", $last->{"suite"},
63
" " x ($NAMELEN - length($last->{"suite"})),
65
" " x ($DESCLEN - length($last->{"desc"})));
68
#------------------------------------------------------------------------
69
# Output the driver function prototypes
70
print "/* Test function prototypes */\n";
71
foreach $elt (@item, $last) {
72
printf("int %s(void);\n", $elt->{"func"});
76
#------------------------------------------------------------------------
77
# Output the table of functions
78
print "/* Table mapping index numbers to functions */\n";
79
printf("int (*%s[])(void) = {\n ", $FUNCVAR);
82
foreach $elt (@item) {
83
print($elt->{"func"}, ", ",
84
" " x ($FUNCLEN - length($elt->{"func"})));
85
$brk = ($brk + 1) & 3;
86
print "\n " unless($brk);
88
print $last->{"func"}, "\n};\n\n";
90
#------------------------------------------------------------------------
91
# Output the table of descriptions
92
print "/* Table mapping index numbers to descriptions */\n";
93
printf("const char *%s[] = {\n", $DESCVAR);
95
foreach $elt (@item) {
96
printf(" \"%s\",\n", $elt->{"desc"});
98
printf(" \"%s\"\n};\n\n", $last->{"desc"});