Re: Apache::Test question

[prev] [thread] [next] [Date index for 2004/12/16]

From: Torsten Foertsch
Subject: Re: Apache::Test question
Date: 14:50 on 16 Dec 2004
--nextPart2468412.xggKr8Hi8H
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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 @argv=@ARGV;			# 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

--nextPart2468412.xggKr8Hi8H
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQBBwaCqwicyCTir8T4RAviQAKCM7V3hxdAcpllkuSitXfnxF26CAgCeM1Sp
CRCZB3cYEvil37zYbAt3q5I=
=bjj8
-----END PGP SIGNATURE-----

--nextPart2468412.xggKr8Hi8H--

(message missing)

Apache::Test question
Torsten Foertsch 10:31 on 15 Dec 2004

Re: Apache::Test question
Stas Bekman 19:46 on 15 Dec 2004

Re: Apache::Test question
Torsten Foertsch 14:50 on 16 Dec 2004

Re: Apache::Test question
Stas Bekman 16:28 on 16 Dec 2004

Re: Apache::Test question
William McKee 21:19 on 16 Dec 2004

Re: Apache::Test question
Stas Bekman 23:28 on 16 Dec 2004

Re: Apache::Test question
Geoffrey Young 23:39 on 16 Dec 2004

Re: Apache::Test question
Torsten Foertsch 15:32 on 19 Dec 2004

Re: Apache::Test question
Stas Bekman 22:34 on 19 Dec 2004

Re: Apache::Test question
Geoffrey Young 23:36 on 16 Dec 2004

Re: Apache::Test question
Stas Bekman 23:49 on 16 Dec 2004

Re: Apache::Test question
Geoffrey Young 00:29 on 17 Dec 2004

Re: Apache::Test question
Stas Bekman 00:41 on 17 Dec 2004

[PATCH]Re: Apache::Test question
Torsten Foertsch 13:41 on 01 May 2005

Generated at 10:25 on 04 May 2005 by mariachi v0.52