On Wednesday 15 December 2004 20:46, Stas Bekman wrote: > Torsten Foertsch wrote: > > But how do I know it in the tests? Is there another way except of > > scanning conf/httpd.conf? > > You do: > > use Apache::Test; > plan tests => 5, need_module 'ssl'; > > It's documented in the Apache::Test manpage and also here: > http://perl.apache.org/docs/general/testing/testing.html > feel free to suggest an improvement if you couldn't find that information > when you read those docs. (you did read those, right? :)
yes, I did. I am aware of need_module() and have_module() being almost the same thing. Now please have a look at Apache::ModSSL/t/1is_https.t and TEST.PL: TEST.PL: ----------------------------------------------------------------------------------------------- ... my $I=Apache::TestRunPerl->new; my @[EMAIL PROTECTED]; # save it $I->run(@ARGV); system "cp t/conf/apache_test_config.pm t/conf/apache_test_config.pm1"; Apache::TestConfig::autoconfig_skip_module_add('mod_ssl.c'); $I->refresh; $I->run(@argv); system "cp t/conf/apache_test_config.pm t/conf/apache_test_config.pm2"; ----------------------------------------------------------------------------------------------- For debugging I am duplicating the generated apache_test_config.pm files. They do differ. The 2nd one lacks the "LoadModule ssl_module" as expected. ... @@ -308,10 +308,6 @@ LoadModule rewrite_module "/usr/lib/apache2-prefork/mod_rewrite.so" </IfModule> ', - '<IfModule !mod_ssl.c> - LoadModule ssl_module "/usr/lib/apache2-prefork/mod_ssl.so" -</IfModule> -', '<IfModule !mod_unique_id.c> LoadModule unique_id_module "/usr/lib/apache2-prefork/mod_unique_id.so" </IfModule> ... 1is_https.t: ----------------------------------------------------------------------------------------------- ... sub ssl_loaded { open my $f, "t/conf/httpd.conf" or die "ERROR: Cannot read t/conf/httpd.conf: $!"; return grep(/^\s*LoadModule\s+ssl_module\b/, <$f>) ? 1 : 0; } ... #if( have_module('ssl') ) { if( ssl_loaded ) { plan tests => 2; ok t_cmp( test( 'default', 'is_https' ), "HAVE_SSL=1 is_https: 0\n", "no ssl" ); ok t_cmp( test( 'SSL', 'is_https' ), "HAVE_SSL=1 is_https: 1\n", "ssl" ); } else { plan tests => 1; ok t_cmp( test( 'default', 'is_https' ), "HAVE_SSL= is_https: UNDEF\n", "no ssl" ); } ----------------------------------------------------------------------------------------------- My ssl_loaded() function distinguishes between the 2 cases, have_module('ssl') does not. With have_module() always the 1st case is entered. Here is an excerpt of Apache::Test: sub need_module { ... for (@modules) { ... next if $cfg->{modules}->{$mod}; if (exists $cfg->{cmodules_disabled}->{$mod}) { push @reasons, $cfg->{cmodules_disabled}->{$mod}; next; } ... } ... } Since my Apache::TestConfig in both cases contains "mod_ssl.c" in $cfg->{modules} the test will succeed. The "Apache::TestConfig::autoconfig_skip_module_add('mod_ssl.c');" is disregarded while generating this hash. Torsten
pgpQzmbM08pVZ.pgp
Description: PGP signature