Skip to content

Commit

Permalink
extend t/c_cross.t test
Browse files Browse the repository at this point in the history
needs a arm-linux-gnueabihf-gcc compiler and
a custom /usr/lib/cperl/5.29.1/armv4l-linux/CORE dir though.
  • Loading branch information
rurban committed Feb 13, 2019
1 parent b6dfce9 commit 24a3967
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions t/c_cross.t
@@ -1,20 +1,32 @@
#! /usr/bin/env perl
# test -cross=path
BEGIN {
print "1..1\n";
}
use strict;
use Config;
use Test::More;
plan tests => 9;

# This should exist for the last test:
my $crossarch = '/usr/lib/cperl/5.29.1/armv4l-linux/CORE';

sub check_cross {
my ($file) = @_;
my $f;
unless (open($f, "<", $file)) {
print "not ok # $file not found\n";
ok(0, "$file $!");
return;
}
# perlpath in config.sh-arm-linux
while (<$f>) {
//;
if (m{"", GV_ADD\|GV_NOTQUAL\), "(.+)"\);}) {
is ($1, "/usr/bin/perl", "perlpath");
next;
}
if (m{/\* cross \@INC \*/}) {
$_ = <$f>;
$_ = <$f>;
like($_, qr{/armv4l-linux}, 'cross \@INC');
next;
}
}
close $f;
}
Expand All @@ -31,7 +43,7 @@ my $X = $^X =~ m/\s/ ? qq{"$^X" -Iblib/arch -Iblib/lib} : "$^X -Iblib/arch -Ibli
system "$X -MO=$C,-cross=t/config.sh-arm-linux,-occross.c $pl";

# now grep the result for the right $^X, $^O and @INC
check_cross('ccross.c');
check_cross('ccross.c', 1);

system "$X -MO=$C,-O3,-cross=t/config.sh-arm-linux,-occross.c $pl";
check_cross('ccross.c');
Expand All @@ -43,12 +55,15 @@ check_cross('ccross.c');
system "$X script/perlcc -S --cross=t/config.sh-arm-linux -o ccross $pl";
check_cross('ccross.c');

if (`which arm-linux-gnueabihf-gcc`) {
#require ExtUtils::Embed;
my $opts = '-I'.$Config{archlib}.'/CORE';
if (-d $crossarch and `which arm-linux-gnueabihf-gcc`) {
my $opts = "-I$crossarch";
system("arm-linux-gnueabihf-gcc -c $opts ccross.c");
} else {
ok (1, "skip no arm-linux-gnueabihf-gcc or $crossarch");
}

unlink $pl;

__DATA__
require vars;
vars->import($c);
Expand Down

0 comments on commit 24a3967

Please sign in to comment.