2 # Copyright (C) 2009, Parrot Foundation.
8 use Test::More tests => 22;
9 use lib qw( lib t/configure/testlib );
10 use_ok('config::auto::frames');
11 use Parrot::Configure::Options qw( process_options );
12 use Parrot::Configure::Step::Test;
13 use Parrot::Configure::Test qw(
14 test_step_constructor_and_description
18 my ($args, $step_list_ref) = process_options( {
23 my $conf = Parrot::Configure::Step::Test->new;
24 $conf->include_config_results( $args );
26 my $serialized = $conf->pcfreeze();
28 my $pkg = q{auto::frames};
29 $conf->add_steps($pkg);
30 $conf->options->set( %{$args} );
31 my $step = test_step_constructor_and_description($conf);
33 # To avoid a warning about an unitialized value, we will set nvsize to 8,
34 # cpuarch to i386 and osname to linux.
35 # This is normally done during earlier configuration steps.
36 $conf->data->set( nvsize => 8 );
37 $conf->data->set( cpuarch => 'i386' );
38 $conf->data->set( osname => 'linux' );
40 my $ret = $step->runstep($conf);
41 ok( $ret, "runstep() returned true value" );
42 ok( defined ( $step->result() ),
43 "Got defined result" );
46 'build frames temporarily disabled at pcc_reapply merge: TT #1132';
47 is( $step->result(), 'yes', "Result is 'yes', as expected" );
50 $step->set_result( undef );
52 $conf->replenish($serialized);
54 ###### _call_frames_buildable() #####
56 my $can_build_call_frames;
58 $conf->options->set( buildframes => 1 );
59 $can_build_call_frames = auto::frames::_call_frames_buildable($conf);
60 ok( $can_build_call_frames,
61 "_call_frames_buildable() returned true value, as expected" );
63 $conf->options->set( buildframes => 0 );
64 $can_build_call_frames = auto::frames::_call_frames_buildable($conf);
65 ok( ! $can_build_call_frames,
66 "_call_frames_buildable() returned false value, as expected" );
68 $conf->options->set( buildframes => undef );
69 $conf->data->set( osname => 'linux' );
70 $conf->data->set( cpuarch => 'i386' );
71 $conf->data->set( nvsize => 8 );
72 $can_build_call_frames = auto::frames::_call_frames_buildable($conf);
75 'build frames temporarily disabled at pcc_reapply merge: TT #1132';
76 ok( $can_build_call_frames,
77 "_call_frames_buildable() returned true value, as expected (i386/non darwin/8)"
81 $conf->data->set( osname => 'darwin' );
82 $conf->data->set( cpuarch => 'i386' );
83 $conf->data->set( nvsize => 8 );
84 $can_build_call_frames = auto::frames::_call_frames_buildable($conf);
85 ok( ! $can_build_call_frames,
86 "_call_frames_buildable() returned false value, as expected (i386/darwin/8)" );
88 $conf->data->set( osname => 'linux' );
89 $conf->data->set( cpuarch => 'ppc' );
90 $conf->data->set( nvsize => 8 );
91 $can_build_call_frames = auto::frames::_call_frames_buildable($conf);
92 ok( ! $can_build_call_frames,
93 "_call_frames_buildable() returned false value, as expected (ppc/linux/8)" );
95 $conf->data->set( osname => 'linux' );
96 $conf->data->set( cpuarch => 'i386' );
97 $conf->data->set( nvsize => 4 );
98 $can_build_call_frames = auto::frames::_call_frames_buildable($conf);
99 ok( ! $can_build_call_frames,
100 "_call_frames_buildable() returned false value, as expected (i386/linux/4)" );
102 ##### _handle_call_frames_buildable() #####
104 $conf->data->set( nvsize => 8 );
105 $conf->data->set( cpuarch => 'i386' );
106 $conf->data->set( osname => 'linux' );
110 $can_build_call_frames = 0;
111 $rv = $step->_handle_can_build_call_frames( $conf, $can_build_call_frames );
112 ok( $rv, "_handle_can_build_call_frames() returned true value" );
113 ok( ! $conf->data->get( 'cc_build_call_frames'),
114 "cc_build_call_frames not set to true, as expected" );
115 ok( ! defined( $conf->data->get( 'has_exec_protect' ) ),
116 "has_exec_protect undefined, as expected" );
117 is( $step->result(), 'no', "Result is 'no', as expected" );
119 $conf->data->set( 'cc_build_call_frames' => undef );
120 $conf->data->set( 'has_exec_protect' => undef );
122 $can_build_call_frames = 1;
123 my $realos = $conf->data->get( 'osname' );
124 $conf->data->set( 'osname' => 'foobar' );
125 $rv = $step->_handle_can_build_call_frames( $conf, $can_build_call_frames );
126 ok( $rv, "_handle_can_build_call_frames() returned true value" );
127 is( $conf->data->get( 'cc_build_call_frames'), '-DCAN_BUILD_CALL_FRAMES',
128 "cc_build_call_frames set to expected value" );
129 is( $conf->data->get( 'has_exec_protect' ), 0,
130 "has_exec_protect is 0, as expected" );
131 is( $step->result(), 'yes', "Result is 'yes', as expected" );
133 $conf->data->set( 'cc_build_call_frames' => undef );
134 $conf->data->set( 'has_exec_protect' => undef );
135 $conf->data->set( 'osname' => $realos );
137 pass("Completed all tests in $0");
139 ################### DOCUMENTATION ###################
143 auto/frames-01.t - test auto::frames
147 % prove t/steps/auto/frames-01.t
151 The files in this directory test functionality used by F<Configure.pl>.
153 The tests in this file test auto::frames.
157 Daniel Arbelo Arrocha
161 config::auto::frames, F<Configure.pl>.
167 # cperl-indent-level: 4
170 # vim: expandtab shiftwidth=4: