This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move Thread::Semaphore from ext/ to dist/
[perl5.git] / ext / threads / t / stack_env.t
1 use strict;
2 use warnings;
3
4 BEGIN {
5     use Config;
6     if (! $Config{'useithreads'}) {
7         print("1..0 # SKIP Perl not compiled with 'useithreads'\n");
8         exit(0);
9     }
10 }
11
12 use ExtUtils::testlib;
13
14 sub ok {
15     my ($id, $ok, $name) = @_;
16
17     # You have to do it this way or VMS will get confused.
18     if ($ok) {
19         print("ok $id - $name\n");
20     } else {
21         print("not ok $id - $name\n");
22         printf("# Failed test at line %d\n", (caller)[2]);
23     }
24
25     return ($ok);
26 }
27
28 BEGIN {
29     $| = 1;
30     print("1..4\n");   ### Number of tests that will be run ###
31
32     $ENV{'PERL5_ITHREADS_STACK_SIZE'} = 128*4096;
33 };
34
35 use threads;
36 ok(1, 1, 'Loaded');
37
38 ### Start of Testing ###
39
40 ok(2, threads->get_stack_size() == 128*4096,
41         '$ENV{PERL5_ITHREADS_STACK_SIZE}');
42 ok(3, threads->set_stack_size(144*4096) == 128*4096,
43         'Set returns previous value');
44 ok(4, threads->get_stack_size() == 144*4096,
45         'Get stack size');
46
47 exit(0);
48
49 # EOF