As we're not passing over (or copying in) a NUL, don't need that extra
[p5sagit/p5-mst-13.2.git] / ext / threads / t / stress_cv.t
CommitLineData
0f1612a7 1use strict;
2use warnings;
3
3dbf27b4 4BEGIN {
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);
3dbf27b4 13 }
14}
15
16use ExtUtils::testlib;
0f1612a7 17
fc04eb16 18sub ok {
3dbf27b4 19 my ($id, $ok, $name) = @_;
fc04eb16 20
3dbf27b4 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 }
3dbf27b4 28
fc04eb16 29 return ($ok);
3dbf27b4 30}
31
fc04eb16 32BEGIN {
33 $| = 1;
34 print("1..63\n"); ### Number of tests that will be run ###
35};
3dbf27b4 36
fc04eb16 37use threads;
38ok(1, 1, 'Loaded');
3dbf27b4 39
fc04eb16 40### Start of Testing ###
3dbf27b4 41
42my @threads;
fc04eb16 43for (2..32) {
44 ok($_, 1, "Multiple thread test");
45 push(@threads , threads->create(sub {
46 my $i = shift;
47 for (1..500000) { $i++ }
48 }, $_));
3dbf27b4 49}
50
fc04eb16 51my $i = 33;
52for (@threads) {
53 $_->join;
54 ok($i++, 1 ,"Thread joined");
3dbf27b4 55}
56
fc04eb16 57# EOF