1*0Sstevel@tonic-gate#!./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate chdir 't' if -d 't'; 5*0Sstevel@tonic-gate @INC = '../lib'; 6*0Sstevel@tonic-gate require "./test.pl"; 7*0Sstevel@tonic-gate} 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gateplan tests => 36; 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gateuse_ok('Config'); 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate# Some (safe?) bets. 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gateok(keys %Config > 500, "Config has more than 500 entries"); 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gateok(each %Config); 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gateis($Config{PERL_REVISION}, 5, "PERL_REVISION is 5"); 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gate# Check that old config variable names are aliased to their new ones. 22*0Sstevel@tonic-gatemy %grandfathers = ( PERL_VERSION => 'PATCHLEVEL', 23*0Sstevel@tonic-gate PERL_SUBVERSION => 'SUBVERSION', 24*0Sstevel@tonic-gate PERL_CONFIG_SH => 'CONFIG' 25*0Sstevel@tonic-gate ); 26*0Sstevel@tonic-gatewhile( my($new, $old) = each %grandfathers ) { 27*0Sstevel@tonic-gate isnt($Config{$new}, undef, "$new is defined"); 28*0Sstevel@tonic-gate is($Config{$new}, $Config{$old}, "$new is aliased to $old"); 29*0Sstevel@tonic-gate} 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gateok( exists $Config{cc}, "has cc"); 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gateok( exists $Config{ccflags}, "has ccflags"); 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gateok(!exists $Config{python}, "has no python"); 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gateok( exists $Config{d_fork}, "has d_fork"); 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gateok(!exists $Config{d_bork}, "has no d_bork"); 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gatelike($Config{ivsize}, qr/^(4|8)$/, "ivsize is 4 or 8 (it is $Config{ivsize})"); 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate# byteorder is virtual, but it has rules. 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gatelike($Config{byteorder}, qr/^(1234|4321|12345678|87654321)$/, "byteorder is 1234 or 4321 or 12345678 or 87654321 (it is $Config{byteorder})"); 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gateis(length $Config{byteorder}, $Config{ivsize}, "byteorder is as long as ivsize (which is $Config{ivsize})"); 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate# ccflags_nolargefiles is virtual, too. 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gateok(exists $Config{ccflags_nolargefiles}, "has ccflags_nolargefiles"); 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate# Utility functions. 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate{ 56*0Sstevel@tonic-gate # make sure we can export what we say we can export. 57*0Sstevel@tonic-gate package Foo; 58*0Sstevel@tonic-gate my @exports = qw(myconfig config_sh config_vars config_re); 59*0Sstevel@tonic-gate Config->import(@exports); 60*0Sstevel@tonic-gate foreach my $func (@exports) { 61*0Sstevel@tonic-gate ::ok( __PACKAGE__->can($func), "$func exported" ); 62*0Sstevel@tonic-gate } 63*0Sstevel@tonic-gate} 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gatelike(Config::myconfig(), qr/osname=\Q$Config{osname}\E/, "myconfig"); 66*0Sstevel@tonic-gatelike(Config::config_sh(), qr/osname='\Q$Config{osname}\E'/, "config_sh"); 67*0Sstevel@tonic-gatelike(join("\n", Config::config_re('c.*')), 68*0Sstevel@tonic-gate qr/^c.*?=/, 'config_re' ); 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gatemy $out = tie *STDOUT, 'FakeOut'; 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gateConfig::config_vars('cc'); 73*0Sstevel@tonic-gatemy $out1 = $$out; 74*0Sstevel@tonic-gate$out->clear; 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gateConfig::config_vars('d_bork'); 77*0Sstevel@tonic-gatemy $out2 = $$out; 78*0Sstevel@tonic-gate$out->clear; 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gateuntie *STDOUT; 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gatelike($out1, qr/^cc='\Q$Config{cc}\E';/, "config_vars cc"); 83*0Sstevel@tonic-gatelike($out2, qr/^d_bork='UNKNOWN';/, "config_vars d_bork is UNKNOWN"); 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate# Read-only. 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gateundef $@; 88*0Sstevel@tonic-gateeval { $Config{d_bork} = 'borkbork' }; 89*0Sstevel@tonic-gatelike($@, qr/Config is read-only/, "no STORE"); 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gateok(!exists $Config{d_bork}, "still no d_bork"); 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gateundef $@; 94*0Sstevel@tonic-gateeval { delete $Config{d_fork} }; 95*0Sstevel@tonic-gatelike($@, qr/Config is read-only/, "no DELETE"); 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gateok( exists $Config{d_fork}, "still d_fork"); 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gateundef $@; 100*0Sstevel@tonic-gateeval { %Config = () }; 101*0Sstevel@tonic-gatelike($@, qr/Config is read-only/, "no CLEAR"); 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gateok( exists $Config{d_fork}, "still d_fork"); 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate{ 106*0Sstevel@tonic-gate package FakeOut; 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate sub TIEHANDLE { 109*0Sstevel@tonic-gate bless(\(my $text), $_[0]); 110*0Sstevel@tonic-gate } 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate sub clear { 113*0Sstevel@tonic-gate ${ $_[0] } = ''; 114*0Sstevel@tonic-gate } 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate sub PRINT { 117*0Sstevel@tonic-gate my $self = shift; 118*0Sstevel@tonic-gate $$self .= join('', @_); 119*0Sstevel@tonic-gate } 120*0Sstevel@tonic-gate} 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate# Signal-related variables 123*0Sstevel@tonic-gate# (this is actually a regression test for Configure.) 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gateis($Config{sig_num_init} =~ tr/,/,/, $Config{sig_size}, "sig_num_init size"); 126*0Sstevel@tonic-gateis($Config{sig_name_init} =~ tr/,/,/, $Config{sig_size}, "sig_name_init size"); 127