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