Commit | Line | Data |
24538b08 |
1 | use Config; |
2 | BEGIN { |
3 | unless ($Config{useithreads}) { |
4 | print "1..0 # SKIP your perl does not support ithreads\n"; |
5 | exit 0; |
6 | } |
7 | } |
8 | |
9 | use threads; |
10 | use threads::shared; |
11 | |
12 | use strict; |
13 | use warnings; |
14 | no warnings 'once'; |
15 | use Time::HiRes 'sleep'; |
16 | |
17 | $|++; # seems to be critical |
18 | |
19 | share $::TEST_COUNT; |
20 | |
21 | # older perls crash if threads are spawned way too quickly, sleep for 100 msecs |
e38f7884 |
22 | my @pool = map { sleep 0.1 and threads->create(\&run_torture) } (1..($ENV{AUTOMATED_TESTING} ? 20 : 5) ); |
c1ec81b5 |
23 | |
24 | # again - necessary for older perls |
25 | sleep 1; |
26 | |
e38f7884 |
27 | for (@pool) { |
28 | if ($_->join != 42) { |
29 | die ($_->can('error') ? $_->error : "Thread did not finish successfully" ); |
30 | } |
31 | } |
24538b08 |
32 | |
33 | if ($ENV{AUTOMATED_TESTING}) { |
34 | my $vsz; |
35 | if (-f "/proc/$$/stat") { |
36 | my $proc_stat = do { local (@ARGV, $/) = "/proc/$$/stat"; <> }; |
37 | ($vsz) = map { $_ / 1024 } |
38 | (split (/\s+/, $proc_stat))[-22]; # go backwards because the %s of the procname can contain anything |
39 | } |
40 | |
41 | printf STDERR "#\n# VSIZE:%dKiB\n", $vsz |
42 | if $vsz; |
43 | } |
44 | |
45 | print "1..$::TEST_COUNT\n"; |
46 | |
47 | sub run_torture { |
e38f7884 |
48 | do 't/03torture.t'; |
24538b08 |
49 | die $@ if $@ ne ''; |
e38f7884 |
50 | 42; |
24538b08 |
51 | } |