From: Artur Bergman Date: Tue, 7 May 2002 20:24:08 +0000 (+0000) Subject: Fix bad assumptions in test case. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a438a718fdfd547b9e467a0fd1f2069bce7cb005;p=p5sagit%2Fp5-mst-13.2.git Fix bad assumptions in test case. a) print "ok $var\n"; $var++ isn't atomic by any stretch of imagination b) $var++ is not atomic c) the creating of the string to print and the actuall printing could be preempted by another thread p4raw-id: //depot/perl@16450 --- diff --git a/ext/threads/shared/t/queue.t b/ext/threads/shared/t/queue.t index f09a5b9..e5c0208 100644 --- a/ext/threads/shared/t/queue.t +++ b/ext/threads/shared/t/queue.t @@ -20,6 +20,12 @@ print "1..26\n"; my $test : shared = 1; +sub ok { + lock($test); + print "ok $test\n"; + $test++; +} + sub reader { my $tid = threads->self->tid; my $i = 0; @@ -27,7 +33,8 @@ sub reader { $i++; # print "reader (tid $tid): waiting for element $i...\n"; my $el = $q->dequeue; - print "ok $test\n"; $test++; + ok(); +# print "ok $test\n"; $test++; # print "reader (tid $tid): dequeued element $i: value $el\n"; select(undef, undef, undef, rand(1)); if ($el == -1) { @@ -58,6 +65,7 @@ for(@threads) { # print "waiting for join\n"; $_->join(); } -print "ok $test\n"; +ok(); +#print "ok $test\n";