This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ExtUtils::CBuilder Tru64 support
[perl5.git] / lib / ExtUtils / CBuilder / t / 02-link.t
CommitLineData
6b09c160
YST
1#! perl -w
2
3BEGIN {
4 if ($ENV{PERL_CORE}) {
5 chdir 't' if -d 't';
6 chdir '../lib/ExtUtils/CBuilder'
7 or die "Can't chdir to lib/ExtUtils/CBuilder: $!";
8 @INC = qw(../..);
9 }
10}
11
12use strict;
13use Test;
14BEGIN {
15 if ($^O eq 'MSWin32') {
16 print "1..0 # Skipped: link_executable() is not implemented yet on Win32\n";
17 exit;
18 }
19 if ($^O eq 'VMS') {
20 # So we can get the return value of system()
21 require vmsish;
22 import vmsish;
23 }
24 plan tests => 5;
25}
26
27use ExtUtils::CBuilder;
28use File::Spec;
29
30# TEST doesn't like extraneous output
31my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
32
33my $b = ExtUtils::CBuilder->new(quiet => $quiet);
34ok $b;
35
36my $source_file = File::Spec->catfile('t', 'compilet.c');
37{
38 local *FH;
39 open FH, "> $source_file" or die "Can't create $source_file: $!";
40 print FH "int main(void) { return 11; }\n";
41 close FH;
42}
43ok -e $source_file;
44
45# Compile
46my $object_file;
47ok $object_file = $b->compile(source => $source_file);
48
49# Link
50my ($exe_file, @temps);
51($exe_file, @temps) = $b->link_executable(objects => $object_file);
52ok $exe_file;
53
54# Try the executable
55ok my_system($exe_file), 11;
56
57# Clean up
58for ($source_file, $exe_file, $object_file, @temps) {
59 tr/"'//d;
60 1 while unlink;
61}
62
63sub my_system {
64 my $cmd = shift;
65 if ($^O eq 'VMS') {
66 return system("mcr $cmd");
67 }
68 return system($cmd) >> 8;
69}