Commit | Line | Data |
514612b7 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | BEGIN { |
5 | if ($ENV{'PERL_CORE'}){ |
6 | chdir 't'; |
7 | unshift @INC, '../lib'; |
8 | } |
9 | use Config; |
10 | if (! $Config{'useithreads'}) { |
11 | print("1..0 # Skip: Perl not compiled with 'useithreads'\n"); |
12 | exit(0); |
13 | } |
14 | } |
15 | |
16 | use ExtUtils::testlib; |
17 | |
18 | sub ok { |
19 | my ($id, $ok, $name) = @_; |
20 | |
21 | # You have to do it this way or VMS will get confused. |
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 | } |
28 | |
29 | return ($ok); |
30 | } |
31 | |
32 | BEGIN { |
33 | $| = 1; |
34 | print("1..18\n"); ### Number of tests that will be run ### |
35 | }; |
36 | |
37 | use threads 1.09 ('stack_size' => 32*4096); |
38 | ok(1, 1, 'Loaded'); |
39 | |
40 | ### Start of Testing ### |
41 | |
42 | ok(2, threads->get_stack_size() == 32*4096, |
43 | 'Stack size set in import'); |
44 | ok(3, threads->set_stack_size(64*4096) == 32*4096, |
45 | 'Set returns previous value'); |
46 | ok(4, threads->get_stack_size() == 64*4096, |
47 | 'Get stack size'); |
48 | |
49 | threads->create( |
50 | sub { |
51 | ok(5, threads->get_stack_size() == 64*4096, |
52 | 'Get stack size in thread'); |
53 | ok(6, threads->self()->get_stack_size() == 64*4096, |
54 | 'Thread gets own stack size'); |
55 | ok(7, threads->set_stack_size(32*4096) == 64*4096, |
56 | 'Thread changes stack size'); |
57 | ok(8, threads->get_stack_size() == 32*4096, |
58 | 'Get stack size in thread'); |
59 | ok(9, threads->self()->get_stack_size() == 64*4096, |
60 | 'Thread stack size unchanged'); |
61 | } |
62 | )->join(); |
63 | |
64 | ok(10, threads->get_stack_size() == 32*4096, |
65 | 'Default thread sized changed in thread'); |
66 | |
67 | threads->create( |
68 | { 'stack' => 64*4096 }, |
69 | sub { |
70 | ok(11, threads->get_stack_size() == 32*4096, |
71 | 'Get stack size in thread'); |
72 | ok(12, threads->self()->get_stack_size() == 64*4096, |
73 | 'Thread gets own stack size'); |
74 | } |
75 | )->join(); |
76 | |
77 | my $thr = threads->create( { 'stack' => 64*4096 }, sub { } ); |
78 | |
79 | $thr->create( |
80 | sub { |
81 | ok(13, threads->get_stack_size() == 32*4096, |
82 | 'Get stack size in thread'); |
83 | ok(14, threads->self()->get_stack_size() == 64*4096, |
84 | 'Thread gets own stack size'); |
85 | } |
86 | )->join(); |
87 | |
88 | $thr->create( |
89 | { 'stack' => 48*4096 }, |
90 | sub { |
91 | ok(15, threads->get_stack_size() == 32*4096, |
92 | 'Get stack size in thread'); |
93 | ok(16, threads->self()->get_stack_size() == 48*4096, |
94 | 'Thread gets own stack size'); |
95 | ok(17, threads->set_stack_size(64*4096) == 32*4096, |
96 | 'Thread changes stack size'); |
97 | } |
98 | )->join(); |
99 | |
100 | $thr->join(); |
101 | |
102 | ok(18, threads->get_stack_size() == 64*4096, |
103 | 'Default thread sized changed in thread'); |
104 | |
105 | # EOF |