#
# Copyright (c) 2002 Japan Network Information Center.
# All rights reserved.
#
# By using this file, you agree to the terms and conditions set forth bellow.
#
# LICENSE TERMS AND CONDITIONS
#
# The following License Terms and Conditions apply, unless a different
# license is obtained from Japan Network Information Center ("JPNIC"),
# a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
# Chiyoda-ku, Tokyo 101-0047, Japan.
#
# 1. Use, Modification and Redistribution (including distribution of any
# under this License Terms and Conditions.
#
# 2. Redistribution of source code must retain the copyright notices as they
# appear in each source code file, this License Terms and Conditions.
#
# 3. Redistribution in binary form must reproduce the Copyright Notice,
# materials provided with the distribution. For the purposes of binary
# distribution the "Copyright Notice" refers to the following language:
# "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
#
# 4. The name of JPNIC may not be used to endorse or promote products
# derived from this Software without specific prior written approval of
# JPNIC.
#
# 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#
use FileHandle;
#
# Parsing status.
#
my $STATUS_HEADER = 0;
my $STATUS_HEADER_COMMENT = 1;
my $STATUS_SEPARATOR = 2;
my $STATUS_BODY = 3;
my $STATUS_GLOBAL = 4;
my $STATUS_GLOBAL_COMMENT = 5;
my $STATUS_PREAMBLE = 6;
my $LINENO_MARK = "<LINENO>";
#
# Create a new testsuite context.
#
return {'ntests' => 0,
'setups' => {},
'teardowns' => {},
'tests' => [],
'titles' => [],
'preambles' => ''};
}
#
# Read `$file' and put the result into `$testsutie'.
#
'group' => '',
'title' => '',
'error' => '',
'lineno' => 0,
}
for (;;) {
}
}
}
}
my $result = 1;
$parser->{status} = $STATUS_SEPARATOR;
$parser->{status} = $STATUS_BODY;
} else {
$result = 0;
}
# nothing to be done.
$parser->{status} = $STATUS_SEPARATOR;
$parser->{status} = $STATUS_BODY;
} else {
$result = 0;
}
# nothing to be done.
$parser->{status} = $STATUS_BODY;
} else {
$result = 0;
}
$parser->{status} = $STATUS_GLOBAL;
} else {
}
$parser->{status} = $STATUS_HEADER;
# nothing to be done.
} else {
$result = 0;
}
# nothing to be done.
$parser->{status} = $STATUS_GLOBAL;
} else {
$result = 0;
}
$parser->{status} = $STATUS_HEADER;
} else {
}
} else {
$result = 0;
}
return $result;
}
$parser->{type} = $1;
} else {
return 0;
}
return 1;
}
$field =~ s/^\/\/\s*//;
$field =~ s/\s+$//;
my $group = $1;
return 0;
}
return 0;
}
return 0;
}
return 0;
}
return 0;
}
} else {
return 0;
}
return 0;
}
}
}
my $title = $1;
return 0;
}
return 0;
}
$parser->{type});
return 0;
}
} else {
return 0;
}
return 1;
}
return 0;
}
return 0;
}
return 1;
}
$testsuite->{setups}->{$group} =
}
$testsuite->{teardowns}->{$group} =
}
} else {
$testsuite->{ntests}++;
$testsuite->{tests}->[-1] .=
$testsuite->{ntests});
$testsuite->{tests}->[-1] .=
$testsuite->{setups}->{$group_names[$i]};
}
}
$testsuite->{tests}->[-1] .=
}
}
return 1;
}
$testsuite->{setups}->{$group} .= $line;
$testsuite->{teardowns}->{$group} .= $line;
} else {
$testsuite->{tests}->[-1] .= $line;
}
return 1;
}
$testsuite->{tests}->[-1] .=
$testsuite->{teardowns}->{$group_names[$i]};
}
}
}
return 1;
}
}
$testsuite->{preambles} .= $line;
return 1;
}
}
#
# Output `$testsuite' as source codes of C.
#
my $generator = {
'lineno' => 0
};
}
my $preamble_header =
"/* This file is automatically generated by testygen. */\n\n"
. "#define TESTYGEN 1\n"
. "\n";
my $preamble_footer =
"\n"
. "$LINENO_MARK\n"
. "#include \"testsuite.h\"\n"
. "\n";
output_lines($testsuite->{tests}->[$i], $generator, $handle,
}
my $main_header =
"\n"
. "$LINENO_MARK\n"
. "int\n"
. "main(int argc, char *argv[]) {\n"
. "\tidn_testsuite_t ctx;\n"
. "\tconst char *title;\n"
. "\n"
. "\tidn_testsuite_create(&ctx);\n";
my $title = $testsuite->{titles}->[$i];
}
my $main_footer =
"\n"
. "\tif (argc > 1 && strcmp(argv[1], \"-v\") == 0) {\n"
. "\t idn_testsuite_setverbose(ctx);\n"
. "\t argc--;\n"
. "\t argv++;\n"
. "\t}\n"
. "\tif (argc == 1)\n"
. "\t idn_testsuite_runall(ctx);\n"
. "\telse\n"
. "\t idn_testsuite_run(ctx, argv + 1);\n"
. "\n"
. "\tprintf(\"passed=%d, failed=%d, total=%d\\n\",\n"
. "\t idn_testsuite_npassed(ctx),\n"
. "\t idn_testsuite_nfailed(ctx),\n"
. "\t idn_testsuite_ntestcases(ctx) - idn_testsuite_nskipped(ctx));\n"
. "\n"
. "\tidn_testsuite_destroy(ctx);\n"
. "\treturn (0);\n"
. "\}\n";
}
$line = $1;
$generator->{lineno}++;
$generator->{file});
}
} else {
}
}
}
}
#
# main.
#
my (%options);
exit(1);
}
if (@ARGV != 1) {
exit(1);
}
my ($out_file);
} else {
}
parse_file($testsuite, $in_file, !$options{L});
output_tests($testsuite, $out_file, !$options{L});
exit(0);