python/samba/netcmd/schema.py: add schema show_oc for attribute
[kai/samba-autobuild/.git] / selftest / Subunit.pm
index a94eecd7e4b594227b42479a30b1d6a3cba13187..07f4b8ff97ddb22853261de7515be2f500a3638a 100644 (file)
 
 package Subunit;
 use POSIX;
+use Time::HiRes;
 
 require Exporter;
 @ISA = qw(Exporter);
-@EXPORT_OK = qw(filter_add_prefix);
 
 use strict;
 
-sub filter_add_prefix($$)
-{
-       my ($prefix, $fh) = @_;
-
-       while(<$fh>) {
-               if (/^test: (.+)\n/) {
-                       Subunit::start_test($prefix.$1);
-               } elsif (/^(success|successful|failure|fail|skip|knownfail|error|xfail): (.*?)( \[)?([ \t]*)( multipart)?\n/) {
-                       my $result = $1;
-                       my $testname = $prefix.$2;
-                       my $reason = undef;
-                       if ($3) {
-                               $reason = "";
-                               # reason may be specified in next lines
-                               my $terminated = 0;
-                               while(<$fh>) {
-                                       if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; }
-                               }
-
-                               unless ($terminated) {
-                                       print $reason;
-                                       $reason = "reason ($result) interrupted";
-                                       $result = "error";
-                               }
-                       }
-                       Subunit::end_test($testname, $result, $reason);
-               } else {
-                       print $_;
-               }
-       }
-}
-
 sub start_test($)
 {
        my ($testname) = @_;
@@ -76,10 +44,11 @@ sub end_test($$;$)
        }
 }
 
-sub report_time($)
+sub report_time()
 {
        my ($time) = @_;
-       my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
+       $time = Time::HiRes::time() unless (defined($time));
+       my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($time);
        $sec = ($time - int($time) + $sec);
        my $msg = sprintf("%f", $sec);
        if (substr($msg, 1, 1) eq ".") {