2
# Copyright (C) 2009, Parrot Foundation.
7
use Test::More tests => 22;
8
use lib qw( lib t/configure/testlib );
9
use_ok('config::auto::frames');
10
use Parrot::Configure::Options qw( process_options );
11
use Parrot::Configure::Step::Test;
12
use Parrot::Configure::Test qw(
13
test_step_constructor_and_description
17
my ($args, $step_list_ref) = process_options( {
22
my $conf = Parrot::Configure::Step::Test->new;
23
$conf->include_config_results( $args );
25
my $serialized = $conf->pcfreeze();
27
my $pkg = q{auto::frames};
28
$conf->add_steps($pkg);
29
$conf->options->set( %{$args} );
30
my $step = test_step_constructor_and_description($conf);
32
# To avoid a warning about an unitialized value, we will set nvsize to 8,
33
# cpuarch to i386 and osname to linux.
34
# This is normally done during earlier configuration steps.
35
$conf->data->set( nvsize => 8 );
36
$conf->data->set( cpuarch => 'i386' );
37
$conf->data->set( osname => 'linux' );
39
my $ret = $step->runstep($conf);
40
ok( $ret, "runstep() returned true value" );
41
ok( defined ( $step->result() ),
42
"Got defined result" );
45
'build frames temporarily disabled at pcc_reapply merge: TT #1132';
46
is( $step->result(), 'yes', "Result is 'yes', as expected" );
49
$step->set_result( undef );
51
$conf->replenish($serialized);
53
###### _call_frames_buildable() #####
55
my $can_build_call_frames;
57
$conf->options->set( buildframes => 1 );
58
$can_build_call_frames = auto::frames::_call_frames_buildable($conf);
59
ok( $can_build_call_frames,
60
"_call_frames_buildable() returned true value, as expected" );
62
$conf->options->set( buildframes => 0 );
63
$can_build_call_frames = auto::frames::_call_frames_buildable($conf);
64
ok( ! $can_build_call_frames,
65
"_call_frames_buildable() returned false value, as expected" );
67
$conf->options->set( buildframes => undef );
68
$conf->data->set( osname => 'linux' );
69
$conf->data->set( cpuarch => 'i386' );
70
$conf->data->set( nvsize => 8 );
71
$can_build_call_frames = auto::frames::_call_frames_buildable($conf);
74
'build frames temporarily disabled at pcc_reapply merge: TT #1132';
75
ok( $can_build_call_frames,
76
"_call_frames_buildable() returned true value, as expected (i386/non darwin/8)"
80
$conf->data->set( osname => 'darwin' );
81
$conf->data->set( cpuarch => 'i386' );
82
$conf->data->set( nvsize => 8 );
83
$can_build_call_frames = auto::frames::_call_frames_buildable($conf);
84
ok( ! $can_build_call_frames,
85
"_call_frames_buildable() returned false value, as expected (i386/darwin/8)" );
87
$conf->data->set( osname => 'linux' );
88
$conf->data->set( cpuarch => 'ppc' );
89
$conf->data->set( nvsize => 8 );
90
$can_build_call_frames = auto::frames::_call_frames_buildable($conf);
91
ok( ! $can_build_call_frames,
92
"_call_frames_buildable() returned false value, as expected (ppc/linux/8)" );
94
$conf->data->set( osname => 'linux' );
95
$conf->data->set( cpuarch => 'i386' );
96
$conf->data->set( nvsize => 4 );
97
$can_build_call_frames = auto::frames::_call_frames_buildable($conf);
98
ok( ! $can_build_call_frames,
99
"_call_frames_buildable() returned false value, as expected (i386/linux/4)" );
101
##### _handle_call_frames_buildable() #####
103
$conf->data->set( nvsize => 8 );
104
$conf->data->set( cpuarch => 'i386' );
105
$conf->data->set( osname => 'linux' );
109
$can_build_call_frames = 0;
110
$rv = $step->_handle_can_build_call_frames( $conf, $can_build_call_frames );
111
ok( $rv, "_handle_can_build_call_frames() returned true value" );
112
ok( ! $conf->data->get( 'cc_build_call_frames'),
113
"cc_build_call_frames not set to true, as expected" );
114
ok( ! defined( $conf->data->get( 'has_exec_protect' ) ),
115
"has_exec_protect undefined, as expected" );
116
is( $step->result(), 'no', "Result is 'no', as expected" );
118
$conf->data->set( 'cc_build_call_frames' => undef );
119
$conf->data->set( 'has_exec_protect' => undef );
121
$can_build_call_frames = 1;
122
my $realos = $conf->data->get( 'osname' );
123
$conf->data->set( 'osname' => 'foobar' );
124
$rv = $step->_handle_can_build_call_frames( $conf, $can_build_call_frames );
125
ok( $rv, "_handle_can_build_call_frames() returned true value" );
126
is( $conf->data->get( 'cc_build_call_frames'), '-DCAN_BUILD_CALL_FRAMES',
127
"cc_build_call_frames set to expected value" );
128
is( $conf->data->get( 'has_exec_protect' ), 0,
129
"has_exec_protect is 0, as expected" );
130
is( $step->result(), 'yes', "Result is 'yes', as expected" );
132
$conf->data->set( 'cc_build_call_frames' => undef );
133
$conf->data->set( 'has_exec_protect' => undef );
134
$conf->data->set( 'osname' => $realos );
136
pass("Completed all tests in $0");
138
################### DOCUMENTATION ###################
142
auto/frames-01.t - test auto::frames
146
% prove t/steps/auto/frames-01.t
150
The files in this directory test functionality used by F<Configure.pl>.
152
The tests in this file test auto::frames.
156
Daniel Arbelo Arrocha
160
config::auto::frames, F<Configure.pl>.
166
# cperl-indent-level: 4
169
# vim: expandtab shiftwidth=4: