parse-testsuite.pl untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 29 CC 1 SCAR 6.9
CC
1
Cov
0%
handle_testcase_end
2.0
handle_testsuite_end
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl -w
2 #
3
4 use XML::Node;
5
6 # The following sample script calculates how many test cases there are in
7 # a test suite XML file.
8 #
9 # The XML file name can be passed as a parameter. Example:
10 # perl test.pl test.xml
11 #
12
13 my $suite_name = "";
14 my $testcase_name = "";
15 my $xml_filename = "test.xml";
16 my $testcase_no = 0;
17 my $arg1 = shift;
18
19 if ($arg1) {
20 $xml_filename = $arg1;
21 }
22
23 $p = XML::Node->new();
24
25 $p->register(">TestTalk>TestSuite>Name","char" => \$ suite_name);
26 $p->register(">TestTalk>TestSuite>TestCase>Name","char" => \$testcase_name);
27 $p->register(">TestTalk>TestSuite>TestCase","end" => \& handle_testcase_end);
28 $p->register(">TestTalk>TestSuite","end" => \& handle_testsuite_end);
29
30 print "\nProcessing file [$xml_filename]...\n\n";
31 $p->parsefile($xml_filename);
32
33
34 sub handle_testcase_end
35 {
36 print "Found test case [$testcase_name]\n";
37 $testcase_name = "";
38 $testcase_no ++;
39 }
40
41 sub handle_testsuite_end
42 {
43 print "\n--There are $testcase_no test cases in test suite [$suite_name]\n\n";
44 $testcase_name = "";
45 }
46
47
48
49