[prev in list] [next in list] [prev in thread] [next in thread]
List: perl5-changes
Subject: Change 34150: [PATCH] watchdog() for threads tests
From: Steve Hay <SteveHay () planit ! com>
Date: 2008-07-16 17:15:05
Message-ID: 20080716171505.2238450086 () mx ! activestate ! com
[Download RAW message or body]
Change 34150 by steveh@maldoror on 2008/07/16 17:03:10
Subject: [PATCH] watchdog() for threads tests
From: "Jerry D. Hedden" <jdhedden@gmail.com>
Date: Wed, 16 Jul 2008 11:10:35 -0400
Message-ID: <1ff86f510807160810ib0a01adg4f54cca69a96b623@mail.gmail.com>
Affected files ...
... //depot/perl/ext/threads/t/free.t#10 edit
... //depot/perl/ext/threads/t/free2.t#8 edit
Differences ...
==== //depot/perl/ext/threads/t/free.t#10 (text) ====
Index: perl/ext/threads/t/free.t
--- perl/ext/threads/t/free.t#9~34048~ 2008-06-13 10:09:19.000000000 -0700
+++ perl/ext/threads/t/free.t 2008-07-16 10:03:10.000000000 -0700
@@ -6,10 +6,16 @@
chdir 't';
unshift @INC, '../lib';
}
+
+ # Import test.pl into its own package
+ {
+ package Test;
+ require($ENV{PERL_CORE} ? './test.pl' : './t/test.pl');
+ }
+
use Config;
if (! $Config{'useithreads'}) {
- print("1..0 # SKIP Perl not compiled with 'useithreads'\n");
- exit(0);
+ Test::skip_all(q/Perl not compiled with 'useithreads'/);
}
}
@@ -23,8 +29,7 @@
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
- print("1..0 # SKIP threads::shared not available\n");
- exit(0);
+ Test::skip_all(q/threads::shared not available/);
}
require Thread::Queue;
@@ -33,6 +38,7 @@
print("1..29\n"); ### Number of tests that will be run ###
}
+Test::watchdog(120); # In case we get stuck
my $q = Thread::Queue->new();
my $TEST = 1;
==== //depot/perl/ext/threads/t/free2.t#8 (text) ====
Index: perl/ext/threads/t/free2.t
--- perl/ext/threads/t/free2.t#7~34048~ 2008-06-13 10:09:19.000000000 -0700
+++ perl/ext/threads/t/free2.t 2008-07-16 10:03:10.000000000 -0700
@@ -6,10 +6,16 @@
chdir 't';
unshift @INC, '../lib';
}
+
+ # Import test.pl into its own package
+ {
+ package Test;
+ require($ENV{PERL_CORE} ? './test.pl' : './t/test.pl');
+ }
+
use Config;
if (! $Config{'useithreads'}) {
- print("1..0 # SKIP Perl not compiled with 'useithreads'\n");
- exit(0);
+ Test::skip_all(q/Perl not compiled with 'useithreads'/);
}
}
@@ -23,13 +29,11 @@
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
- print("1..0 # SKIP threads::shared not available\n");
- exit(0);
+ Test::skip_all(q/threads::shared not available/);
}
if (($] < 5.008002) && ($threads::shared::VERSION < 0.92)) {
- print("1..0 # SKIP Needs threads::shared 0.92 or later\n");
- exit(0);
+ Test::skip_all(q/Needs threads::shared 0.92 or later/);
}
require Thread::Queue;
@@ -38,6 +42,7 @@
print("1..78\n"); ### Number of tests that will be run ###
}
+Test::watchdog(60); # In case we get stuck
my $q = Thread::Queue->new();
my $TEST = 1;
@@ -87,8 +92,8 @@
lock(%READY);
# Create next thread
- if ($tid < 17) {
- my $next = 'th' . ($tid+1);
+ if ($tid < 18) {
+ my $next = 'th' . $tid;
my $th = threads->create($next, $q);
} else {
# Last thread signals first
@@ -123,6 +128,7 @@
{
my $q = shift;
my $other = shift;
+ $other++;
my $tid = threads->tid();
$q->enqueue($tid, "Thread $tid signalling $other");
@@ -232,8 +238,8 @@
th_signal($q, $other);
sleep(1);
$q->enqueue(1, "Thread $tid getting return from thread $other");
- my $ret = threads->object($other)->join();
- $q->enqueue($ret == $other, "Thread $tid saw that thread $other returned $ret");
+ my $ret = threads->object($other+1)->join();
+ $q->enqueue($ret == $other+1, "Thread $tid saw that thread $other returned $ret");
th_done($q);
}
@@ -256,8 +262,8 @@
threads->detach();
th_signal($q, $other);
$q->enqueue(1, "Thread $tid getting return from thread $other");
- my $ret = threads->object($other)->join();
- $q->enqueue($ret == $other, "Thread $tid saw that thread $other returned $ret");
+ my $ret = threads->object($other+1)->join();
+ $q->enqueue($ret == $other+1, "Thread $tid saw that thread $other returned $ret");
th_done($q);
}
@@ -282,8 +288,8 @@
th_signal($q, $other);
sleep(1);
$q->enqueue(1, "Thread $tid getting return from thread $other");
- my $ret = threads->object($other)->join();
- $q->enqueue($ret == $other, "Thread $tid saw that thread $other returned $ret");
+ my $ret = threads->object($other+1)->join();
+ $q->enqueue($ret == $other+1, "Thread $tid saw that thread $other returned $ret");
th_done($q);
}
@@ -306,8 +312,8 @@
threads->detach();
th_signal($q, $other);
$q->enqueue(1, "Thread $tid getting return from thread $other");
- my $ret = threads->object($other)->join();
- $q->enqueue($ret == $other, "Thread $tid saw that thread $other returned $ret");
+ my $ret = threads->object($other+1)->join();
+ $q->enqueue($ret == $other+1, "Thread $tid saw that thread $other returned $ret");
th_done($q);
}
End of Patch.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic