9 Test::More::plan(skip_all => $msg);
12 use Config qw<%Config>;
15 my $force = $ENV{PERL_INDIRECT_TEST_THREADS} ? 1 : !1;
16 skipall 'This perl wasn\'t built to support threads'
17 unless $Config{useithreads};
18 skipall 'perl 5.13.4 required to test thread safety'
19 unless $force or $] >= 5.013004;
27 delete $ENV{PERL_INDIRECT_PM_DISABLE};
29 skipall 'This indirect isn\'t thread safe' unless indirect::I_THREADSAFE();
31 defined and diag "Using threads $_" for $threads::VERSION;
37 my $SystemRoot = $ENV{SystemRoot};
39 $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot;
41 system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code;
46 skip 'Fails on 5.8.2 and lower' => 1 if $] <= 5.008002;
48 my $status = run_perl <<' RUN';
49 my ($code, @expected);
54 sub cb { --$code if $_[0] eq shift(@expected) || q{DUMMY} }
56 $code = threads->create(sub {
57 eval q{return; no indirect hook => \&cb; new X;};
61 eval q{return; no indirect hook => \&cb; new Z;};
64 is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';