Fixes to threads tests
[p5sagit/p5-mst-13.2.git] / ext / threads / t / stress_string.t
index 2a744ea..9cd0cd2 100644 (file)
@@ -15,14 +15,16 @@ BEGIN {
 
 use ExtUtils::testlib;
 
+my $test = 0;
 sub ok {
-    my ($id, $ok, $name) = @_;
+    my ($ok, $name) = @_;
+    $test++;
 
     # You have to do it this way or VMS will get confused.
     if ($ok) {
-        print("ok $id - $name\n");
+        print("ok $test - $name\n");
     } else {
-        print("not ok $id - $name\n");
+        print("not ok $test - $name\n");
         printf("# Failed test at line %d\n", (caller)[2]);
     }
 
@@ -31,28 +33,33 @@ sub ok {
 
 BEGIN {
     $| = 1;
-    print("1..63\n");   ### Number of tests that will be run ###
+    print("1..61\n");   ### Number of tests that will be run ###
 };
 
 use threads;
-ok(1, 1, 'Loaded');
+ok(1, 'Loaded');
 
 ### Start of Testing ###
 
+my $cnt = 30;
+
 sub test9 {
     my $i = shift;
     for (1..500000) { $i++ };
 }
+
 my @threads;
-for (2..32) {
-    ok($_, 1, "Multiple thread test");
-    push(@threads, threads->create('test9', $_));
+for (1..$cnt) {
+    my $thr = threads->create('test9', $_);
+    ok($thr, "Thread created - iter $_");
+    push(@threads, $thr);
 }
 
-my $i = 33;
-for (@threads) {
-    $_->join;
-    ok($i++, 1, "Thread joined");
+for (1..$cnt) {
+    my ($result, $thr);
+    $thr = $threads[$_-1];
+    $result = $thr->join if $thr;
+    ok($thr, "Thread joined - iter $_");
 }
 
 # EOF