2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 27;
11 use File::Temp qw(tempdir);
12 use lib qw( lib t/configure/testlib );
13 use_ok('config::auto::signal');
14 use Parrot::Configure::Options qw( process_options );
15 use Parrot::Configure::Step::Test;
16 use Parrot::Configure::Test qw(
17 test_step_constructor_and_description
19 use IO::CaptureOutput qw| capture |;
21 ########### _handle__sighandler_t() ###########
23 my ($args, $step_list_ref) = process_options( {
28 my $conf = Parrot::Configure::Step::Test->new;
29 $conf->include_config_results( $args );
31 my $serialized = $conf->pcfreeze();
33 my $pkg = q{auto::signal};
35 $conf->add_steps($pkg);
36 $conf->options->set( %{$args} );
37 my $step = test_step_constructor_and_description($conf);
39 ok(auto::signal::_handle__sighandler_t($conf),
40 "_handle__sighandler_t() returned true value");
41 is($conf->data->get( 'has___sighandler_t'), 'define',
42 "Got expected value for has__sighandler_t");
44 ########### _handle_sigaction() ###########
46 ok(auto::signal::_handle_sigaction($conf),
47 "_handle_sigaction() returned true value");
48 is($conf->data->get( 'has_sigaction'), 'define',
49 "Got expected value for has_sigaction");
51 ########### _handle_setitimer() ###########
53 ok(auto::signal::_handle_setitimer($conf),
54 "_handle_setitimer() returned true value");
55 is($conf->data->get( 'has_setitimer'), 'define',
56 "Got expected value for has_setitimer");
57 is($conf->data->get( 'has_sig_atomic_t'), 'define',
58 "Got expected value for has_sig_atomic_t");
60 ########### _print_signalpasm() ###########
64 my $tdir = tempdir( CLEANUP => 1);
65 chdir $tdir or croak "Unable to change to $tdir";
66 my $signalpasm = q{signal.pasm};
67 ok(auto::signal::_print_signalpasm($conf, $signalpasm),
68 "_print_signalpasm returned true value");
69 ok(-s $signalpasm, "File with nonzero size created");
70 unlink $signalpasm or croak "Unable to delete file after testing";
71 chdir $cwd or croak "Unable to change back to $cwd";
74 $conf->replenish($serialized);
76 ########### --verbose; _handle__sighandler_t() ###########
78 ($args, $step_list_ref) = process_options( {
79 argv => [ q{--verbose} ],
83 $conf->add_steps($pkg);
84 $conf->options->set( %{$args} );
85 $step = test_step_constructor_and_description($conf);
91 sub { $rv = auto::signal::_handle__sighandler_t($conf, $verbose); },
94 ok($rv, "_handle__sighandler_t() returned true value");
95 is($conf->data->get( 'has___sighandler_t'), 'define',
96 "Got expected value for has__sighandler_t");
97 like($stdout, qr/__sighandler_t/, "Got expected verbose output");
100 ########### --verbose; _handle_sigaction() ###########
105 sub { $rv = auto::signal::_handle_sigaction($conf, $verbose); },
108 ok($rv, "_handle_sigaction() returned true value");
109 is($conf->data->get( 'has_sigaction'), 'define',
110 "Got expected value for has_sigaction");
111 like($stdout, qr/sigaction/, "Got expected verbose output");
114 ########### --verbose; _handle_setitimer() ###########
119 sub { $rv = auto::signal::_handle_setitimer($conf, $verbose); },
122 ok($rv, "_handle_setitimer() returned true value");
123 is($conf->data->get( 'has_setitimer'), 'define',
124 "Got expected value for has_setitimer");
125 is($conf->data->get( 'has_sig_atomic_t'), 'define',
126 "Got expected value for has_sig_atomic_t");
127 like($stdout, qr/setitimer/s, "Got expected verbose output");
132 pass("Completed all tests in $0");
134 ################### DOCUMENTATION ###################
138 auto/signal-01.t - test auto::signal
142 % prove t/steps/auto/signal-01.t
146 The files in this directory test functionality used by F<Configure.pl>.
148 The tests in this file test auto::signal.
156 config::auto::signal, F<Configure.pl>.
162 # cperl-indent-level: 4
165 # vim: expandtab shiftwidth=4: