From 01ab492d286e40dd2118b6755223d7bdad2fec92 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Aug 2007 15:15:38 +0000 Subject: r24708: Move subunit code to a separate module. (This used to be commit 4be702896d6875b463dee046b34744b0b5699519) --- source4/selftest/Subunit.pm | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 source4/selftest/Subunit.pm (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm new file mode 100644 index 0000000000..1be412c356 --- /dev/null +++ b/source4/selftest/Subunit.pm @@ -0,0 +1,74 @@ +package Subunit; + +require Exporter; +@ISA = qw(Exporter); +@EXPORT_OK = qw(parse_results); + +use strict; + +sub parse_results($$$$$) +{ + my ($msg_ops, $msg_state, $statistics, $fh, $expecting_failure) = @_; + my $expected_ret = 1; + my $open_tests = {}; + + while(<$fh>) { + if (/^test: (.+)\n/) { + $msg_ops->control_msg($msg_state, $_); + $open_tests->{$1} = 1; + $msg_ops->start_test($msg_state, $1); + } elsif (/^(success|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) { + $msg_ops->control_msg($msg_state, $_); + my $reason = undef; + if ($3) { + $reason = ""; + # reason may be specified in next lines + while(<$fh>) { + $msg_ops->control_msg($msg_state, $_); + if ($_ eq "]\n") { last; } else { $reason .= $_; } + } + } + my $result = $1; + if ($1 eq "success") { + delete $open_tests->{$2}; + if ($expecting_failure->("$msg_state->{NAME}/$2")) { + $statistics->{TESTS_UNEXPECTED_OK}++; + $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + } else { + $statistics->{TESTS_EXPECTED_OK}++; + $msg_ops->end_test($msg_state, $2, $1, 0, $reason); + } + } elsif ($1 eq "failure") { + delete $open_tests->{$2}; + if ($expecting_failure->("$msg_state->{NAME}/$2")) { + $statistics->{TESTS_EXPECTED_FAIL}++; + $msg_ops->end_test($msg_state, $2, $1, 0, $reason); + $expected_ret = 0; + } else { + $statistics->{TESTS_UNEXPECTED_FAIL}++; + $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + } + } elsif ($1 eq "skip") { + $statistics->{TESTS_SKIP}++; + delete $open_tests->{$2}; + $msg_ops->end_test($msg_state, $2, $1, 0, $reason); + } elsif ($1 eq "error") { + $statistics->{TESTS_ERROR}++; + delete $open_tests->{$2}; + $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + } + } else { + $msg_ops->output_msg($msg_state, $_); + } + } + + foreach (keys %$open_tests) { + $msg_ops->end_test($msg_state, $_, "error", 1, + "was started but never finished!"); + $statistics->{TESTS_ERROR}++; + } + + return $expected_ret; +} + +1; -- cgit From 37d63aab72b1e40577d61a87eab214601eaf82d2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 2 Oct 2007 15:54:26 +0000 Subject: r25466: fix calculation of $expected_ret, when there're some expected and some unexpected failures within one testsuite. metze (This used to be commit ca2a07c71fd5aa2446c0c292b4b058acc0b54838) --- source4/selftest/Subunit.pm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index 1be412c356..2ecafb42d0 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -9,7 +9,10 @@ use strict; sub parse_results($$$$$) { my ($msg_ops, $msg_state, $statistics, $fh, $expecting_failure) = @_; - my $expected_ret = 1; + my $unexpected_ok = 0; + my $expected_fail = 0; + my $unexpected_fail = 0; + my $unexpected_err = 0; my $open_tests = {}; while(<$fh>) { @@ -34,6 +37,7 @@ sub parse_results($$$$$) if ($expecting_failure->("$msg_state->{NAME}/$2")) { $statistics->{TESTS_UNEXPECTED_OK}++; $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + $unexpected_ok++; } else { $statistics->{TESTS_EXPECTED_OK}++; $msg_ops->end_test($msg_state, $2, $1, 0, $reason); @@ -43,10 +47,11 @@ sub parse_results($$$$$) if ($expecting_failure->("$msg_state->{NAME}/$2")) { $statistics->{TESTS_EXPECTED_FAIL}++; $msg_ops->end_test($msg_state, $2, $1, 0, $reason); - $expected_ret = 0; + $expected_fail++; } else { $statistics->{TESTS_UNEXPECTED_FAIL}++; $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + $unexpected_fail++; } } elsif ($1 eq "skip") { $statistics->{TESTS_SKIP}++; @@ -56,6 +61,7 @@ sub parse_results($$$$$) $statistics->{TESTS_ERROR}++; delete $open_tests->{$2}; $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + $unexpected_err++; } } else { $msg_ops->output_msg($msg_state, $_); @@ -63,12 +69,18 @@ sub parse_results($$$$$) } foreach (keys %$open_tests) { - $msg_ops->end_test($msg_state, $_, "error", 1, - "was started but never finished!"); + $msg_ops->end_test($msg_state, $_, "error", 1, + "was started but never finished!"); $statistics->{TESTS_ERROR}++; + $unexpected_err++; } - return $expected_ret; + return 1 if $unexpected_err > 0; + return 1 if $unexpected_fail > 0; + return 1 if $unexpected_ok > 0 and $expected_fail > 0; + return 0 if $unexpected_ok > 0 and $expected_fail == 0; + return 0 if $expected_fail > 0; + return 1; } 1; -- cgit From 902b1935bb5655dc9340747ddf8a0e70de231882 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Nov 2007 01:36:38 +0100 Subject: r26190: Allow successful as well as success. (This used to be commit d5dd11d1f5837c1aa929e8168d5d51a470277b88) --- source4/selftest/Subunit.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index 2ecafb42d0..27e1b9815f 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -20,7 +20,7 @@ sub parse_results($$$$$) $msg_ops->control_msg($msg_state, $_); $open_tests->{$1} = 1; $msg_ops->start_test($msg_state, $1); - } elsif (/^(success|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) { + } elsif (/^(success|successful|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) { $msg_ops->control_msg($msg_state, $_); my $reason = undef; if ($3) { @@ -32,7 +32,7 @@ sub parse_results($$$$$) } } my $result = $1; - if ($1 eq "success") { + if ($1 eq "success" or $1 eq "successful") { delete $open_tests->{$2}; if ($expecting_failure->("$msg_state->{NAME}/$2")) { $statistics->{TESTS_UNEXPECTED_OK}++; -- cgit From 254f1c6fee18dd14d2f9f97d65e6fe9ef04c26f2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Dec 2007 15:54:02 +0100 Subject: r26547: Make testsuites less special during subunit handling. (This used to be commit 0bf6bdcd7f21740853ae852193d51bdf14201782) --- source4/selftest/Subunit.pm | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index 27e1b9815f..ea08ef8f38 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -6,20 +6,20 @@ require Exporter; use strict; -sub parse_results($$$$$) +sub parse_results($$$$$$) { - my ($msg_ops, $msg_state, $statistics, $fh, $expecting_failure) = @_; + my ($msg_ops, $msg_state, $statistics, $fh, $expecting_failure, $open_tests) = @_; my $unexpected_ok = 0; my $expected_fail = 0; my $unexpected_fail = 0; my $unexpected_err = 0; - my $open_tests = {}; + my $orig_open_len = $#$open_tests; while(<$fh>) { if (/^test: (.+)\n/) { $msg_ops->control_msg($msg_state, $_); - $open_tests->{$1} = 1; - $msg_ops->start_test($msg_state, $1); + $msg_ops->start_test($msg_state, $open_tests, $1); + push (@$open_tests, $1); } elsif (/^(success|successful|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) { $msg_ops->control_msg($msg_state, $_); my $reason = undef; @@ -33,34 +33,34 @@ sub parse_results($$$$$) } my $result = $1; if ($1 eq "success" or $1 eq "successful") { - delete $open_tests->{$2}; + pop(@$open_tests); #FIXME: Check that popped value == $2 if ($expecting_failure->("$msg_state->{NAME}/$2")) { $statistics->{TESTS_UNEXPECTED_OK}++; - $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason); $unexpected_ok++; } else { $statistics->{TESTS_EXPECTED_OK}++; - $msg_ops->end_test($msg_state, $2, $1, 0, $reason); + $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason); } } elsif ($1 eq "failure") { - delete $open_tests->{$2}; + pop(@$open_tests); #FIXME: Check that popped value == $2 if ($expecting_failure->("$msg_state->{NAME}/$2")) { $statistics->{TESTS_EXPECTED_FAIL}++; - $msg_ops->end_test($msg_state, $2, $1, 0, $reason); + $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason); $expected_fail++; } else { $statistics->{TESTS_UNEXPECTED_FAIL}++; - $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason); $unexpected_fail++; } } elsif ($1 eq "skip") { $statistics->{TESTS_SKIP}++; - delete $open_tests->{$2}; - $msg_ops->end_test($msg_state, $2, $1, 0, $reason); + pop(@$open_tests); #FIXME: Check that popped value == $2 + $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason); } elsif ($1 eq "error") { $statistics->{TESTS_ERROR}++; - delete $open_tests->{$2}; - $msg_ops->end_test($msg_state, $2, $1, 1, $reason); + pop(@$open_tests); #FIXME: Check that popped value == $2 + $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason); $unexpected_err++; } } else { @@ -68,8 +68,8 @@ sub parse_results($$$$$) } } - foreach (keys %$open_tests) { - $msg_ops->end_test($msg_state, $_, "error", 1, + while ($#$open_tests > $orig_open_len) { + $msg_ops->end_test($msg_state, $open_tests, pop(@$open_tests), "error", 1, "was started but never finished!"); $statistics->{TESTS_ERROR}++; $unexpected_err++; -- cgit From b3b3af05f14c2d8d946ea024fcba1852949cb484 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Dec 2007 17:07:21 +0100 Subject: r26552: remove unused state variable, use dot as path separator for test names. (This used to be commit a84975610c2825e9ceecdd47d744282bd55220be) --- source4/selftest/Subunit.pm | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index ea08ef8f38..e5c61ca9ba 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -6,9 +6,9 @@ require Exporter; use strict; -sub parse_results($$$$$$) +sub parse_results($$$$$) { - my ($msg_ops, $msg_state, $statistics, $fh, $expecting_failure, $open_tests) = @_; + my ($msg_ops, $statistics, $fh, $expecting_failure, $open_tests) = @_; my $unexpected_ok = 0; my $expected_fail = 0; my $unexpected_fail = 0; @@ -17,59 +17,59 @@ sub parse_results($$$$$$) while(<$fh>) { if (/^test: (.+)\n/) { - $msg_ops->control_msg($msg_state, $_); - $msg_ops->start_test($msg_state, $open_tests, $1); + $msg_ops->control_msg($_); + $msg_ops->start_test($open_tests, $1); push (@$open_tests, $1); } elsif (/^(success|successful|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) { - $msg_ops->control_msg($msg_state, $_); + $msg_ops->control_msg($_); my $reason = undef; if ($3) { $reason = ""; # reason may be specified in next lines while(<$fh>) { - $msg_ops->control_msg($msg_state, $_); + $msg_ops->control_msg($_); if ($_ eq "]\n") { last; } else { $reason .= $_; } } } my $result = $1; if ($1 eq "success" or $1 eq "successful") { pop(@$open_tests); #FIXME: Check that popped value == $2 - if ($expecting_failure->("$msg_state->{NAME}/$2")) { + if ($expecting_failure->(join(".", @$open_tests) . ".$2")) { $statistics->{TESTS_UNEXPECTED_OK}++; - $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason); + $msg_ops->end_test($open_tests, $2, $1, 1, $reason); $unexpected_ok++; } else { $statistics->{TESTS_EXPECTED_OK}++; - $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason); + $msg_ops->end_test($open_tests, $2, $1, 0, $reason); } } elsif ($1 eq "failure") { pop(@$open_tests); #FIXME: Check that popped value == $2 - if ($expecting_failure->("$msg_state->{NAME}/$2")) { + if ($expecting_failure->(join(".", @$open_tests) . ".$2")) { $statistics->{TESTS_EXPECTED_FAIL}++; - $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason); + $msg_ops->end_test($open_tests, $2, $1, 0, $reason); $expected_fail++; } else { $statistics->{TESTS_UNEXPECTED_FAIL}++; - $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason); + $msg_ops->end_test($open_tests, $2, $1, 1, $reason); $unexpected_fail++; } } elsif ($1 eq "skip") { $statistics->{TESTS_SKIP}++; pop(@$open_tests); #FIXME: Check that popped value == $2 - $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason); + $msg_ops->end_test($open_tests, $2, $1, 0, $reason); } elsif ($1 eq "error") { $statistics->{TESTS_ERROR}++; pop(@$open_tests); #FIXME: Check that popped value == $2 - $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason); + $msg_ops->end_test($open_tests, $2, $1, 1, $reason); $unexpected_err++; } } else { - $msg_ops->output_msg($msg_state, $_); + $msg_ops->output_msg($_); } } while ($#$open_tests > $orig_open_len) { - $msg_ops->end_test($msg_state, $open_tests, pop(@$open_tests), "error", 1, + $msg_ops->end_test($open_tests, pop(@$open_tests), "error", 1, "was started but never finished!"); $statistics->{TESTS_ERROR}++; $unexpected_err++; -- cgit From 0de47f6b577fdb1e93395b56960951b32cca48c0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 17 Mar 2008 15:17:19 +0100 Subject: selftest: handle progress output in verbose mode metze (This used to be commit 9196213c49532ac60349ff55e66430b7c80b09c2) --- source4/selftest/Subunit.pm | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index e5c61ca9ba..f8a7794aac 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -15,7 +15,34 @@ sub parse_results($$$$$) my $unexpected_err = 0; my $orig_open_len = $#$open_tests; - while(<$fh>) { + while(1) { + my $line = ""; + my $char = ""; + my $eof = 0; + my $error = 0; + + while ($char ne "\n") { + my $ret = sysread($fh, $char, 1); + if (not defined($ret)) { + $error = $!; + last; + } + if ($ret == 0) { + $eof = 1; + last; + } + + $line .= $char; + if ($char eq "\r") { + $msg_ops->output_msg($line); + $line = ""; + } + } + + last if ($eof or $error); + + $_ = $line; + if (/^test: (.+)\n/) { $msg_ops->control_msg($_); $msg_ops->start_test($open_tests, $1); -- cgit From 297399d877476bd72fbf8055cd728b6f8230ba09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 09:36:29 +0100 Subject: selftest: use a separate var for printing out sub parts of lines with \r This restores the bahavior of the $_ variable in the code that detects expected failures. metze (This used to be commit 903eb9a23d80576f5df2d90a0e025f2366ffe4c6) --- source4/selftest/Subunit.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index f8a7794aac..1c279437c8 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -17,6 +17,7 @@ sub parse_results($$$$$) while(1) { my $line = ""; + my $subline = ""; my $char = ""; my $eof = 0; my $error = 0; @@ -33,9 +34,10 @@ sub parse_results($$$$$) } $line .= $char; + $subline .= $char; if ($char eq "\r") { - $msg_ops->output_msg($line); - $line = ""; + $msg_ops->output_msg($subline); + $subline = ""; } } -- cgit From 5b35e551300419d75b2405ba76bff8e7ec5a01af Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 15:36:03 +0100 Subject: selftest: fix parsing of Subunit results This reverts parts of 903eb9a23d80576f5df2d90a0e025f2366ffe4c6 and 9196213c49532ac60349ff55e66430b7c80b09c2. metze (This used to be commit 5f5fa368c2ca472409c0082400b6e26029dfd7b5) --- source4/selftest/Subunit.pm | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index 1c279437c8..e5c61ca9ba 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -15,36 +15,7 @@ sub parse_results($$$$$) my $unexpected_err = 0; my $orig_open_len = $#$open_tests; - while(1) { - my $line = ""; - my $subline = ""; - my $char = ""; - my $eof = 0; - my $error = 0; - - while ($char ne "\n") { - my $ret = sysread($fh, $char, 1); - if (not defined($ret)) { - $error = $!; - last; - } - if ($ret == 0) { - $eof = 1; - last; - } - - $line .= $char; - $subline .= $char; - if ($char eq "\r") { - $msg_ops->output_msg($subline); - $subline = ""; - } - } - - last if ($eof or $error); - - $_ = $line; - + while(<$fh>) { if (/^test: (.+)\n/) { $msg_ops->control_msg($_); $msg_ops->start_test($open_tests, $1); -- cgit From d3729a8efa1c7e848d263ef320d3114144477be3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2008 00:03:00 +0200 Subject: Support knownfail Subunit command. (This used to be commit ad58a508542bd93115be0ad826fb93aa3d349658) --- source4/selftest/Subunit.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'source4/selftest/Subunit.pm') diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm index e5c61ca9ba..05e51da541 100644 --- a/source4/selftest/Subunit.pm +++ b/source4/selftest/Subunit.pm @@ -20,15 +20,22 @@ sub parse_results($$$$$) $msg_ops->control_msg($_); $msg_ops->start_test($open_tests, $1); push (@$open_tests, $1); - } elsif (/^(success|successful|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) { + } elsif (/^(success|successful|failure|skip|knownfail|error): (.*?)( \[)?([ \t]*)\n/) { $msg_ops->control_msg($_); my $reason = undef; if ($3) { $reason = ""; # reason may be specified in next lines + my $terminated = 0; while(<$fh>) { $msg_ops->control_msg($_); - if ($_ eq "]\n") { last; } else { $reason .= $_; } + if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; } + } + + unless ($terminated) { + $statistics->{TESTS_ERROR}++; + $msg_ops->end_test($open_tests, $2, $1, 1, "reason interrupted"); + return 1; } } my $result = $1; @@ -53,6 +60,10 @@ sub parse_results($$$$$) $msg_ops->end_test($open_tests, $2, $1, 1, $reason); $unexpected_fail++; } + } elsif ($1 eq "knownfail") { + pop(@$open_tests); #FIXME: Check that popped value == $2 + $statistics->{TESTS_EXPECTED_FAIL}++; + $msg_ops->end_test($open_tests, $2, $1, 0, $reason); } elsif ($1 eq "skip") { $statistics->{TESTS_SKIP}++; pop(@$open_tests); #FIXME: Check that popped value == $2 -- cgit