From: Jarkko Hietaniemi Date: Sun, 21 Apr 2002 16:22:17 +0000 (+0000) Subject: Do not assume that io buffer flushing happens in the same X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8abd20a8dbd37aec308f8f9efa9e3b63677392e4;p=p5sagit%2Fp5-mst-13.2.git Do not assume that io buffer flushing happens in the same order as joins (that assumption broke in a multicpu IRIX box) p4raw-id: //depot/perl@16044 --- diff --git a/ext/threads/t/thread.t b/ext/threads/t/thread.t index bb374ee..85bf2cd 100644 --- a/ext/threads/t/thread.t +++ b/ext/threads/t/thread.t @@ -1,17 +1,18 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; + @INC = qw(../lib .); require Config; import Config; unless ($Config{'useithreads'}) { print "1..0 # Skip: no useithreads\n"; exit 0; } + require "test.pl"; } use ExtUtils::testlib; use strict; -BEGIN { $| = 1; print "1..22\n" }; +BEGIN { $| = 1; print "1..21\n" }; use threads; use threads::shared; @@ -78,37 +79,24 @@ $t->join->join; sub testsprintf { my $testno = shift; my $same = sprintf( "%0.f", $testno); - if($testno eq $same) { - print "ok $testno\n"; - } else { - print "not ok $testno\t# '$testno' ne '$same'\n"; - } + return $testno eq $same; } sub threaded { - my ($string, $string_end, $testno) = @_; + my ($string, $string_end) = @_; # Do the match, saving the output in appropriate variables $string =~ /(.*)(is)(.*)/; # Yield control, allowing the other thread to fill in the match variables threads->yield(); # Examine the match variable contents; on broken perls this fails - if ($3 eq $string_end) { - print "ok $testno\n"; - } - else { - warn <new(\&testsprintf, 15); my $thr2 = threads->new(\&testsprintf, 16); @@ -118,22 +106,17 @@ EOT my $longe = " short."; my $foo = "This is bar bar bar."; my $fooe = " bar bar bar."; - my $thr3 = new threads \&threaded, $short, $shorte, "17"; - my $thr4 = new threads \&threaded, $long, $longe, "18"; - my $thr5 = new threads \&testsprintf, "19"; - my $thr6 = threads->new(\&testsprintf, 20); - my $thr7 = new threads \&threaded, $foo, $fooe, "21"; - - - - $thr1->join(); - $thr2->join(); - $thr3->join(); - $thr4->join(); - $thr5->join(); - $thr6->join(); - $thr7->join(); - print "ok 22\n"; + my $thr3 = new threads \&threaded, $short, $shorte; + my $thr4 = new threads \&threaded, $long, $longe; + my $thr5 = new threads \&testsprintf, 19; + my $thr6 = new threads \&testsprintf, 20; + my $thr7 = new threads \&threaded, $foo, $fooe; + + ok($thr1->join()); + ok($thr2->join()); + ok($thr3->join()); + ok($thr4->join()); + ok($thr5->join()); + ok($thr6->join()); + ok($thr7->join()); } - -