The patch proposes to split Parrot configuration step auto::jit into two steps, auto::arch and auto::jit.
The rationale for this patch is that currently config/auto/jit.pm has, in its runstep() method, two distinct tasks: determining the CPU architecture and the operating system on the one hand; and determining the JIT capabilities of the system on the other. It is relatively easy to write tests for the first task, but is considerably more difficult to write tests for the second. So if we split the step in two we can achieve high coverage of the first while we figure out a way to test the second. 'arch.jit.01.txt' contains the changes to currently existing files. 'arch.pm' will become config/auto/arch.pm. 11 test files test various aspects of auto::arch. Currently there is little test coverage of the JIT capabilities in t/configure/132-auto_jit-01.t, so we're not going backwards on that. If you wish to review this it may be easier to checkout the 'archjit' branch from our SVN repository. Thank you very much. kid51
132-auto_arch-01.t
Description: Binary data
132-auto_arch-09.t
Description: Binary data
132-auto_arch-10.t
Description: Binary data
132-auto_arch-02.t
Description: Binary data
132-auto_arch-06.t
Description: Binary data
# Copyright (C) 2001-2007, The Perl Foundation. # $Id: arch.pm 22835 2007-11-15 13:14:30Z jkeenan $ =head1 NAME config/auto/arch - Determine CPU architecture and operating system =head1 DESCRIPTION Determines the CPU architecture, the operating system. =cut package auto::arch; use strict; use warnings; use base qw(Parrot::Configure::Step::Base); use Parrot::Configure::Step; sub _init { my $self = shift; my %data; $data{description} = q{Determining CPU architecture and OS}; $data{args} = [ ]; $data{result} = q{}; return \%data; } sub runstep { my ( $self, $conf ) = @_; if ( $conf->options->get('miniparrot') ) { $self->set_result('skipped'); return 1; } my $verbose = $conf->options->get('verbose'); $verbose and print "\n"; my $archname = $conf->data->get('archname'); my ( $cpuarch, $osname ) = split( /-/, $archname ); if ($verbose) { print "determining operating system and cpu architecture\n"; print "archname: <$archname>\n"; } if ( !defined $osname ) { ( $osname, $cpuarch ) = ( $cpuarch, q{} ); } # This was added to convert 9000/800 to 9000_800 on HP-UX $cpuarch =~ s|/|_|g; # On OS X if you are using the Perl that shipped with the system # the above split fails because archname is "darwin-thread-multi-2level". if ( $cpuarch =~ /darwin/ ) { $osname = 'darwin'; if ( $conf->data->get('byteorder') == 1234 ) { $cpuarch = 'i386'; } else { $cpuarch = 'ppc'; } } # cpuarch and osname are reversed in archname on windows elsif ( $cpuarch =~ /MSWin32/ ) { $cpuarch = ( $osname =~ /x64/ ) ? 'amd64' : 'i386'; $osname = 'MSWin32'; } elsif ( $osname =~ /cygwin/i || $cpuarch =~ /cygwin/i ) { $cpuarch = 'i386'; $osname = 'cygwin'; } if ( $archname =~ m/powerpc/ ) { $cpuarch = 'ppc'; } $cpuarch =~ s/armv[34]l?/arm/i; $cpuarch =~ s/i[456]86/i386/i; $cpuarch =~ s/x86_64/amd64/i; print "osname: $osname\ncpuarch: $cpuarch\n" if $verbose; $conf->data->set( cpuarch => $cpuarch, osname => $osname ); return 1; } 1; # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 100 # End: # vim: expandtab shiftwidth=4:
132-auto_arch-03.t
Description: Binary data
132-auto_arch-05.t
Description: Binary data
132-auto_arch-11.t
Description: Binary data
132-auto_arch-08.t
Description: Binary data
132-auto_arch-07.t
Description: Binary data
Index: MANIFEST =================================================================== --- MANIFEST (revision 24187) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Mon Dec 24 12:47:34 2007 UT +# generated by tools/dev/mk_manifest_and_skip.pl Mon Dec 24 16:40:48 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -203,6 +203,7 @@ config/auto/aio/aio.in [] config/auto/alignptrs.pm [] config/auto/alignptrs/test_c.in [] +config/auto/arch.pm [] config/auto/attributes.pm [] config/auto/attributes/test_c.in [] config/auto/backtrace.pm [] @@ -3185,6 +3186,17 @@ t/configure/131-auto_isreg-01.t [] t/configure/131-auto_isreg-02.t [] t/configure/131-auto_isreg-03.t [] +t/configure/132-auto_arch-01.t [] +t/configure/132-auto_arch-02.t [] +t/configure/132-auto_arch-03.t [] +t/configure/132-auto_arch-04.t [] +t/configure/132-auto_arch-05.t [] +t/configure/132-auto_arch-06.t [] +t/configure/132-auto_arch-07.t [] +t/configure/132-auto_arch-08.t [] +t/configure/132-auto_arch-09.t [] +t/configure/132-auto_arch-10.t [] +t/configure/132-auto_arch-11.t [] t/configure/132-auto_jit-01.t [] t/configure/133-gen_cpu.t [] t/configure/134-auto_funcptr.t [] Index: lib/Parrot/Configure/Step/List.pm =================================================================== --- lib/Parrot/Configure/Step/List.pm (revision 24187) +++ lib/Parrot/Configure/Step/List.pm (working copy) @@ -39,6 +39,7 @@ auto::pack auto::format auto::isreg + auto::arch auto::jit gen::cpu auto::funcptr Index: t/configure/132-auto_jit-01.t =================================================================== --- t/configure/132-auto_jit-01.t (revision 24187) +++ t/configure/132-auto_jit-01.t (working copy) @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 13; use Carp; use lib qw( lib t/configure/testlib ); use_ok('config::init::defaults'); @@ -14,14 +14,6 @@ use Parrot::Configure::Options qw( process_options ); use Parrot::Configure::Test qw( test_step_thru_runstep); -=for hints_for_testing Check latest reports of Parrot configuration -tools testing coverage to see where your time available for writing -tests is spent. You will have to determine a way to test a user -response to a prompt. In the course of writing tests, you should try -to resolve RT 43146. - -=cut - my $args = process_options( { argv => [ q{--miniparrot} ], @@ -39,7 +31,7 @@ $conf->options->set( %{$args} ); my ( $task, $step_name, $step); -$task = $conf->steps->[1]; +$task = $conf->steps->[-1]; $step_name = $task->step; $step = $step_name->new(); @@ -51,7 +43,7 @@ ok( $ret, "$step_name runstep() returned true value" ); is($step->result(), q{skipped}, "Expected result was set"); - +pass("Keep Devel::Cover happy"); pass("Completed all tests in $0"); ################### DOCUMENTATION ################### @@ -68,7 +60,8 @@ The files in this directory test functionality used by F<Configure.pl>. -The tests in this file test subroutines exported by config::auto::jit. +The tests in this file tests config::auto::jit with the C<--miniparrot> +option. =head1 AUTHOR Index: config/auto/jit.pm =================================================================== --- config/auto/jit.pm (revision 24187) +++ config/auto/jit.pm (working copy) @@ -7,10 +7,10 @@ =head1 DESCRIPTION -Determines the CPU architecture, the operating system, and whether there is JIT -capability available. Use the C<--jitcapable> and C<--execcapable> options to -override the default value calculated specifically for your CPU architecture -and operating system. +Determines whether there is JIT capability available. Use the +C<--jitcapable> and C<--execcapable> options to override the default +value calculated specifically for your CPU architecture and operating +system. =cut @@ -30,6 +30,10 @@ $data{description} = q{Determining architecture, OS and JIT capability}; $data{args} = [ qw( jitcapable miniparrot execcapable verbose ) ]; $data{result} = q{}; + $data{jit_is_working} = { + i386 => 1, + ppc => 1, + }; return \%data; } @@ -44,80 +48,26 @@ my $verbose = $conf->options->get('verbose'); $verbose and print "\n"; - my $jitbase = 'src/jit'; # base path for jit sources - my $archname = $conf->data->get('archname'); - my ( $cpuarch, $osname ) = split( /-/, $archname ); + my $cpuarch = $conf->data->get('cpuarch'); + my $osname = $conf->data->get('osname'); - if ($verbose) { - print "determining operating system and cpu architecture\n"; - print "archname: <$archname>\n"; - } + my $jitbase = 'src/jit'; # base path for jit sources - if ( !defined $osname ) { - ( $osname, $cpuarch ) = ( $cpuarch, q{} ); - } - - # This was added to convert 9000/800 to 9000_800 on HP-UX - $cpuarch =~ s|/|_|g; - - # On OS X if you are using the Perl that shipped with the system - # the above split fails because archname is "darwin-thread-multi-2level". - if ( $cpuarch =~ /darwin/ ) { - $osname = 'darwin'; - if ( $conf->data->get('byteorder') == 1234 ) { - $cpuarch = 'i386'; - } - else { - $cpuarch = 'ppc'; - } - } - - # cpuarch and osname are reversed in archname on windows - elsif ( $cpuarch =~ /MSWin32/ ) { - $cpuarch = ( $osname =~ /x64/ ) ? 'amd64' : 'i386'; - $osname = 'MSWin32'; - } - elsif ( $osname =~ /cygwin/i || $cpuarch =~ /cygwin/i ) { - $cpuarch = 'i386'; - $osname = 'cygwin'; - } - - if ( $archname =~ m/powerpc/ ) { - $cpuarch = 'ppc'; - } - - $cpuarch =~ s/armv[34]l?/arm/i; - $cpuarch =~ s/i[456]86/i386/i; - $cpuarch =~ s/x86_64/amd64/i; - - warn "osname: $osname\ncpuarch: $cpuarch\n" if $verbose; - - $conf->data->set( - archname => $archname, - cpuarch => $cpuarch, - osname => $osname - ); - - my $jitarchname = "$cpuarch-$osname"; - my ( $jitcapable, $execcapable ) = ( 0, 0 ); - - print( qq{-e "$jitbase/$cpuarch/core.jit" = }, - -e "$jitbase/$cpuarch/core.jit" ? 'yes' : 'no', "\n" ) + my $corejit = "$jitbase/$cpuarch/core.jit"; + print( qq{-e $corejit = }, + -e $corejit ? 'yes' : 'no', "\n" ) if $verbose; - if ( -e "$jitbase/$cpuarch/core.jit" ) { + my $jitcapable = 0; + if ( -e $corejit ) { # Just because there is a "$jitbase/$cpuarch/core.jit" file, # doesn't mean the JIT is working on that platform. # So build JIT per default only on platforms where JIT in known # to work. Building JIT on other platform most likely breaks the build. # Developer can always call: Configure.pl --jitcapable - # See also RT#43145 - my %jit_is_working = ( - i386 => 1, - ppc => 1, - ); - if ( $jit_is_working{$cpuarch} ) { + # This was discussed in RT #43145 (which has been resolved). + if ( $self->{jit_is_working}->{$cpuarch} ) { $jitcapable = 1; } @@ -127,12 +77,15 @@ } } - if ( -e "$jitbase/$cpuarch/$jitarchname.s" ) { - copy_if_diff( "$jitbase/$cpuarch/$jitarchname.s", "src/asmfun.s" ); + my $jitarchname = "$cpuarch-$osname"; + my $sjit = "$jitbase/$cpuarch/$jitarchname.s"; + my $asm = "$jitbase/$cpuarch/asm.s"; + if ( -e $sjit ) { + copy_if_diff( $sjit, "src/asmfun.s" ); $conf->data->set( asmfun_o => 'src/asmfun$(O)' ); } - elsif ( -e "$jitbase/$cpuarch/asm.s" ) { - copy_if_diff( "$jitbase/$cpuarch/asm.s", "src/asmfun.s" ); + elsif ( -e $asm ) { + copy_if_diff( $asm, "src/asmfun.s" ); $conf->data->set( asmfun_o => 'src/asmfun$(O)' ); } else { @@ -157,10 +110,12 @@ '$(SRC_DIR)/jit$(O) $(SRC_DIR)/jit_cpu$(O) $(SRC_DIR)/jit_debug$(O) $(SRC_DIR)/jit_debug_xcoff$(O)' ); + my $execcapable = 0; if ( ( $jitcpuarch eq 'i386' ) || ( $jitcpuarch eq 'ppc' ) || ( $jitcpuarch eq 'arm' ) ) { +# if ( $jitcpuarch =~ /^(i386|ppc|arm)$/ ) { $execcapable = 1; unless ( ( $osname eq 'openbsd' ) || ( $osname eq 'freebsd' )
132-auto_arch-04.t
Description: Binary data