xref: /openbsd/gnu/usr.bin/perl/t/thread_it.pl (revision 73471bf0)
1#!perl
2use strict;
3use warnings;
4
5# As perlfunc.pod says:
6# Note that the file will not be included twice under the same specified name.
7# So ensure that this, textually, is the same name as all the loaded tests use.
8# Otherwise if we require 'test.pl' and they require './test.pl', it is loaded
9# twice.
10require './test.pl';
11skip_all_without_config('useithreads');
12skip_all_if_miniperl("no dynamic loading on miniperl, no threads");
13
14require threads;
15
16# Which file called us?
17my $caller = (caller)[1];
18
19die "Can't figure out which test to run from filename '$caller'"
20    unless $caller =~ m!((?:op|re)/[-_a-z0-9A-Z]+)_thr\.t\z!;
21
22my $file = "./$1.t";
23
24$::running_as_thread = "running tests in a new thread";
25require $file;
26
27note('running tests in a new thread');
28
29# Currently 59*4096 is the minimum stack size to just get t/re/pat_thr.t to
30# pass on HP-UX 64bit PA-RISC. The test for capture buffers (eg \87)
31# recurses heavily, and busts the default stack size (65536 on PA-RISC)
32# On Mac OS X under gcc and g++, the default stack size is also too small.
33# Ditto on VMS, although threshold varies by platform and -Dusevmsdebug.
34# Same on AIX
35my $curr = threads->create({
36                            stack_size => $^O eq 'hpux'   ? 524288 :
37                                          $^O eq 'darwin' ? 2000000:
38                                          $^O eq 'VMS'    ? 150000 :
39                                          $^O eq 'aix'    ? 1500000 : 0,
40                           }, sub {
41			       run_tests();
42			       return defined &curr_test ? curr_test() : ()
43			   })->join();
44
45curr_test($curr) if defined $curr;
46
471;
48