This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Skip symbols for which Configure found no support.
[perl5.git] / t / porting / globvar.t
1 #!perl -w
2
3 use TestInit qw(T);
4 use strict;
5 use Config;
6
7 require 't/test.pl';
8
9 skip_all("Code to read symbols not ported to $^O")
10     if $^O eq 'VMS' or $^O eq 'MSWin32';
11
12 # Not investigated *why* we don't export these, but we don't, and we've not
13 # received any bug reports about it causing problems:
14 my %skip = map { ("PL_$_", 1) }
15     qw(
16           DBcv bitcount cshname force_link_funcs generation lastgotoprobe
17           mod_latin1_uc modcount no_symref_sv timesbuf uudmap
18           watchaddr watchok warn_uninit_sv
19      );
20
21 $skip{PL_hash_rand_bits}= $skip{PL_hash_rand_bits_enabled}= 1; # we can be compiled without these, so skip testing them
22
23
24 my $trial = "nm globals$Config{_o} 2>&1";
25 my $yes = `$trial`;
26
27 skip_all("Could not run `$trial`") if $?;
28
29 my $defined = qr/^[0-9a-fA-F]{8,16}\s+[^Uu]\s+_?/m;
30
31 skip_all("Could not spot definition of PL_Yes in output of `$trial`")
32     unless $yes =~ /${defined}PL_Yes/m;
33
34 my %exported;
35 open my $fh, '-|', $^X, '-Ilib', './makedef.pl', 'PLATFORM=test'
36     or die "Can't run makedef.pl";
37
38 while (<$fh>) {
39     next unless /^PL_/;
40     chomp;
41     ++$exported{$_};
42 }
43
44 close $fh or die "Problem running makedef.pl";
45
46 my %unexported;
47
48 foreach my $file (map {$_ . $Config{_o}} qw(globals regcomp)) {
49     open $fh, '-|', 'nm', $file
50         or die "Can't run nm $file";
51
52     while (<$fh>) {
53         next unless /$defined(PL_\S+)/;
54         if (delete $exported{$1}) {
55             note("Seen definition of $1");
56             next;
57         }
58         ++$unexported{$1};
59     }
60     close $fh or die "Problem running nm $file";
61 }
62
63 foreach (sort keys %exported) {
64  SKIP: {
65     skip("We dont't export '$_' (Perl not built with this enabled?)",1) if $skip{$_};
66     fail("Attempting to export '$_' which is never defined");
67  }
68 }
69
70 foreach (sort keys %unexported) {
71  SKIP: {
72         skip("We don't export '$_'", 1) if $skip{$_};
73         fail("'$_' is defined, but we do not export it");
74     }
75 }
76
77 done_testing();