blob: 592b8d350e40659c8190eb21f942b01edf81a131 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
use strict;
use warnings;
BEGIN {
require($ENV{PERL_CORE} ? '../../t/test.pl' : './t/test.pl');
use Config;
if (! $Config{'useithreads'}) {
skip_all(q/Perl not compiled with 'useithreads'/);
}
# Guard against bugs that result in deadlock
watchdog(1 * 60);
plan(11);
}
use ExtUtils::testlib;
use_ok('threads');
### Start of Testing ###
my $i = 10;
my $y = 20000;
my %localtime;
for (1..$i) {
$localtime{$_} = localtime($_);
};
my @threads;
for (1..$i) {
$threads[$_] = threads->create(sub {
my $arg = shift;
my $localtime = $localtime{$arg};
my $error = 0;
for (1..$y) {
my $lt = localtime($arg);
if ($localtime ne $lt) {
$error++;
}
}
return $error;
}, $_);
}
for (1..$i) {
is($threads[$_]->join(), 0, 'localtime() thread-safe');
}
exit(0);
# EOF
|