1#!perl -w 2 3use TestInit qw(T); 4use strict; 5use Config; 6 7require './t/test.pl'; 8 9skip_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: 14my %skip = map { ("PL_$_", 1) } 15 qw( 16 DBcv bitcount cshname generation lastgotoprobe 17 mod_latin1_uc modcount no_symref_sv uudmap 18 watchaddr watchok warn_uninit_sv hash_chars 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$skip{PL_warn_locale}= 1; # we can be compiled without locales, so skip testing them 23 24# -P is POSIX and defines an expected format, while the default 25# output will vary from platform to platform 26my $trial = "$Config{nm} -P globals$Config{_o} 2>&1"; 27my $yes = `$trial`; 28 29skip_all("Could not run `$trial`") if $?; 30 31my $defined = qr/\s+[^Uu]\s+/m; 32 33skip_all("Could not spot definition of PL_Yes in output of `$trial`") 34 unless $yes =~ /^_?PL_Yes${defined}/m; 35 36my %exported; 37open my $fh, '-|', $^X, '-Ilib', './makedef.pl', 'PLATFORM=test' 38 or die "Can't run makedef.pl"; 39 40while (<$fh>) { 41 next unless /^PL_/; 42 chomp; 43 ++$exported{$_}; 44} 45 46close $fh or die "Problem running makedef.pl"; 47 48# AIX can list a symbol as both a local and a global symbol 49# so collect all of the symbols *then* process them 50my %defined; 51foreach my $file (map {$_ . $Config{_o}} qw(globals regcomp)) { 52 open $fh, '-|', $Config{nm}, "-P", $file 53 or die "Can't run nm $file"; 54 55 while (<$fh>) { 56 next unless /^_?(PL_\S+)${defined}/; 57 $defined{$1} = 1; 58 } 59 close $fh or die "Problem running nm $file"; 60} 61 62my %unexported; 63for my $name (sort keys %defined) { 64 if (delete $exported{$name}) { 65 note("Seen definition of $name"); 66 next; 67 } 68 ++$unexported{$name}; 69} 70 71unless ($Config{d_double_has_inf}) { 72 $skip{PL_inf}++; 73} 74unless ($Config{d_double_has_nan}) { 75 $skip{PL_nan}++; 76} 77 78foreach (sort keys %exported) { 79 SKIP: { 80 skip("We dont't export '$_' (Perl not built with this enabled?)",1) if $skip{$_}; 81 fail("Attempting to export '$_' which is never defined"); 82 } 83} 84 85$::TODO = $::TODO; # silence uninitialized warnings 86foreach (sort keys %unexported) { 87 SKIP: { 88 skip("We don't export '$_'", 1) if $skip{$_}; 89 TODO: { 90 local $::TODO = "HPUX exports everything" if $^O eq "hpux"; 91 fail("'$_' is defined, but we do not export it"); 92 } 93 } 94} 95 96done_testing(); 97