X-Git-Url: http://git.maemo.org/git/?p=dh-make-perl;a=blobdiff_plain;f=dev%2Fi386%2Flibextutils-cbuilder-perl%2Flibextutils-cbuilder-perl-0.23%2Ft%2F02-link.t;fp=dev%2Fi386%2Flibextutils-cbuilder-perl%2Flibextutils-cbuilder-perl-0.23%2Ft%2F02-link.t;h=30ecbe5d3b29ce41db5660368ba5ca06c2798f52;hp=0000000000000000000000000000000000000000;hb=8977e561d8a9eae6959218b0306c9df2056a38a9;hpb=df794b845212301ea0d267c919232538bfef356a diff --git a/dev/i386/libextutils-cbuilder-perl/libextutils-cbuilder-perl-0.23/t/02-link.t b/dev/i386/libextutils-cbuilder-perl/libextutils-cbuilder-perl-0.23/t/02-link.t new file mode 100644 index 0000000..30ecbe5 --- /dev/null +++ b/dev/i386/libextutils-cbuilder-perl/libextutils-cbuilder-perl-0.23/t/02-link.t @@ -0,0 +1,77 @@ +#! perl -w + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + chdir '../lib/ExtUtils/CBuilder' + or die "Can't chdir to lib/ExtUtils/CBuilder: $!"; + @INC = qw(../..); + } +} + +use strict; +use Test; +BEGIN { + if ($^O eq 'MSWin32') { + print "1..0 # Skipped: link_executable() is not implemented yet on Win32\n"; + exit; + } + if ($^O eq 'VMS') { + # So we can get the return value of system() + require vmsish; + import vmsish; + } + plan tests => 5; +} + +use ExtUtils::CBuilder; +use File::Spec; + +# TEST doesn't like extraneous output +my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE}; + +my $b = ExtUtils::CBuilder->new(quiet => $quiet); +ok $b; + +my $source_file = File::Spec->catfile('t', 'compilet.c'); +{ + local *FH; + open FH, "> $source_file" or die "Can't create $source_file: $!"; + print FH "int main(void) { return 11; }\n"; + close FH; +} +ok -e $source_file; + +# Compile +my $object_file; +ok $object_file = $b->compile(source => $source_file); + +# Link +my ($exe_file, @temps); +($exe_file, @temps) = $b->link_executable(objects => $object_file); +ok $exe_file; + +if ($^O eq 'os2') { # Analogue of LDLOADPATH... + # Actually, not needed now, since we do not link with the generated DLL + my $old = OS2::extLibpath(); # [builtin function] + $old = ";$old" if defined $old and length $old; + # To pass the sanity check, components must have backslashes... + OS2::extLibpath_set(".\\$old"); +} + +# Try the executable +ok my_system($exe_file), 11; + +# Clean up +for ($source_file, $object_file, $exe_file) { + tr/"'//d; + 1 while unlink; +} + +sub my_system { + my $cmd = shift; + if ($^O eq 'VMS') { + return system("mcr $cmd"); + } + return system($cmd) >> 8; +}