The following test fails with perl 5.14.2 and B::C 1.42 on x86_64/
Ubuntu 12.04.
# vim:set sw=4 ts=4 et ai smartindent fileformat=unix
fileencoding=utf-8 syntax=perl:
use Test::More tests => 7;
use B::C;
use File::Temp;
use File::Slurp qw(write_file);
use File::Spec;
my ($plvol,$pldir,$plbin) = File::Spec->splitpath($^X);
my $cc_harness_bin = File::Spec->catpath($plvol,$pldir,'cc_harness');
ok(-e $cc_harness_bin, 'cc_harness found');
my $tempdir = File::Temp->newdir;
my ($tvol,$tdir,$tfile) = File::Spec->splitpath($tempdir,1);
my $plsrcfn = File::Spec->catpath($tvol,$tdir,'
test.pl');
my $cfn = File::Spec->catpath($tvol,$tdir,'test.c');
my $binfn = File::Spec->catpath($tvol,$tdir,'test');
write_file($plsrcfn, <<"EOF");
#!$^X
exit 123;
EOF
ok(system($^X, '-MO=C,-o'.$cfn, $plsrcfn)==0, 'C code generation');
ok(system($^X, $cc_harness_bin, '-o', $binfn, $cfn)==0, 'C code
compilation');
is(system($binfn), 123 << 8, 'binary execution');
# exit 0;
write_file($plsrcfn, <<"EOF");
#!$^X
use Getopt::Long::Descriptive;
my (\$opt, \$usage) = describe_options(
[ 'help', "print usage message and exit" ],
);
exit 124;
EOF
ok(system($^X, '-MO=C,-o'.$cfn, $plsrcfn)==0, 'C code generation');
ok(system($^X, $cc_harness_bin, '-o', $binfn, $cfn)==0, 'C code
compilation');
is(system($binfn), 124 << 8, 'binary execution');