2 # Copyright (C) 2005-2006, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
10 use vars qw($EXT $DIR @shootouts);
12 # find dynamically all shootouts from dir listing
13 BEGIN { # to be run before declaring the number of tests
15 $DIR = "examples/shootout";
16 opendir( DIR, $DIR ) or die "can't opendir $DIR: $!";
17 @shootouts = grep { -e "$DIR/$_$EXT" } sort grep { /\.pir$/ } readdir(DIR);
21 use Parrot::Test tests => scalar(@shootouts);
25 t/examples/shootout.t - Test the shootout examples in "examples/shootout/*.pir".
29 % prove t/examples/shootout.t
33 Test the PIR shootout examples in 'examples/shootout/*.pir'.
35 To add a new test, you do not have to modify this script:
37 1. add your script (toto.pir) to examples/shootout
38 2. put parrot options in the first line (e.g "#!./parrot -Oc -Cj")
39 3. make sure you have default argument values
40 4. put the expected output as a file : toto.pir_output
41 5. if you need an input file (to be read from stdin), call it toto.pir_input
43 See the explanation of benchmarks and sample data for reduced N benches at
44 http://shootout.alioth.debian.org/sandbox/
48 #40064: [TODO] shootout example testing in Parrot RT
50 L<"https://rt.perl.org/rt3/Public/Bug/Display.html?id=40064">
55 'pidigits.pir' => [ 'not exists $PConfig{HAS_GMP}', 'needs GMP' ],
56 'recursive.pir' => [ '$PConfig{cpuarch} !~ /86/', 'float JIT broken on non-x86' ],
57 'recursive-2.pir' => [ '$PConfig{cpuarch} !~ /86/', 'float JIT broken on non-x86' ],
58 'fannkuch.pir' => [ '$^O eq "darwin"', 'fannkuch benchmark failure on darwin' ],
60 my $INPUT_EXT = '_input';
61 foreach my $script (@shootouts) {
62 my $skip = $skips{$script};
64 my ( $cond, $reason ) = @{$skip};
66 Test::More->builder->skip("$script $reason");
70 my $file = "$DIR/$script";
73 open( my $FILE, '<', $file ) or die "unable to open file [$file] : $!";
74 my $shebang = <$FILE>;
76 my $expected = slurp_file("$file$EXT");
79 if ( $shebang =~ /^\#.+parrot\s+(.+)$/ ) {
80 $args = $1; # parrot options
82 unless ( $PConfig{jitcapable} ) {
86 unless ( $PConfig{cg_flag} =~ /HAVE/ ) {
89 # Remove any plain -C option.
90 $args =~ s/(^|\s)-C(\s|$)/$1$2/;
92 # Remove any extra Cs still floating around
96 # look for input files
97 my $input = "$file$INPUT_EXT";
99 $args .= " < $input ";
102 $ENV{TEST_PROG_ARGS} = $args;
103 warn "$file $args\n" if $ENV{TEST_VERBOSE};
106 # this is an example of todo syntax
107 # @todo = ( todo => 'known GC segfault' ) if $file =~ /regexdna.pir/;
108 example_output_is( $file, $expected, @todo );
113 # cperl-indent-level: 4
116 # vim: expandtab shiftwidth=4: