Commit | Line | Data |
0f1612a7 |
1 | use strict; |
2 | use warnings; |
3 | |
31623e47 |
4 | BEGIN { |
0f1612a7 |
5 | if ($ENV{'PERL_CORE'}){ |
6 | chdir 't'; |
7 | unshift @INC, '../lib'; |
8 | } |
9 | use Config; |
fc04eb16 |
10 | if (! $Config{'useithreads'}) { |
11 | print("1..0 # Skip: Perl not compiled with 'useithreads'\n"); |
12 | exit(0); |
31623e47 |
13 | } |
14 | } |
15 | |
16 | use ExtUtils::testlib; |
0f1612a7 |
17 | |
fc04eb16 |
18 | sub ok { |
31623e47 |
19 | my ($id, $ok, $name) = @_; |
fc04eb16 |
20 | |
31623e47 |
21 | # You have to do it this way or VMS will get confused. |
fc04eb16 |
22 | if ($ok) { |
23 | print("ok $id - $name\n"); |
24 | } else { |
25 | print("not ok $id - $name\n"); |
26 | printf("# Failed test at line %d\n", (caller)[2]); |
27 | } |
31623e47 |
28 | |
fc04eb16 |
29 | return ($ok); |
31623e47 |
30 | } |
31 | |
fc04eb16 |
32 | BEGIN { |
33 | $| = 1; |
34 | print("1..63\n"); ### Number of tests that will be run ### |
35 | }; |
36 | |
37 | use threads; |
38 | ok(1, 1, 'Loaded'); |
31623e47 |
39 | |
fc04eb16 |
40 | ### Start of Testing ### |
31623e47 |
41 | |
42 | sub test9 { |
fc04eb16 |
43 | my $s = "abcd" x (1000 + $_[0]); |
44 | my $t = ''; |
45 | while ($s =~ /(.)/g) { $t .= $1 } |
46 | print "not ok $_[0]\n" if $s ne $t; |
31623e47 |
47 | } |
48 | my @threads; |
fc04eb16 |
49 | for (2..32) { |
50 | ok($_, 1, "Multiple thread test"); |
51 | push(@threads, threads->create('test9',$_)); |
31623e47 |
52 | } |
53 | |
fc04eb16 |
54 | my $i = 33; |
55 | for (@threads) { |
56 | $_->join; |
57 | ok($i++, 1, "Thread joined"); |
31623e47 |
58 | } |
59 | |
fc04eb16 |
60 | # EOF |