@@ -6,6 +6,7 @@ use File::Basename;
66use POSIX qw( WEXITSTATUS WIFEXITED) ;
77use Cwd qw( abs_path getcwd) ;
88use File::Path qw( mkpath) ; # mkpath works with ancient perl, as well as newer perl
9+ use Data::Dumper; # for debugging.
910
1011# these are created in the directory where we are run, which might be
1112# a build directory.
@@ -71,20 +72,71 @@ sub runShellTests {
7172 # have to update passed/failed here
7273}
7374
75+ $confighhash = undef ;
76+
77+ sub loadconfighash {
78+ if (defined ($confighhash )) {
79+ return $confighhash ;
80+ }
81+
82+ $main::confighhash = {};
83+
84+ # this could be loaded once perhaps.
85+ open (CONFIG_H, " config.h" ) || die " Can not open config.h: $! \n " ;
86+ while (<CONFIG_H>) {
87+ chomp ;
88+ if (/ ^\# define (.*) 1/ ) {
89+ # print "Setting $1\n";
90+ $main::confighhash -> {$1 } = 1;
91+ }
92+ }
93+ close (CONFIG_H);
94+ # print Dumper($main::confighhash);
95+ return $main::confighhash ;
96+ }
97+
98+
7499sub runOneComplexTest {
75100 local ($testconfig ) = @_ ;
76101
77102 my $output = $testconfig -> {output };
78103 my $input = $testconfig -> {input };
79104 my $name = $testconfig -> {name };
80105 my $options = $testconfig -> {args };
81-
106+ my $foundit = 1;
107+ my $unfoundit =1;
108+
109+ my $configset = $testconfig -> {config_set };
110+ my $configunset = $testconfig -> {config_unset };
111+ my $ch = loadconfighash();
112+ # print Dumper($ch);
113+
114+ if (defined ($configset )) {
115+ $foundit = ($ch -> {$configset } == 1);
116+ }
117+ if (defined ($configunset )) {
118+ $unfoundit =($ch -> {$configunset } != 1);
119+ }
120+
121+ if (!$foundit ) {
122+ print " ${name} ... skipped, no ${configset} \n " ;
123+ return 0;
124+ }
125+
126+ if (!$unfoundit ) {
127+ print " ${name} ... skipped, ${configunset} is set\n " ;
128+ return 0;
129+ }
130+
82131 # use Data::Dumper;
83132 # print Dumper($testconfig);
84-
85- my $result = runtest($name ,
86- $testsdir . " /" . $input ,
87- $testsdir . " /" . $output ,
133+
134+ # EXPAND any occurances of @TESTDIR@ to $testsdir
135+ $options =~ s /\@ TESTDIR\@ / $testsdir / ;
136+
137+ my $result = runtest($name ,
138+ $testsdir . " /" . $input ,
139+ $testsdir . " /" . $output ,
88140 $options );
89141
90142 if ($result == 0) {
@@ -100,10 +152,13 @@ sub runComplexTests {
100152 my @files = glob ( $testsdir . ' /*.tests' );
101153 foreach $file (@files ) {
102154 my @testlist = undef ;
155+ my $definitions ;
103156 print " FILE: ${file} \n " ;
104157 open (FILE, " <" .$file ) || die " can not open $file : $! " ;
105- local $/ = undef ;
106- $definitions = <FILE>;
158+ {
159+ local $/ = undef ;
160+ $definitions = <FILE>;
161+ }
107162 close (FILE);
108163 # print "STUFF: ${definitions}\n";
109164 eval $definitions ;
@@ -116,13 +171,13 @@ sub runComplexTests {
116171 } else {
117172 warn " File: ${file} could not be loaded as PERL: $! " ;
118173 }
119- }
174+ }
120175}
121176
122177sub runSimpleTests {
123178
124179 local ($only )=@_ ;
125-
180+
126181 open (TESTLIST, " <" . " ${testsdir} /TESTLIST" ) || die " no ${testsdir} /TESTFILE: $! \n " ;
127182 while (<TESTLIST>) {
128183 next if / ^\# / ;
@@ -132,7 +187,7 @@ sub runSimpleTests {
132187 ($name , $input , $output , @options ) = split ;
133188 # print "processing ${only} vs ${name}\n";
134189 next if (defined ($only ) && $only ne $name );
135-
190+
136191 my $options = join (" " , @options );
137192 # print "@{options} becomes ${options}\n";
138193
0 commit comments