From 16b7182d91c8e5071656b7a8b9f73d13e41099ea Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 13 Oct 2018 14:37:44 -0400 Subject: Upgrade qtest to 1.5 --- qtest/module/TestDriver.pm | 52 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'qtest/module') diff --git a/qtest/module/TestDriver.pm b/qtest/module/TestDriver.pm index ca083e56..cec08d35 100644 --- a/qtest/module/TestDriver.pm +++ b/qtest/module/TestDriver.pm @@ -2,7 +2,7 @@ # # This file is part of qtest. # -# Copyright 1993-2007, Jay Berkenbilt +# Copyright 1993-2018, Jay Berkenbilt # # QTest is distributed under the terms of version 2.0 of the Artistic # license which may be found in the source distribution. @@ -71,12 +71,14 @@ use constant EXPECT_FAILURE => 1 << 2; use constant RM_WS_ONLY_LINES => 1 << 3; # Field names -use vars qw($f_socket $f_origdir $f_tempdir $f_testlog $f_testxml $f_suitename); +use vars (qw($f_socket $f_origdir $f_tempdir $f_testlog), + qw($f_testxml $f_testjunit $f_suitename)); $f_socket = 'socket'; $f_origdir = 'origdir'; $f_tempdir = 'tempdir'; $f_testlog = 'testlog'; $f_testxml = 'testxml'; +$f_testjunit = 'testjunit'; $f_suitename = 'suitename'; use vars qw($f_passes $f_fails $f_xpasses $f_xfails $f_testnum); @@ -233,13 +235,14 @@ sub new } my $suitename = shift; - if (! ((@ARGV == 11) && + if (! ((@ARGV == 13) && (($ARGV[0] eq '-fd') || ($ARGV[0] eq '-port')) && ($ARGV[2] eq '-origdir') && ($ARGV[4] eq '-tempdir') && ($ARGV[6] eq '-testlog') && ($ARGV[8] eq '-testxml') && - ($ARGV[10] =~ m/^-stdout-tty=([01])$/) && + ($ARGV[10] eq '-testjunit') && + ($ARGV[12] =~ m/^-stdout-tty=([01])$/) && (-d $ARGV[5]))) { die +__PACKAGE__, ": improper invocation of test driver $0 (" . @@ -251,11 +254,14 @@ sub new my $tempdir = $ARGV[5]; my $testlogfile = $ARGV[7]; my $testxmlfile = $ARGV[9]; + my $testjunitfile = $ARGV[11]; my $testlog = new IO::File(">>$testlogfile"); binmode $testlog; my $testxml = new IO::File(">>$testxmlfile"); binmode $testxml; - $ARGV[10] =~ m/=([01])/ or die +__PACKAGE__, ": INTERNAL ERROR in ARGV[10]"; + my $testjunit = new IO::File(">>$testjunitfile"); + binmode $testjunit; + $ARGV[12] =~ m/=([01])/ or die +__PACKAGE__, ": INTERNAL ERROR in ARGV[10]"; my $stdout_is_tty = $1; if ($stdout_is_tty) { @@ -300,6 +306,7 @@ sub new $rep->{+__PACKAGE__}{$f_tempdir} = $tempdir; $rep->{+__PACKAGE__}{$f_testlog} = $testlog; $rep->{+__PACKAGE__}{$f_testxml} = $testxml; + $rep->{+__PACKAGE__}{$f_testjunit} = $testjunit; $rep->{+__PACKAGE__}{$f_suitename} = $suitename; $rep->{+__PACKAGE__}{$f_passes} = 0; $rep->{+__PACKAGE__}{$f_fails} = 0; @@ -342,6 +349,12 @@ sub _testxml $rep->{+__PACKAGE__}{$f_testxml}; } +sub _testjunit +{ + my $rep = shift; + $rep->{+__PACKAGE__}{$f_testjunit}; +} + sub _suitename { my $rep = shift; @@ -1003,6 +1016,7 @@ sub runtest my $passed = $rep->update_counters($outcome, $exp_outcome); my $testxml = $rep->_testxml(); + my $testjunit = $rep->_testjunit(); my $testlog = $rep->_testlog(); # $outcome_text is for the human-readable. We need something # different for the xml file. @@ -1014,16 +1028,22 @@ sub runtest ? ($passed ? "pass" : "unexpected-pass") : ($passed ? "expected-fail" : "fail")) . "\"\n"); + $testjunit->print(" print(" >\n"); + $testjunit->print(" >\n" . + " \n"); $testlog->printf("$category test %d (%s) FAILED\n", $testnum, $description); my $cwd = getcwd(); $testlog->print("cwd: $cwd\n"); + $testjunit->print("cwd: " . xmlify($cwd) . "\n"); $testxml->print(" " . xmlify($cwd) . "\n"); my $cmd = $in_command; if ((defined $cmd) && (ref($cmd) eq 'ARRAY')) @@ -1034,6 +1054,7 @@ sub runtest { $testlog->print("command: $cmd\n"); $testxml->print(" " . xmlify($cmd) . "\n"); + $testjunit->print("command: " . xmlify($cmd) . "\n"); } if (defined $out_file) { @@ -1044,6 +1065,8 @@ sub runtest $testxml->print( " " . xmlify($out_file) . "\n"); + $testjunit->print("expected output in " . + xmlify($out_file) . "\n"); } # It would be nice if we could filter out internal calls for @@ -1054,6 +1077,7 @@ sub runtest $testxml->print(" test failure" . xmlify(Carp::longmess()) . "\n"); + $testjunit->print("stracktrace:\n" . xmlify(Carp::longmess())); if (! $status_match) { @@ -1064,16 +1088,20 @@ sub runtest " $out_exit_status\n"); $testxml->print( " $exit_status\n"); + $testjunit->printf(" Expected status: %s\n", $out_exit_status); + $testjunit->printf(" Actual status: %s\n", $exit_status); } if (! $output_match) { &QTC::TC("testdriver", "TestDriver output mismatch"); $testlog->print("--> BEGIN EXPECTED OUTPUT <--\n"); $testxml->print(" "); + $testjunit->print("-- BEGIN EXPECTED OUTPUT --\n"); if (defined $expected_file) { write_file_to_fh($expected_file, $testlog); xml_write_file_to_fh($expected_file, $testxml); + xml_write_file_to_fh($expected_file, $testjunit); } elsif (defined $out_regexp) { @@ -1083,6 +1111,7 @@ sub runtest $testlog->print("\n"); } $testxml->print("regexp: " . xmlify($out_regexp)); + $testjunit->print("regexp: " . xmlify($out_regexp)); } else { @@ -1093,19 +1122,26 @@ sub runtest "--> BEGIN ACTUAL OUTPUT <--\n"); $testxml->print("\n" . " "); + $testjunit->print("-- END EXPECTED OUTPUT --\n" . + "-- ACTUAL OUTPUT --\n"); write_file_to_fh($actual_file, $testlog); xml_write_file_to_fh($actual_file, $testxml); + xml_write_file_to_fh($actual_file, $testjunit); $testlog->print("--> END ACTUAL OUTPUT <--\n"); $testxml->print("\n"); + $testjunit->print("-- ACTUAL OUTPUT --\n"); if (defined $output_diff) { &QTC::TC("testdriver", "TestDriver display diff"); $testlog->print("--> DIFF EXPECTED ACTUAL <--\n"); $testxml->print(" "); + $testjunit->print("-- DIFF EXPECTED ACTUAL --\n"); write_file_to_fh($output_diff, $testlog); xml_write_file_to_fh($output_diff, $testxml); + xml_write_file_to_fh($output_diff, $testjunit); $testlog->print("--> END DIFFERENCES <--\n"); $testxml->print("\n"); + $testjunit->print("-- END DIFFERENCES --\n"); } else { @@ -1113,10 +1149,13 @@ sub runtest } } $testxml->print(" \n"); + $testjunit->print(" \n" . + " \n"); } else { $testxml->print(" />\n"); + $testjunit->print(" />\n"); } if (defined $threads) @@ -1245,7 +1284,8 @@ sub xmlify $str =~ s//>/g; $str =~ s/\"/"/g if $attr; - $str =~ s/([\000-\010\013-\037\177-\377])/sprintf("&#x%02x;", ord($1))/ge; + $str =~ s/([\000-\010\013-\037])/sprintf("[0x%02x]", ord($1))/ge; + $str =~ s/([\177-\377])/sprintf("&#x%02x;", ord($1))/ge; $str; } -- cgit v1.2.3-54-g00ecf