hi all
I thought it might be useful to have an have_apache_mpm function. while not particularly useful for individual tests, I use have_min_apache_version() from my Makefile.PL and plan to use have_apache_mpm() from there as well. I suspect it's real utility, though, would be from a custom TEST.PL.
anyway, I tested it with the prefork and worker mpms on unix - tests from other platforms welcome to make sure I have a decent (well, usable) regex. patch is against current CVS.
--Geoff
? have_apache_mpm.patch Index: lib/Apache/Test.pm =================================================================== RCS file: /home/cvspublic/httpd-test/perl-framework/Apache-Test/lib/Apache/Test.pm,v retrieving revision 1.63 diff -u -r1.63 Test.pm --- lib/Apache/Test.pm 19 Jun 2003 00:45:31 -0000 1.63 +++ lib/Apache/Test.pm 25 Jun 2003 13:27:40 -0000 @@ -15,7 +15,7 @@ have_cgi have_access have_auth have_module have_apache have_min_apache_version have_apache_version have_perl have_min_perl_version have_min_module_version - have_threads under_construction); + have_threads under_construction have_apache_mpm); $VERSION = '1.04'; %SubTests = (); @@ -274,6 +274,22 @@ push @SkipReasons, "apache version $wanted or higher is required," . " this is version $current"; + return 0; + } + else { + return 1; + } +} + +sub have_apache_mpm { + my $wanted = shift; + my $cfg = Apache::Test::config(); + my $current = $cfg->{server}->{mpm}; + + if ($current ne $wanted) { + push @SkipReasons, + "apache mpm $wanted is required," . + " this is the $current mpm"; return 0; } else { Index: lib/Apache/TestConfigParse.pm =================================================================== RCS file: /home/cvspublic/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm,v retrieving revision 1.33 diff -u -r1.33 TestConfigParse.pm --- lib/Apache/TestConfigParse.pm 27 Apr 2003 22:52:28 -0000 1.33 +++ lib/Apache/TestConfigParse.pm 25 Jun 2003 13:27:40 -0000 @@ -341,4 +341,25 @@ return $version; } +sub httpd_mpm { + my $self = shift; + + my $httpd = $self->{vars}->{httpd}; + return unless $httpd; + + my $mpm; + my $cmd = "$httpd -V"; + + my $v = $self->open_cmd($cmd); + + while (my $line = <$v>) { + ($mpm) = $line =~ m!APACHE_MPM_DIR.*\b(\w+)"$!; + last if $mpm; + } + + close $v; + + return $mpm; +} + 1; Index: lib/Apache/TestServer.pm =================================================================== RCS file: /home/cvspublic/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v retrieving revision 1.62 diff -u -r1.62 TestServer.pm --- lib/Apache/TestServer.pm 21 May 2003 04:02:14 -0000 1.62 +++ lib/Apache/TestServer.pm 25 Jun 2003 13:27:41 -0000 @@ -38,6 +38,7 @@ $self->{port_counter} = $self->{config}->{vars}->{port}; $self->{version} = $self->{config}->httpd_version || ''; + $self->{mpm} = $self->{config}->httpd_mpm || ''; ($self->{rev}) = $self->{version} =~ m:^Apache/(\d)\.:; $self->{rev} ||= 2;