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