| 1 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||||||||||||||||||||
| 2 | # contributor license agreements. See the NOTICE file distributed with | ||||||||||||||||||||||||||||
| 3 | # this work for additional information regarding copyright ownership. | ||||||||||||||||||||||||||||
| 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 | ||||||||||||||||||||||||||||
| 5 | # (the "License"); you may not use this file except in compliance with | ||||||||||||||||||||||||||||
| 6 | # the License. You may obtain a copy of the License at | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||
| 13 | # See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||
| 14 | # limitations under the License. | ||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||
| 16 | package Apache::TestConfig; #not TestConfigC on purpose | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Apache::TestConfig (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Apache::TestConfigPerl (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Apache::TestTrace; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use File::Find qw(finddepth); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub cmodule_find { | ||||||||||||||||||||||||||
|
Subroutine
cmodule_find: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 0 | my($self, $mod) = @_; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | return unless $mod =~ /^mod_(\w+)\.c$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | my $sym = $1; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | my $dir = $File::Find::dir; | |||||||||||||||||||||||||||
| 34 | 0 | my $file = catfile $dir, $mod; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | unless ($self->{APXS}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $self->{cmodules_disabled}->{$mod} = "no apxs configured"; | |||||||||||||||||||||||||||
| 38 | 0 | return; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | open $fh, $file or die "open $file: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | my $v = <$fh>; | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($v =~ /^\#define\s+HTTPD_TEST_REQUIRE_APACHE\s+(\d+)\s*$/) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 45 | #define HTTPD_TEST_REQUIRE_APACHE 1 | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | unless ($self->{server}->{rev} == $1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | my $reason = "requires Apache version $1"; | |||||||||||||||||||||||||||
| 48 | 0 | $self->{cmodules_disabled}->{$mod} = $reason; | |||||||||||||||||||||||||||
| 49 | 0 | notice "$mod $reason, skipping."; | |||||||||||||||||||||||||||
| 50 | 0 | return; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | elsif ($v =~ /^\#define\s+HTTPD_TEST_REQUIRE_APACHE\s+(\d\.\d+(\.\d+)?)/) { | ||||||||||||||||||||||||||||
| 54 | #define HTTPD_TEST_REQUIRE_APACHE 2.1 | ||||||||||||||||||||||||||||
| 55 | 0 | my $wanted = $1; | |||||||||||||||||||||||||||
| 56 | 0 | (my $current) = $self->{server}->{version} =~ m:^Apache/(\d\.\d+\.\d+):; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if (Apache::Test::normalize_vstring($current) < | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | Apache::Test::normalize_vstring($wanted)) { | ||||||||||||||||||||||||||||
| 60 | 0 | my $reason = "requires Apache version $wanted"; | |||||||||||||||||||||||||||
| 61 | 0 | $self->{cmodules_disabled}->{$mod} = $reason; | |||||||||||||||||||||||||||
| 62 | 0 | notice "$mod $reason, skipping."; | |||||||||||||||||||||||||||
| 63 | 0 | return; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 0 | close $fh; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | push @{ $self->{cmodules} }, { | |||||||||||||||||||||||||||
| 69 | name => "mod_$sym", | ||||||||||||||||||||||||||||
| 70 | sym => "${sym}_module", | ||||||||||||||||||||||||||||
| 71 | dir => $dir, | ||||||||||||||||||||||||||||
| 72 | subdir => basename $dir, | ||||||||||||||||||||||||||||
| 73 | }; | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub cmodules_configure { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_configure: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 0 | my($self, $dir) = @_; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | $self->{cmodules_disabled} = {}; #for have_module to check | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $dir ||= catfile $self->{vars}->{top_dir}, 'c-modules'; | ||||||||||||||||||||||||||
|
Condition0%0/3
$dir ||= catfile($self->{"vars"}{"top_dir"}, "c-modules")
MC/DC0%0/2
$dir ||= catfile($self->{"vars"}{"top_dir"}, "c-modules")
$dir
catfile($self->{"vars"}{"top_dir"}, "c-modules")
Truth table0%0/3
A ||= B
A= $dirB= catfile($self->{"vars"}{"top_dir"}, "c-modules")
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | unless (-d $dir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 0 | return; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | $self->{cmodules_dir} = $dir; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | finddepth(sub { cmodule_find($self, $_) }, $dir); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | unless ($self->{APXS}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | warning "cannot build c-modules without apxs"; | |||||||||||||||||||||||||||
| 93 | 0 | return; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | $self->cmodules_generate_include; | |||||||||||||||||||||||||||
| 97 | 0 | $self->cmodules_write_makefiles; | |||||||||||||||||||||||||||
| 98 | 0 | $self->cmodules_compile; | |||||||||||||||||||||||||||
| 99 | 0 | $self->cmodules_httpd_conf; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub cmodules_makefile_vars { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_makefile_vars: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 0 | return <<EOF; | |||||||||||||||||||||||||||
| 104 | MAKE = $Config{make} | ||||||||||||||||||||||||||||
| 105 | EOF | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | my %lib_dir = Apache::TestConfig::WIN32 | |||||||||||||||||||||||||||
| 109 | ? (1 => "", 2 => "") | ||||||||||||||||||||||||||||
| 110 | : (1 => "", 2 => ".libs/"); | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub cmodules_build_so { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_build_so: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 113 | 0 | my($self, $name) = @_; | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | $name = "mod_$name" unless $name =~ /^mod_/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | my $libdir = $self->server->version_of(\%lib_dir); | |||||||||||||||||||||||||||
| 116 | 0 | my $lib = "$libdir$name.so"; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub cmodules_write_makefiles { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_write_makefiles: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 120 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | my $modules = $self->{cmodules}; | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | for (@$modules) { | |||||||||||||||||||||||||||
| 125 | 0 | $self->cmodules_write_makefile($_); | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | my $file = catfile $self->{cmodules_dir}, 'Makefile'; | |||||||||||||||||||||||||||
| 129 | 0 | my $fh = $self->genfile($file); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | print $fh $self->cmodules_makefile_vars; | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | my @dirs = map { $_->{subdir} } @$modules; | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | my @targets = qw(clean); | |||||||||||||||||||||||||||
| 136 | 0 | my @libs; | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | for my $dir (@dirs) { | |||||||||||||||||||||||||||
| 139 | 0 | for my $targ (@targets) { | |||||||||||||||||||||||||||
| 140 | 0 | print $fh "$dir-$targ:\n\tcd $dir && \$(MAKE) $targ\n\n"; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | my $lib = $self->cmodules_build_so($dir); | |||||||||||||||||||||||||||
| 144 | 0 | my $cfile = "$dir/mod_$dir.c"; | |||||||||||||||||||||||||||
| 145 | 0 | push @libs, "$dir/$lib"; | |||||||||||||||||||||||||||
| 146 | 0 | print $fh "$libs[-1]: $cfile\n\tcd $dir && \$(MAKE) $lib\n\n"; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | for my $targ (@targets) { | |||||||||||||||||||||||||||
| 150 | 0 | print $fh "$targ: ", (map { "$_-$targ " } @dirs), "\n\n"; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | print $fh "all: @libs\n\n"; | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 0 | ▶ | close $fh or die "close $file: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub cmodules_write_makefile { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_write_makefile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 159 | 0 | my ($self, $mod) = @_; | |||||||||||||||||||||||||||
| 160 | 0 | my $write = \&{"cmodules_write_makefile_$^O"}; | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | $write = \&cmodules_write_makefile_default unless defined &$write; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | $write->($self, $mod); | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub cmodules_write_makefile_default { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_write_makefile_default: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 166 | 0 | my($self, $mod) = @_; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | my $dversion = $self->server->dversion; | |||||||||||||||||||||||||||
| 169 | 0 | my $name = $mod->{name}; | |||||||||||||||||||||||||||
| 170 | 0 | my $makefile = catfile $mod->{dir}, 'Makefile'; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | my $extra = $ENV{EXTRA_CFLAGS} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'EXTRA_CFLAGS'} || ''
MC/DC0%0/1
$ENV{'EXTRA_CFLAGS'} || ''
$ENV{'EXTRA_CFLAGS'}
Truth table0%0/2
A
A= $ENV{'EXTRA_CFLAGS'}
| |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | debug "writing $makefile"; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | my $lib = $self->cmodules_build_so($name); | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | my $fh = $self->genfile($makefile); | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | print $fh <<EOF; | |||||||||||||||||||||||||||
| 181 | APXS=$self->{APXS} | ||||||||||||||||||||||||||||
| 182 | all: $lib | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | $lib: $name.c | ||||||||||||||||||||||||||||
| 185 | \$(APXS) $dversion $extra -I$self->{cmodules_dir} -c $name.c | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | clean: | ||||||||||||||||||||||||||||
| 188 | -rm -rf $name.o $name.lo $name.slo $name.la $name.i $name.s $name.gcno .libs | ||||||||||||||||||||||||||||
| 189 | EOF | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | close $fh or die "close $makefile: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub cmodules_write_makefile_aix { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_write_makefile_aix: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 195 | 0 | my($self, $mod) = @_; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | my $dversion = $self->server->dversion; | |||||||||||||||||||||||||||
| 198 | 0 | my $name = $mod->{name}; | |||||||||||||||||||||||||||
| 199 | 0 | my $makefile = catfile $mod->{dir}, 'Makefile'; | |||||||||||||||||||||||||||
| 200 | 0 | my $apxsflags = ''; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | # | ||||||||||||||||||||||||||||
| 203 | # Only do this for Apache 1.* | ||||||||||||||||||||||||||||
| 204 | # | ||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ($self->server->{rev} == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | $apxsflags = "-Wl,-bE:$name.exp"; | |||||||||||||||||||||||||||
| 207 | 0 | my $expfile = catfile $mod->{dir}, "$name.exp"; | |||||||||||||||||||||||||||
| 208 | 0 | ▶ | if (! -f $expfile) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 0 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||
| 210 | 0 | $name =~ /^mod_(\w+)(?:\.c)?$/; | |||||||||||||||||||||||||||
| 211 | 0 | my $sym = $1 . '_module'; | |||||||||||||||||||||||||||
| 212 | 0 | ▶ | open $fh, ">$expfile" or die "open $expfile: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 0 | print $fh "$sym\n"; | |||||||||||||||||||||||||||
| 214 | 0 | close $fh; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my $extra = $ENV{EXTRA_CFLAGS} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'EXTRA_CFLAGS'} || ''
MC/DC0%0/1
$ENV{'EXTRA_CFLAGS'} || ''
$ENV{'EXTRA_CFLAGS'}
Truth table0%0/2
A
A= $ENV{'EXTRA_CFLAGS'}
| |||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | debug "writing $makefile"; | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | my $lib = $self->cmodules_build_so($name); | |||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||
| 225 | 0 | ▶ | open $fh, ">$makefile" or die "open $makefile: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | print $fh <<EOF; | |||||||||||||||||||||||||||
| 228 | APXS=$self->{APXS} | ||||||||||||||||||||||||||||
| 229 | APXSFLAGS=$apxsflags | ||||||||||||||||||||||||||||
| 230 | all: $lib | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | $lib: $name.c | ||||||||||||||||||||||||||||
| 233 | \$(APXS) $dversion $extra -I$self->{cmodules_dir} \$(APXSFLAGS) -c $name.c | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | clean: | ||||||||||||||||||||||||||||
| 236 | -rm -rf $name.o $name.lo $name.slo $name.la .libs | ||||||||||||||||||||||||||||
| 237 | EOF | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | close $fh or die "close $makefile: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub cmodules_write_makefile_MSWin32 { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_write_makefile_MSWin32: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 243 | 0 | my($self, $mod) = @_; | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | my $dversion = $self->server->dversion; | |||||||||||||||||||||||||||
| 246 | 0 | my $name = $mod->{name}; | |||||||||||||||||||||||||||
| 247 | 0 | my $makefile = "$mod->{dir}/Makefile"; | |||||||||||||||||||||||||||
| 248 | 0 | debug "writing $makefile"; | |||||||||||||||||||||||||||
| 249 | 0 | my $extras = ''; | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | my $lib = $self->cmodules_build_so($name); | |||||||||||||||||||||||||||
| 252 | 0 | ▶ | $extras = ' -llibhttpd -p ' if ($self->server->{rev} != 1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | my $goners = join ' ', (map {$name . '.' . $_} qw(exp lib so lo)); | |||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 0 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||
| 256 | 0 | ▶ | open $fh, ">$makefile" or die "open $makefile: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $extra = $ENV{EXTRA_CFLAGS} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'EXTRA_CFLAGS'} || ''
MC/DC0%0/1
$ENV{'EXTRA_CFLAGS'} || ''
$ENV{'EXTRA_CFLAGS'}
Truth table0%0/2
A
A= $ENV{'EXTRA_CFLAGS'}
| |||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 0 | debug "writing $makefile"; | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | print $fh <<EOF; | |||||||||||||||||||||||||||
| 263 | APXS=$self->{APXS} | ||||||||||||||||||||||||||||
| 264 | all: $lib | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | $lib: $name.c | ||||||||||||||||||||||||||||
| 267 | \$(APXS) $dversion $extra -I$self->{cmodules_dir} $extras -c $name.c | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | clean: | ||||||||||||||||||||||||||||
| 270 | -erase $goners | ||||||||||||||||||||||||||||
| 271 | EOF | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | ▶ | close $fh or die "close $makefile: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 0 | ▶ | sub cmodules_make { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_make: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 277 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 278 | 0 | ▶ | my $targ = shift || 'all'; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'all'
MC/DC0%0/1
shift() || 'all'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | my $cmd = "cd $self->{cmodules_dir} && $Config{make} $targ"; | |||||||||||||||||||||||||||
| 281 | 0 | debug $cmd; | |||||||||||||||||||||||||||
| 282 | 0 | system $cmd; | |||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ($?) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 284 | 0 | die "Failed to build c-modules"; | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub cmodules_compile { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_compile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 289 | 0 | shift->cmodules_make('all'); | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 0 | ▶ | sub cmodules_httpd_conf { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_httpd_conf: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 293 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 0 | my @args; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | for my $mod (@{ $self->{cmodules} }) { | |||||||||||||||||||||||||||
| 298 | 0 | my $dir = $mod->{dir}; | |||||||||||||||||||||||||||
| 299 | 0 | my $lib = $self->cmodules_build_so($mod->{name}); | |||||||||||||||||||||||||||
| 300 | 0 | my $so = "$dir/$lib"; | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | next unless -e $so; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | $self->preamble(LoadModule => "$mod->{sym} $so"); | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 0 | my $cname = "$mod->{name}.c"; | |||||||||||||||||||||||||||
| 307 | 0 | my $cfile = "$dir/$cname"; | |||||||||||||||||||||||||||
| 308 | 0 | $self->{modules}->{$cname} = 1; | |||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 0 | $self->add_module_config($cfile, \@args); | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 0 | ▶ | $self->postamble(\@args) if @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | ▶ | sub cmodules_clean { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_clean: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 317 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 0 | my $dir = $self->{cmodules_dir}; | |||||||||||||||||||||||||||
| 320 | 0 | ▶ | return unless $dir and -e "$dir/Makefile"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dir and -e "$dir/Makefile"
MC/DC0%0/2
$dir and -e "$dir/Makefile"
$dir
-e "$dir/Makefile"
Truth table0%0/3
A and B
A= $dirB= -e "$dir/Makefile"
| |||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 0 | ▶ | unless ($self->{clean_level} > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | #skip t/TEST -conf | ||||||||||||||||||||||||||||
| 324 | 0 | warning "skipping rebuild of c-modules; run t/TEST -clean to force"; | |||||||||||||||||||||||||||
| 325 | 0 | return; | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | $self->cmodules_make('clean'); | |||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 0 | for my $mod (@{ $self->{cmodules} }) { | |||||||||||||||||||||||||||
| 331 | 0 | my $makefile = "$mod->{dir}/Makefile"; | |||||||||||||||||||||||||||
| 332 | 0 | debug "unlink $makefile"; | |||||||||||||||||||||||||||
| 333 | 0 | unlink $makefile; | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 0 | unlink "$dir/Makefile"; | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | #try making it easier for test modules to compile with both 1.x and 2.x | ||||||||||||||||||||||||||||
| 340 | 43 | ▶ | sub cmodule_define_name { | ||||||||||||||||||||||||||
|
Subroutine
cmodule_define_name: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 341 | 43 | my $name = shift; | |||||||||||||||||||||||||||
| 342 | 43 | ▶ | $name eq 'NULL' ? $name : "APACHE_HTTPD_TEST_\U$name"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 16 | ▶ | sub cmodule_define { | ||||||||||||||||||||||||||
|
Subroutine
cmodule_define: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 346 | 16 | my $hook = cmodule_define_name(@_); | |||||||||||||||||||||||||||
| 347 | 16 | "#ifndef $hook\n#define $hook NULL\n#endif\n"; | |||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 1 | my @cmodule_config_names = qw(per_dir_create per_dir_merge | |||||||||||||||||||||||||||
| 351 | per_srv_create per_srv_merge | ||||||||||||||||||||||||||||
| 352 | commands); | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | my @cmodule_config_defines = map { | ||||||||||||||||||||||||||||
| 355 | 1 | cmodule_define($_); | |||||||||||||||||||||||||||
| 356 | } @cmodule_config_names; | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 1 | my $cmodule_config_extra = | |||||||||||||||||||||||||||
| 359 | "#ifndef APACHE_HTTPD_TEST_EXTRA_HOOKS\n". | ||||||||||||||||||||||||||||
| 360 | "#define APACHE_HTTPD_TEST_EXTRA_HOOKS(p) do { } while (0)\n". | ||||||||||||||||||||||||||||
| 361 | "#endif\n"; | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | my $cmodule_config_hooks = join ",\n ", map { | ||||||||||||||||||||||||||||
| 364 | 1 | cmodule_define_name($_); | |||||||||||||||||||||||||||
| 365 | } @cmodule_config_names; | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 1 | my @cmodule_phases = qw(post_read_request translate_name header_parser | |||||||||||||||||||||||||||
| 368 | access_checker check_user_id auth_checker | ||||||||||||||||||||||||||||
| 369 | type_checker fixups handler log_transaction | ||||||||||||||||||||||||||||
| 370 | child_init); | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | my $cmodule_hooks_1 = join ",\n ", map { | ||||||||||||||||||||||||||||
| 373 | 1 | cmodule_define_name($_); | |||||||||||||||||||||||||||
| 374 | } qw(translate_name check_user_id auth_checker access_checker | ||||||||||||||||||||||||||||
| 375 | type_checker fixups log_transaction header_parser | ||||||||||||||||||||||||||||
| 376 | child_init NULL post_read_request); | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | my $cmodule_template_1 = <<"EOF", | ||||||||||||||||||||||||||||
| 379 | static const handler_rec name ## _handlers[] = | ||||||||||||||||||||||||||||
| 380 | { | ||||||||||||||||||||||||||||
| 381 | {#name, APACHE_HTTPD_TEST_HANDLER}, /* ok if handler is NULL */ | ||||||||||||||||||||||||||||
| 382 | {NULL} | ||||||||||||||||||||||||||||
| 383 | }; | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | module MODULE_VAR_EXPORT name ## _module = | ||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||
| 387 | STANDARD_MODULE_STUFF, | ||||||||||||||||||||||||||||
| 388 | NULL, /* initializer */ | ||||||||||||||||||||||||||||
| 389 | $cmodule_config_hooks, | ||||||||||||||||||||||||||||
| 390 | name ## _handlers, /* handlers */ | ||||||||||||||||||||||||||||
| 391 | $cmodule_hooks_1 | ||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||
| 393 | EOF | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | my @cmodule_hooks = map { | ||||||||||||||||||||||||||||
| 396 | 1 | my $hook = cmodule_define_name($_); | |||||||||||||||||||||||||||
| 397 | 11 | <<EOF; | |||||||||||||||||||||||||||
| 398 | if ($hook != NULL) | ||||||||||||||||||||||||||||
| 399 | ap_hook_$_($hook, | ||||||||||||||||||||||||||||
| 400 | NULL, NULL, | ||||||||||||||||||||||||||||
| 401 | APACHE_HTTPD_TEST_HOOK_ORDER); | ||||||||||||||||||||||||||||
| 402 | EOF | ||||||||||||||||||||||||||||
| 403 | } @cmodule_phases; | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | my @cmodule_hook_defines = map { | ||||||||||||||||||||||||||||
| 406 | 1 | cmodule_define($_); | |||||||||||||||||||||||||||
| 407 | } @cmodule_phases; | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 1 | my $cmodule_template_2 = <<"EOF"; | |||||||||||||||||||||||||||
| 410 | static void name ## _register_hooks(apr_pool_t *p) | ||||||||||||||||||||||||||||
| 411 | { | ||||||||||||||||||||||||||||
| 412 | @cmodule_hooks | ||||||||||||||||||||||||||||
| 413 | APACHE_HTTPD_TEST_EXTRA_HOOKS(p); | ||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | module AP_MODULE_DECLARE_DATA name ## _module = { | ||||||||||||||||||||||||||||
| 417 | STANDARD20_MODULE_STUFF, | ||||||||||||||||||||||||||||
| 418 | $cmodule_config_hooks, | ||||||||||||||||||||||||||||
| 419 | name ## _register_hooks, /* register hooks */ | ||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | EOF | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | 1 | my %cmodule_templates = (1 => $cmodule_template_1, 2 => $cmodule_template_2); | |||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | 0 | ▶ | sub cmodules_module_template { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_module_template: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 426 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 427 | 0 | my $template = $self->server->version_of(\%cmodule_templates); | |||||||||||||||||||||||||||
| 428 | 0 | chomp $template; | |||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 0 | $template =~ s,$, \\,mg; | |||||||||||||||||||||||||||
| 431 | 0 | $template =~ s, \\$,,s; | |||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | 0 | local $" = ', '; | |||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | 0 | return <<EOF; | |||||||||||||||||||||||||||
| 436 | #define APACHE_HTTPD_TEST_MODULE(name) \\ | ||||||||||||||||||||||||||||
| 437 | $template | ||||||||||||||||||||||||||||
| 438 | EOF | ||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub cmodules_generate_include { | ||||||||||||||||||||||||||
|
Subroutine
cmodules_generate_include: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 442 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 0 | my $file = "$self->{cmodules_dir}/apache_httpd_test.h"; | |||||||||||||||||||||||||||
| 445 | 0 | my $fh = $self->genfile($file); | |||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | 0 | ▶ | while (read Apache::TestConfigC::DATA, my $buf, 1024) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | 0 | print $fh $buf; | |||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | 0 | print $fh @cmodule_hook_defines, @cmodule_config_defines; | |||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 0 | print $fh $cmodule_config_extra; | |||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 0 | print $fh $self->cmodules_module_template; | |||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 0 | close $fh; | |||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | package Apache::TestConfigC; #Apache/TestConfig.pm also has __DATA__ | ||||||||||||||||||||||||||||
| 461 | 1 | 1; | |||||||||||||||||||||||||||
| 462 | __DATA__ | ||||||||||||||||||||||||||||