security/nss/lib/freebl/mpi/make-test-arrays

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #!/usr/bin/perl
     3 #
     4 # make-test-arrays
     5 #
     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:
    10 #
    11 # suite-name:function-name:comment
    12 #
    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 # Read parameters from the environment, if available
    21 $NAMEVAR = $ENV{'NAMEVAR'} || "g_names";
    22 $COUNTVAR = $ENV{'COUNTVAR'} || "g_count";
    23 $FUNCVAR = $ENV{'FUNCVAR'} || "g_tests";
    24 $DESCVAR = $ENV{'DESCVAR'} || "g_descs";
    25 $FUNCLEN = 13;
    26 $NAMELEN = 18;
    27 $DESCLEN = 45;
    29 #------------------------------------------------------------------------
    30 # Suck in input from the files on the command line, or standard input
    31 while(<>) {
    32     chomp;
    33     s/\#.*$//;
    34     next if /^\s*$/;
    36     ($suite, $func, $desc) = split(/:/, $_);
    38     $tmp = { "suite" => $suite,
    39 	     "func"  => $func,
    40 	     "desc"  => $desc };
    42     push(@item, $tmp);
    43 }
    44 $count = scalar(@item);
    45 $last = pop(@item);
    47 #------------------------------------------------------------------------
    48 # Output the table of names
    49 print "/* Table mapping test suite names to index numbers */\n";
    50 printf("const int   %s = %d;\n", $COUNTVAR, $count);
    51 printf("const char *%s[] = {\n", $NAMEVAR);
    53 foreach $elt (@item) {
    54     printf("   \"%s\",%s/* %s%s */\n", $elt->{"suite"},
    55 	   " " x ($NAMELEN - length($elt->{"suite"})),
    56 	   $elt->{"desc"},
    57 	   " " x ($DESCLEN - length($elt->{"desc"})));
    58 }
    59 printf("   \"%s\" %s/* %s%s */\n", $last->{"suite"},
    60        " " x ($NAMELEN - length($last->{"suite"})),
    61        $last->{"desc"},
    62        " " x ($DESCLEN - length($last->{"desc"})));
    63 print "};\n\n";
    65 #------------------------------------------------------------------------
    66 # Output the driver function prototypes
    67 print "/* Test function prototypes */\n";
    68 foreach $elt (@item, $last) {
    69     printf("int  %s(void);\n", $elt->{"func"});
    70 }
    71 print "\n";
    73 #------------------------------------------------------------------------
    74 # Output the table of functions
    75 print "/* Table mapping index numbers to functions */\n";
    76 printf("int (*%s[])(void)  = {\n   ", $FUNCVAR);
    77 $brk = 0;
    79 foreach $elt (@item) {
    80     print($elt->{"func"}, ", ", 
    81 	  " " x ($FUNCLEN - length($elt->{"func"})));
    82     $brk = ($brk + 1) & 3;
    83     print "\n   " unless($brk);
    84 }
    85 print $last->{"func"}, "\n};\n\n";
    87 #------------------------------------------------------------------------
    88 # Output the table of descriptions
    89 print "/* Table mapping index numbers to descriptions */\n";
    90 printf("const char *%s[] = {\n", $DESCVAR);
    92 foreach $elt (@item) {
    93     printf("   \"%s\",\n", $elt->{"desc"});
    94 }
    95 printf("   \"%s\"\n};\n\n", $last->{"desc"});
    97 exit 0;

mercurial