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'/);
}
}
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;
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;
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'/);
}
}
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;
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;
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
{
my $q = shift;
my $other = shift;
+ $other++;
my $tid = threads->tid();
$q->enqueue($tid, "Thread $tid signalling $other");
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);
}
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);
}
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);
}
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);
}