summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/Apache-Test/Apache-TestItSelf
diff options
context:
space:
mode:
Diffstat (limited to 'debian/perl-framework/Apache-Test/Apache-TestItSelf')
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes21
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Makefile.PL221
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/README5
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/TEST.PL37
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/hello.t20
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/vhost.t7
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/extra.conf.in16
-rwxr-xr-xdebian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/modperl_extra.pl2
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Hello.pm19
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Vhost.pm28
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Changes27
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/Makefile.PL40
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/README73
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/lib/MyTest/Util.pm160
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_apache_test_core.pl44
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_mp2_core.pl43
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_mp2_modules.pl43
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/t/TEST.PL123
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/t/httpd_arg.t117
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/t/interactive.t158
-rw-r--r--debian/perl-framework/Apache-Test/Apache-TestItSelf/t/minmaxclients.t101
21 files changed, 1305 insertions, 0 deletions
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes
new file mode 100644
index 0000000..adf4530
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes
@@ -0,0 +1,21 @@
+=head1 NAME
+
+Changes - Apache::TestMe changes logfile
+
+=head1 Changes
+
+=over 4
+
+=item 0.01
+
+new test basic/vhost.t which introduces a vhost entry in .pm. also
+added a dummy vhost entry in t/conf/extra.conf.in, the setup needed by
+t/minmaxclients.t from Apache-TestItSelf [Stas]
+
+write a basic mod_perl test: basic/hello.t [Stas]
+
+starting the config test suite used by Apache::TestItSelf [Stas]
+
+=back
+
+=cut
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Makefile.PL b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Makefile.PL
new file mode 100644
index 0000000..cd2ef90
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Makefile.PL
@@ -0,0 +1,221 @@
+use 5.005;
+
+use lib qw(../../lib); # Apache-Test/lib
+
+use Apache::TestMM qw(test clean);
+use Apache::TestMM ();
+use Apache::TestReport;
+
+use ExtUtils::MakeMaker ();
+
+my $mp_gen = satisfy_mp_generation();
+warn "Goind to build against mod_perl/$mod_perl::VERSION Perl/$]\n";
+
+Apache::TestMM::filter_args();
+
+my @scripts = qw(t/TEST);
+for (@scripts) {
+ Apache::TestMM::generate_script($_);
+}
+Apache::TestReport->generate_script;
+
+my @clean_files = (@scripts, qw(t/REPORT));
+
+
+my %common_opts = (
+ NAME => 'Apache-TestMe',
+ VERSION => '0.01',
+ clean => {
+ FILES => "@clean_files",
+ },
+);
+
+if ($mp_gen == 1) {
+ require ExtUtils::MakeMaker;
+ ExtUtils::MakeMaker::WriteMakefile(
+ %common_opts,
+ );
+
+}
+else {
+ require ModPerl::MM;
+ ModPerl::MM::WriteMakefile(
+ %common_opts,
+ );
+}
+# If a specific generation was passed as an argument,
+# if satisfied
+# return the same generation
+# else
+# die
+# else @ARGV and %ENV will be checked for specific orders
+# if the specification will be found
+# if satisfied
+# return the specified generation
+# else
+# die
+# else if any mp generation is found
+# return it
+# else
+# die
+
+sub satisfy_mp_generation {
+ my $wanted = shift || wanted_mp_generation();
+
+ unless ($wanted == 1 || $wanted == 2) {
+ die "don't know anything about mod_perl generation: $wanted\n" .
+ "currently supporting only generations 1 and 2";
+ }
+
+ my $selected = 0;
+
+ if ($wanted == 1) {
+ require_mod_perl();
+ if ($mod_perl::VERSION >= 1.99) {
+ # so we don't pick 2.0 version if 1.0 is wanted
+ die "You don't seem to have mod_perl 1.0 installed";
+ }
+ $selected = 1;
+ }
+ elsif ($wanted == 2) {
+ #warn "Looking for mod_perl 2.0";
+ require_mod_perl2();
+ if ($mod_perl::VERSION < 1.99) {
+ die "You don't seem to have mod_perl 2.0 installed";
+ }
+ $selected = 2;
+ }
+ else {
+ $selected = eval { require_mod_perl2() or require_mod_perl() };
+ warn "Using $mod_perl::VERSION\n";
+ }
+
+ return $selected;
+}
+
+sub require_mod_perl {
+ eval { require mod_perl };
+ die "Can't find mod_perl installed\nThe error was: $@" if $@;
+ 1;
+}
+
+sub require_mod_perl2 {
+ eval { require mod_perl2 };
+ die "Can't find mod_perl installed\nThe error was: $@" if $@;
+ 2;
+}
+
+
+# the function looks at %ENV and Makefile.PL option to figure out
+# whether a specific mod_perl generation was requested.
+# It uses the following logic:
+# via options:
+# perl Makefile.PL MOD_PERL=2
+# or via %ENV:
+# env MOD_PERL=1 perl Makefile.PL
+#
+# return value is:
+# 1 or 2 if the specification was found (mp 1 and mp 2 respectively)
+# 0 otherwise
+sub wanted_mp_generation {
+
+ # check if we have a command line specification
+ # flag: 0: unknown, 1: mp1, 2: mp2
+ my $flag = 0;
+ my @pass;
+ while (@ARGV) {
+ my $key = shift @ARGV;
+ if ($key =~ /^MOD_PERL=(\d)$/) {
+ $flag = $1;
+ }
+ else {
+ push @pass, $key;
+ }
+ }
+ @ARGV = @pass;
+
+ # check %ENV
+ my $env = exists $ENV{MOD_PERL} ? $ENV{MOD_PERL} : 0;
+
+ # check for contradicting requirements
+ if ($env && $flag && $flag != $env) {
+ die <<EOF;
+Can\'t decide which mod_perl version should be used, since you have
+supplied contradicting requirements:
+ enviroment variable MOD_PERL=$env
+ Makefile.PL option MOD_PERL=$flag
+EOF
+ }
+
+ my $wanted = 0;
+ $wanted = 2 if $env == 2 || $flag == 2;
+ $wanted = 1 if $env == 1 || $flag == 1;
+
+ unless ($wanted) {
+ # if still unknown try to require mod_perl.pm
+ eval { require mod_perl2 or require mod_perl };
+ unless ($@) {
+ $wanted = $mod_perl::VERSION >= 1.99 ? 2 : 1;
+ }
+ }
+
+ return $wanted;
+}
+
+
+# the function looks at %ENV and Makefile.PL option to figure out
+# whether a specific mod_perl generation was requested.
+# It uses the following logic:
+# via options:
+# perl Makefile.PL MOD_PERL=2
+# or via %ENV:
+# env MOD_PERL=1 perl Makefile.PL
+#
+# return value is:
+# 1 or 2 if the specification was found (mp 1 and mp 2 respectively)
+# 0 otherwise
+sub wanted_mp_generation {
+
+ # check if we have a command line specification
+ # flag: 0: unknown, 1: mp1, 2: mp2
+ my $flag = 0;
+ my @pass;
+ while (@ARGV) {
+ my $key = shift @ARGV;
+ if ($key =~ /^MOD_PERL=(\d)$/) {
+ $flag = $1;
+ }
+ else {
+ push @pass, $key;
+ }
+ }
+ @ARGV = @pass;
+
+ # check %ENV
+ my $env = exists $ENV{MOD_PERL} ? $ENV{MOD_PERL} : 0;
+
+ # check for contradicting requirements
+ if ($env && $flag && $flag != $env) {
+ die <<EOF;
+Can\'t decide which mod_perl version should be used, since you have
+supplied contradicting requirements:
+ enviroment variable MOD_PERL=$env
+ Makefile.PL option MOD_PERL=$flag
+EOF
+ }
+
+ my $wanted = 0;
+ $wanted = 2 if $env == 2 || $flag == 2;
+ $wanted = 1 if $env == 1 || $flag == 1;
+
+ unless ($wanted) {
+ # if still unknown try to require mod_perl.pm
+ eval { require mod_perl2 or require mod_perl };
+ unless ($@) {
+ $wanted = $mod_perl::VERSION >= 1.99 ? 2 : 1;
+ }
+ }
+
+ return $wanted;
+}
+
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/README b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/README
new file mode 100644
index 0000000..bc79ea1
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/README
@@ -0,0 +1,5 @@
+This package contains an Apache-Test test suite used by
+Apache-TestItSelf. We use a dedicated test suite, so we can re-create
+cases which normally won't fit into the core Apache-Test test suite.
+This is the test suite that should be run from Apache-TestTestItSelf
+as explained in Apache-TestItSelf/README
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/TEST.PL b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/TEST.PL
new file mode 100644
index 0000000..b5d3494
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/TEST.PL
@@ -0,0 +1,37 @@
+use strict;
+
+use FindBin;
+# test against the A-T source lib for easier dev
+use lib "$FindBin::Bin/../../../lib";
+
+use lib qw(lib ../lib);
+
+use warnings FATAL => 'all';
+
+use Apache::TestRunPerl ();
+
+package MyTest;
+
+use vars qw(@ISA);
+@ISA = qw(Apache::TestRunPerl);
+
+sub new_test_config {
+ my $self = shift;
+
+ #$self->{conf_opts}->{authname} = 'gold club';
+
+ return $self->SUPER::new_test_config;
+}
+
+sub bug_report {
+ my $self = shift;
+
+ print <<EOI;
++-----------------------------------------------------+
+| To report problems please refer to the SUPPORT file |
++-----------------------------------------------------+
+EOI
+}
+
+MyTest->new->run(@ARGV);
+
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/hello.t b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/hello.t
new file mode 100644
index 0000000..ced9f86
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/hello.t
@@ -0,0 +1,20 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+
+plan tests => 3, have_lwp;
+
+my $response = GET '/TestBasic__Hello';
+
+ok t_cmp $response->code, 200, '/handler returned HTTP_OK';
+
+ok t_cmp $response->header('Content-Type'), 'text/plain',
+ '/handler set proper Content-Type';
+
+chomp(my $content = $response->content);
+
+ok t_cmp $content, 'Hello', '/handler returned proper content';
+
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/vhost.t b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/vhost.t
new file mode 100644
index 0000000..4b4d315
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/vhost.t
@@ -0,0 +1,7 @@
+use Apache::TestUtil;
+use Apache::TestRequest 'GET_BODY_ASSERT';
+
+my $module = 'TestBasic::Vhost';
+my $url = Apache::TestRequest::module2url($module);
+t_debug("connecting to $url");
+print GET_BODY_ASSERT $url;
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/extra.conf.in b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/extra.conf.in
new file mode 100644
index 0000000..e16d963
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/extra.conf.in
@@ -0,0 +1,16 @@
+# this vhost entry is needed to check that when t/TEST -maxclients 1
+# or similar is called after t/TEST -conf was run, and extra.conf
+# includes a vhost entry and httpd.conf includes an autogenerated
+# vhost entry from some .pm file, we used to have a collision, since
+# extra.conf wasn't reparsed and the same port was getting assigned to
+# more than one vhost entry, preventing server startup:
+#
+#default_ VirtualHost overlap on port 8530, the first has precedence
+#(98)Address already in use: make_sock: could not bind to address
+#0.0.0.0:8530 no listening sockets available, shutting down
+#
+# XXX: for now using a dummy vhost entry. later if needed to put a
+# real vhost entry in ths file, the dummy one can be removed
+#
+<VirtualHost foo_bar_tar>
+</VirtualHost>
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/modperl_extra.pl b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/modperl_extra.pl
new file mode 100755
index 0000000..a9f939a
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/modperl_extra.pl
@@ -0,0 +1,2 @@
+
+1;
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Hello.pm b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Hello.pm
new file mode 100644
index 0000000..953df81
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Hello.pm
@@ -0,0 +1,19 @@
+package TestBasic::Hello;
+
+use Apache2::RequestRec ();
+use Apache2::RequestIO ();
+use Apache2::Const -compile => qw(OK);
+
+# XXX: adjust the test that it'll work under mp1 as well
+
+sub handler {
+
+ my $r = shift;
+
+ $r->content_type('text/plain');
+ $r->print('Hello');
+
+ return Apache2::OK;
+}
+
+1;
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Vhost.pm b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Vhost.pm
new file mode 100644
index 0000000..9692b49
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Vhost.pm
@@ -0,0 +1,28 @@
+package TestBasic::Vhost;
+
+use Apache2::Const -compile => qw(OK);
+use Apache::Test;
+
+# XXX: adjust the test that it'll work under mp1 as well
+
+sub handler {
+
+ my $r = shift;
+
+ plan $r, tests => 1;
+
+ ok 1;
+
+ return Apache2::OK;
+}
+
+1;
+__END__
+<NoAutoConfig>
+<VirtualHost TestBasic::Vhost>
+ <Location /TestBasic__Vhost>
+ SetHandler modperl
+ PerlResponseHandler TestBasic::Vhost
+ </Location>
+</VirtualHost>
+</NoAutoConfig>
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Changes b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Changes
new file mode 100644
index 0000000..04f23d7
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Changes
@@ -0,0 +1,27 @@
+=head1 NAME
+
+Changes - Apache::TestItSelf changes logfile
+
+=head1 Changes
+
+=over 4
+
+=item 0.01
+
+Fix Makefile.PL to make sure that MakeMaker won't descend into
+Apache-TestMe. NORECURS doesn't work in older MM versions, so use the
+DIR attr as a workaround [Stas]
+
+new test: minmaxclients.t: testing a bug with vhosts reproducable by
+t/TEST -conf followed by t/TEST -maxclients 1 [Stas]
+
+new test: interactive.t: the interactive config [Stas]
+
+new test: httpd_arg.t: passing -httpd argument to 'perl Makefile.PL'
+and to 't/TEST' [Stas]
+
+starting the config test suite [Stas]
+
+=back
+
+=cut
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/Makefile.PL b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Makefile.PL
new file mode 100644
index 0000000..ef0d9ae
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/Makefile.PL
@@ -0,0 +1,40 @@
+use 5.005;
+
+use lib qw(../lib); # Apache-Test/lib
+use Apache::Test5005compat;
+
+use strict;
+use warnings;
+
+use ExtUtils::MakeMaker;
+
+use Apache::TestMM ();
+
+Apache::TestMM::generate_script('t/TEST');
+
+my @clean_files =
+ qw(t/TEST
+ Makefile.old
+ );
+
+my %prereq = (
+ # needed to be able to use one perl version to drive the test
+ # suite, but a different version from the tests themselves
+ 'Test::Harness' => '2.44',
+);
+
+WriteMakefile(
+ NAME => 'Apache::TestItSelf',
+ PREREQ_PM => \%prereq,
+ VERSION => "0.01",
+ NORECURS => 1, # don't descend into Apache-TestMe
+ DIR => [], # NORECURS is broken in older MM
+ dist => {
+ COMPRESS => 'gzip -9f', SUFFIX=>'gz',
+ },
+ clean => {
+ FILES => "@clean_files",
+ },
+);
+
+
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/README b/debian/perl-framework/Apache-Test/Apache-TestItSelf/README
new file mode 100644
index 0000000..dd332f2
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/README
@@ -0,0 +1,73 @@
+This test suite tests various Apache-Test setups (i.e. whether the
+configuration works correctly), something that can't be tested with
+the normal run-time test suite.
+
+1) first of all move into Apache-TestItSelf
+
+ % chdir Apache-TestItSelf
+
+
+
+2) now choose which test suite to run again, to test whether some
+ changes in A-T break its config, run 2a. But if the config testing
+ coverage is not complete, try other test suites and then try to
+ re-create this problem in 2a.
+
+ You will need to adjust config files under sample/ to reflect the
+ location of your preinstalled httpd and mod_perl files.
+
+ a. Apache-Test config test suite
+
+ % t/TEST -config sample/testitself_conf_apache_test_core.pl
+
+ this runs against the test suite under:
+
+ Apache-Test/Apache-TestItSelf/Apache-TestMe/t
+
+ it's the same as calling:
+
+ % t/TEST -base ~/apache.org/Apache-Test/Apache-TestItSelf/Apache-TestMe \
+ -config sample/testitself_conf_apache_test_core.pl
+
+
+
+ b. Apache-Test
+
+ assuming that Apache-Test is checked out under
+ ~/apache.org/Apache-Test, the following will run the tests against the
+ Apache-Test test suite
+
+ % t/TEST -base ~/apache.org/Apache-Test \
+ -config sample/testitself_conf_apache_test_core.pl
+
+
+
+ c. modperl-2.0
+
+ assuming that modperl-2.0 is checked out under
+ ~/apache.org/modperl-2.0, the following will run the tests against the
+ modperl-2.0 test suite
+
+ % t/TEST -base ~/apache.org/modperl-2.0 \
+ -config sample/testitself_conf_mp2_core.pl t/httpd_arg.t t/interactive.t
+
+
+
+ d. 3rd party modules ###
+
+ assuming that Apache-VMonitor-2.0 is checked out under
+ ~/work/modules/Apache-VMonitor-2.0, the following will run the tests
+ against the Apache-VMonitor-2.0 test suite. of course any other 3rd
+ party module should do.
+
+
+ % t/TEST -base ~/work/modules/Apache-VMonitor-2.0 \
+ -config sample/testitself_conf_mp2_modules.pl
+
+
+-----------------------------
+
+DEBUGGING:
+
+env IPCRUNDEBUG=data t/TEST t/interactive.t
+(for more options see IPC::Run / IPC::Run3 manpages)
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/lib/MyTest/Util.pm b/debian/perl-framework/Apache-Test/Apache-TestItSelf/lib/MyTest/Util.pm
new file mode 100644
index 0000000..736eb6f
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/lib/MyTest/Util.pm
@@ -0,0 +1,160 @@
+package MyTest::Util;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::TestConfig;
+use Apache::TestTrace;
+
+use Exporter ();
+use IPC::Run3 ();
+use Cwd;
+
+use vars qw(@ISA @EXPORT @EXPORT_OK);
+@ISA = qw(Exporter);
+@EXPORT = ();
+@EXPORT_OK = qw(myrun3 go_in go_out work_dir dump_stds check_eval
+ test_configs);
+
+sub myrun3 {
+ my $cmd = shift;
+ my $out = '';
+ my $err = '';
+
+ my $ok = IPC::Run3::run3($cmd, \undef, \$out, \$err);
+ die "IPC::Run3 failed to run $cmd" unless $ok;
+
+ dump_stds($cmd, '', $out, $err) if $?;
+
+ return ($out, $err);
+}
+
+sub go_in {
+ my $orig_dir = cwd();
+ my $dir = $ENV{APACHE_TESTITSELF_BASE_DIR} || '';
+ debug "chdir $dir";
+ chdir $dir or die "failed to chdir to $dir: $!";
+ return $orig_dir;
+}
+
+sub go_out {
+ my $dir = shift;
+ debug "chdir $dir";
+ chdir $dir or die "failed to chdir to $dir: $!";
+}
+
+# the base dir from which the A-T tests are supposed to be run
+# we might not be there
+sub work_dir { $ENV{APACHE_TESTITSELF_BASE_DIR} }
+
+sub dump_stds {
+ my($cmd, $in, $out, $err) = @_;
+ $cmd = 'unknown' unless length $cmd;
+ $in = '' unless length $in;
+ $out = '' unless length $out;
+ $err = '' unless length $err;
+
+ if ($cmd) {
+ $cmd =~ s/\n$//;
+ $cmd =~ s/^/# /gm;
+ print STDERR "\n\n#== CMD ===\n$cmd\n#=============";
+ }
+ if ($in) {
+ $in =~ s/\n$//;
+ $in =~ s/^/# /gm;
+ print STDERR "\n### STDIN ###\n$in\n##############\n\n\n";
+ }
+ if ($out) {
+ $out =~ s/\n$//;
+ $out =~ s/^/# /gm;
+ print STDERR "\n### STDOUT ###\n$out\n##############\n\n\n";
+ }
+ if ($err) {
+ $err =~ s/\n$//;
+ $err =~ s/^/# /gm;
+ print STDERR "\n### STDERR ###\n$err\n##############\n\n\n";
+ }
+}
+
+# if $@ is set dumps the $out and $err streams and dies
+# otherwise resets the $out and $err streams if $reset_std is true
+sub check_eval {
+ my($cmd, $out, $err, $reset_std, $msg) = @_;
+ $msg ||= "unknown";
+ if ($@) {
+ dump_stds($cmd, '', $out, $err);
+ die "$@\nError: $msg\n";
+ }
+ # reset the streams in caller
+ ($_[1], $_[2]) = ("", "") if $reset_std;
+}
+
+# this function returns an array of configs (hashes) coming from
+# -config-file command line option
+sub test_configs {
+ my $config_file = $ENV{APACHE_TESTITSELF_CONFIG_FILE} || '';
+
+ # reset
+ %Apache::TestItSelf::Config = ();
+ @Apache::TestItSelf::Configs = ();
+
+ require $config_file;
+ unless (@Apache::TestItSelf::Configs) {
+ error "can't find test configs in '$config_file'";
+ exit 1;
+ }
+
+ my %global = %Apache::TestItSelf::Config;
+
+ # merge the global config with instance configs
+ my @configs = map { { %global, %$_ } } @Apache::TestItSelf::Configs;
+
+ return @configs;
+}
+
+
+1;
+
+__END__
+
+=head1 NAME
+
+MyTest::Util -- helper functions
+
+=head1 Config files format
+
+the -config-file command line option specifies which file contains the
+configurations to run with.
+
+META: expand
+
+ %Apache::TestItSelf::Config = (
+ perl_exec => "/home/$ENV{USER}/perl/5.8.5-ithread/bin/perl5.8.5",
+ mp_gen => '2.0',
+ httpd_gen => '2.0',
+ httpd_version => 'Apache/2.0.55',
+ timeout => 200,
+ makepl_arg => 'MOD_PERL=2 -libmodperl mod_perl-5.8.5-ithread.so',
+ );
+
+ my $path = "/home/$ENV{USER}/httpd";
+
+ @Apache::TestItSelf::Configs = (
+ {
+ apxs_exec => "$path/prefork/bin/apxs",
+ httpd_exec => "$path/prefork/bin/httpd",
+ httpd_mpm => "prefork",
+ test_verbose => 0,
+ },
+ {
+ apxs_exec => "$path/worker/bin/apxs",
+ httpd_exec => "$path/worker/bin/httpd",
+ httpd_mpm => "worker",
+ test_verbose => 1,
+ },
+ );
+ 1;
+
+
+=cut
+
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_apache_test_core.pl b/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_apache_test_core.pl
new file mode 100644
index 0000000..d873eb7
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_apache_test_core.pl
@@ -0,0 +1,44 @@
+# This is a config file for testing Apache-Test
+
+use strict;
+use warnings FATAL => 'all';
+
+my $base = "/home/$ENV{USER}";
+
+my $perl_base = "$base/perl";
+my $perl_ver = "5.8.8-ithread";
+my $PERL = "$perl_base/$perl_ver/bin/perl$perl_ver";
+
+my $httpd_base = "$base/httpd";
+my $httpd_gen = '2.0';
+my $httpd_ver = 'Apache/2.2.3';
+my @mpms = (qw(prefork worker));
+
+my $mp_gen = 2.0;
+my $mod_perl_so = "mod_perl-$perl_ver.so";
+
+%Apache::TestItSelf::Config = (
+ repos_type => 'apache_test_core',
+ perl_exec => $PERL,
+ mp_gen => $mp_gen,
+ httpd_gen => $httpd_gen,
+ httpd_version => $httpd_ver,
+ timeout => 200,
+ test_verbose => 0,
+);
+
+@Apache::TestItSelf::Configs = ();
+foreach my $mpm (@mpms) {
+ push @Apache::TestItSelf::Configs,
+ {
+ apxs_exec => "$httpd_base/$mpm/bin/apxs",
+ httpd_exec => "$httpd_base/$mpm/bin/httpd",
+ httpd_conf => "$httpd_base/$mpm/conf/httpd.conf",
+ httpd_mpm => $mpm,
+ makepl_arg => "MOD_PERL=2 -libmodperl $httpd_base/$mpm/modules/$mod_perl_so",
+ };
+}
+
+1;
+
+
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_mp2_core.pl b/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_mp2_core.pl
new file mode 100644
index 0000000..865c33b
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_mp2_core.pl
@@ -0,0 +1,43 @@
+# This is a config file for testing modperl 2.0 core
+
+use strict;
+use warnings FATAL => 'all';
+
+my $base = "/home/$ENV{USER}";
+
+my $perl_base = "$base/perl";
+my $perl_ver = "5.8.8-ithread";
+my $PERL = "$perl_base/$perl_ver/bin/perl$perl_ver";
+
+my $httpd_base = "$base/httpd/svn";
+my $httpd_gen = '2.0';
+my $httpd_ver = 'Apache/2.2.3';
+my @mpms = (qw(prefork worker));
+
+my $mp_gen = 2.0;
+my $mod_perl_so = "mod_perl-$perl_ver.so";
+my $common_makepl_arg = "MP_MAINTAINER=1";
+
+%Apache::TestItSelf::Config = (
+ repos_type => 'mp2_core',
+ perl_exec => $PERL,
+ mp_gen => $mp_gen,
+ httpd_gen => $httpd_gen,
+ httpd_version => $httpd_ver,,
+ timeout => 900, # make test may take a long time
+ test_verbose => 0,
+);
+
+@Apache::TestItSelf::Configs = ();
+foreach my $mpm (@mpms) {
+ push @Apache::TestItSelf::Configs,
+ {
+ apxs_exec => "$httpd_base/$mpm/bin/apxs",
+ httpd_exec => "$httpd_base/$mpm/bin/httpd",
+ httpd_conf => "$httpd_base/$mpm/conf/httpd.conf",
+ httpd_mpm => $mpm,
+ makepl_arg => "MP_APXS=$httpd_base/$mpm/bin/apxs $common_makepl_arg",
+ };
+}
+
+1;
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_mp2_modules.pl b/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_mp2_modules.pl
new file mode 100644
index 0000000..07b6fe0
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/sample/testitself_conf_mp2_modules.pl
@@ -0,0 +1,43 @@
+# This is a config file for testing modperl 2.0 Apache:: 3rd party modules
+
+use strict;
+use warnings FATAL => 'all';
+
+my $base = "/home/$ENV{USER}";
+
+my $perl_base = "$base/perl";
+my $perl_ver = "5.8.8-ithread";
+my $PERL = "$perl_base/$perl_ver/bin/perl$perl_ver";
+
+my $httpd_base = "$base/httpd/svn";
+my $httpd_gen = '2.0';
+my $httpd_ver = 'Apache/2.2.3';
+my @mpms = (qw(prefork worker));
+
+my $mp_gen = 2.0;
+my $mod_perl_so = "mod_perl-$perl_ver.so";
+
+%Apache::TestItSelf::Config = (
+ repos_type => 'mp2_cpan_modules',
+ perl_exec => $PERL,
+ mp_gen => $mp_gen,
+ httpd_gen => $httpd_gen,
+ httpd_version => $httpd_ver,
+ timeout => 200,
+ test_verbose => 0,
+);
+
+
+@Apache::TestItSelf::Configs = ();
+foreach my $mpm (@mpms) {
+ push @Apache::TestItSelf::Configs,
+ {
+ apxs_exec => "$httpd_base/$mpm/bin/apxs",
+ httpd_exec => "$httpd_base/$mpm/bin/httpd",
+ httpd_conf => "$httpd_base/$mpm/conf/httpd.conf",
+ httpd_mpm => $mpm,
+ makepl_arg => "MOD_PERL=2 -libmodperl $httpd_base/$mpm/modules/$mod_perl_so",
+ };
+}
+
+1;
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/TEST.PL b/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/TEST.PL
new file mode 100644
index 0000000..8e28ce4
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/TEST.PL
@@ -0,0 +1,123 @@
+use strict;
+
+use lib qw(../../lib ../lib ./lib);
+
+use strict;
+use warnings FATAL => 'all';
+
+use Test::Harness;
+use FindBin;
+use File::Spec::Functions qw(catdir);
+use Apache::TestTrace;
+use Cwd qw(cwd);
+
+use Getopt::Long qw(GetOptions);
+
+my %usage = (
+ 'base-dir' => 'which dir to run the tests in (default: Apache-TestMe)',
+ 'config-file' => 'which config file to use',
+ 'help' => 'display this message',
+ 'trace=T' => 'change tracing default to: warning, notice, ' .
+ 'info, debug, ...',
+ 'verbose[=1]' => 'verbose output',
+);
+
+my @flag_opts = qw(verbose help);
+my @string_opts = qw(config-file base-dir trace);
+
+my %opts;
+# grab from @ARGV only the options that we expect
+GetOptions(\%opts, @flag_opts, (map "$_=s", @string_opts));
+
+# t/TEST -v -base /home/$ENV{USER}/apache.org/Apache-Test \
+# -config /home/$ENV{USER}/.apache-test/apache_test_config.pm
+#
+
+$Test::Harness::verbose = 1 if $opts{verbose};
+
+opt_help() if $opts{help};
+opt_help() unless $opts{'config-file'};
+
+if ($opts{'base-dir'}) {
+ unless (-d $opts{'base-dir'}) {
+ error "can't find $opts{'base-dir'}";
+ opt_help();
+ }
+}
+else {
+ my $dir = catdir $FindBin::Bin, qw(.. Apache-TestMe);
+ # get rid of relative paths
+ die "can't find the default dir $dir" unless -d $dir;
+ my $from = cwd();
+ chdir $dir or die "can't chdir to $dir: $!";
+ $dir = cwd();
+ chdir $from or die "can't chdir to $from: $!";
+ $opts{'base-dir'} = $dir;
+}
+
+
+unless (-r $opts{'config-file'}) {
+ error "can't read $opts{'config-file'}";
+ opt_help();
+}
+
+ if ($opts{trace}) {
+ my %levels = map {$_ => 1} @Apache::TestTrace::Levels;
+ if (exists $levels{ $opts{trace} }) {
+ $Apache::TestTrace::Level = $opts{trace};
+ # propogate the override for the server-side.
+ # -trace overrides any previous APACHE_TEST_TRACE_LEVEL settings
+ $ENV{APACHE_TEST_TRACE_LEVEL} = $opts{trace};
+ }
+ else {
+ error "unknown trace level: $opts{trace}",
+ "valid levels are: @Apache::TestTrace::Levels";
+ opt_help();
+ }
+ }
+
+# forward the data to the sub-processes run by Test::Harness
+$ENV{APACHE_TESTITSELF_CONFIG_FILE} = $opts{'config-file'};
+$ENV{APACHE_TESTITSELF_BASE_DIR} = $opts{'base-dir'};
+
+run_my_tests();
+
+sub run_my_tests {
+
+ my $base = "t";
+ unless (-d $base) {
+ # try to move into the top-level directory
+ chdir ".." or die "Can't chdir: $!";
+ }
+
+ my @tests;
+ if (@ARGV) {
+ for (@ARGV) {
+ if (-d $_) {
+ push @tests, <$_/*.t>;
+ } else {
+ $_ .= ".t" unless /\.t$/;
+ push @tests, $_;
+ }
+ }
+ } else {
+ chdir $base;
+ @tests = sort (<*.t>);
+ chdir "..";
+ @tests = map { "$base/$_" } @tests;
+ }
+
+ runtests @tests;
+}
+
+sub opt_help {
+ print <<EOM;
+usage: TEST [options ...]
+ where options include:
+EOM
+
+ for (sort keys %usage){
+ printf " -%-13s %s\n", $_, $usage{$_};
+ }
+ exit;
+}
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/httpd_arg.t b/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/httpd_arg.t
new file mode 100644
index 0000000..835b328
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/httpd_arg.t
@@ -0,0 +1,117 @@
+#
+# basic testing with -httpd argument passed explicitly (to
+# Makefile.PL, to t/TEST, etc.)
+#
+
+# XXX: -apxs should be really the same test but passing -apxs instead
+# of -httpd, so consider to just run both in this test
+
+use strict;
+use warnings FATAL => 'all';
+
+use Test::More;
+use MyTest::Util qw(myrun3 go_in go_out test_configs);
+use Apache::TestConfig ();
+
+my @configs = test_configs();
+my $tests_per_config = 18;
+plan tests => $tests_per_config * @configs;
+
+my $orig_dir = go_in();
+
+for my $c (@configs) {
+ Apache::TestConfig::custom_config_nuke();
+ $ENV{APACHE_TEST_NO_STICKY_PREFERENCES} = 1;
+ makefile_pl_plus_httpd_arg($c);
+
+ # this one will have custom config, but it shouldn't interrupt
+ # with the explicit one
+ # XXX: useless at the moment, since the previously stored custom
+ # config and the explicit config both point to the same config
+ $ENV{APACHE_TEST_NO_STICKY_PREFERENCES} = 0;
+ makefile_pl_plus_httpd_arg($c);
+
+ Apache::TestConfig::custom_config_nuke();
+ t_TEST_plus_httpd_arg($c);
+}
+
+go_out($orig_dir);
+
+# 6 tests
+# explicit Makefile.PL -httpd argument
+sub makefile_pl_plus_httpd_arg {
+ my $c = shift;
+
+ my($cmd, $out, $err);
+
+ # clean and ignore the results
+ $cmd = "make clean";
+ ($out, $err) = myrun3($cmd);
+
+ my $makepl_arg = $c->{makepl_arg} || '';
+ $cmd = "$c->{perl_exec} Makefile.PL $makepl_arg " .
+ "-httpd $c->{httpd_exec} -httpd_conf $c->{httpd_conf}";
+ ($out, $err) = myrun3($cmd);
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ $cmd = "make";
+ ($out, $err) = myrun3($cmd);
+ is $err, "", $cmd;
+
+ my $test_verbose = $c->{test_verbose} ? "TEST_VERBOSE=1" : "";
+ $cmd = "make test $test_verbose";
+ ($out, $err) = myrun3($cmd);
+ like $out, qr/using $c->{httpd_version} \($c->{httpd_mpm} MPM\)/, $cmd;
+ like $out, qr/All tests successful/, $cmd;
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ # test that httpd is found in t/REPORT (if exists)
+ SKIP: {
+ $cmd = "t/REPORT";
+ skip "$cmd doesn't exist", 1 unless -e $cmd;
+
+ ($out, $err) = myrun3($cmd);
+ like $out, qr/Server version: $c->{httpd_version}/, $cmd;
+ }
+}
+
+# explicit t/TEST -httpd argument
+sub t_TEST_plus_httpd_arg {
+ my $c = shift;
+
+ my($cmd, $out, $err);
+
+ # clean and ignore the results
+ $cmd = "make clean";
+ ($out, $err) = myrun3($cmd);
+
+ my $makepl_arg = $c->{makepl_arg} || '';
+ $cmd = "$c->{perl_exec} Makefile.PL $makepl_arg";
+ ($out, $err) = myrun3($cmd);
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ $cmd = "make";
+ ($out, $err) = myrun3($cmd);
+ is $err, "", $cmd;
+
+ my $test_verbose = $c->{test_verbose} ? "-v " : "";
+ $cmd = "t/TEST -httpd $c->{httpd_exec} $test_verbose";
+ ($out, $err) = myrun3($cmd);
+ like $out,
+ qr/using $c->{httpd_version} \($c->{httpd_mpm} MPM\)/,
+ $cmd;
+ like $out, qr/All tests successful/, $cmd;
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ # test that httpd is found in t/REPORT (if exists)
+ SKIP: {
+ $cmd = "t/REPORT";
+ skip "$cmd doesn't exist", 1 unless -e $cmd;
+
+ ($out, $err) = myrun3($cmd);
+ like $out, qr/Server version: $c->{httpd_version}/, $cmd;
+ }
+}
+
+__END__
+
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/interactive.t b/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/interactive.t
new file mode 100644
index 0000000..7afb2a0
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/interactive.t
@@ -0,0 +1,158 @@
+#
+# interactive testing (when A-T) can't figure out the configuration
+#
+
+use Test::More;
+
+use strict;
+use warnings FATAL => 'all';
+
+use IPC::Run qw(start pump finish timeout);
+use Cwd qw(cwd);
+use File::Spec::Functions qw(catfile);
+
+use MyTest::Util qw(myrun3 go_in go_out work_dir check_eval
+ test_configs);
+
+use Apache::TestConfig ();
+use Apache::TestTrace;
+
+# in this test we don't want any cached preconfiguration to kick in
+# A-T is aware of this env var and won't load neither custom config, nor
+# Apache/Build.pm from mod_perl2.
+local $ENV{APACHE_TEST_INTERACTIVE_CONFIG_TEST} = 1;
+
+my @configs = test_configs();
+if ($configs[0]{repos_type} eq 'mp2_core') {
+ plan skip_all => "modperl2 doesn't run interactive config";
+}
+else {
+ my $tests_per_config = 11;
+ plan tests => $tests_per_config * @configs + 1;
+}
+
+my $orig_dir = go_in();
+
+my $cwd = cwd();
+my $expected_work_dir = work_dir();
+is $cwd, $expected_work_dir, "working in $expected_work_dir";
+
+debug "cwd: $cwd";
+
+for my $c (@configs) {
+
+ # install the sticky custom config
+ install($c);
+
+ # interactive config doesn't work with this var on
+ $ENV{APACHE_TEST_NO_STICKY_PREFERENCES} = 0;
+ basic($c);
+}
+
+go_out($orig_dir);
+
+# 4 tests
+sub install {
+ my $c = shift;
+
+ my($cmd, $out, $err);
+
+ $cmd = "make clean";
+ ($out, $err) = myrun3($cmd);
+ # ignore the results
+
+ my $makepl_arg = $c->{makepl_arg} || '';
+ $cmd = "$c->{perl_exec} Makefile.PL $makepl_arg " .
+ "-httpd $c->{httpd_exec} -apxs $c->{apxs_exec}";
+ ($out, $err) = myrun3($cmd);
+ my $makefile = catfile $expected_work_dir, "Makefile";
+ is -e $makefile, 1, "generated $makefile";
+ unlike $err, qr/\[ error\]/, "checking for errors";
+
+ $cmd = "make";
+ ($out, $err) = myrun3($cmd);
+ is $err, "", $cmd;
+
+ $cmd = "make install";
+ ($out, $err) = myrun3($cmd);
+ unlike $err, qr/\[ error\]/, $cmd;
+}
+
+# 7 tests
+sub basic {
+ my $c = shift;
+
+ my($cmd, $out, $err);
+
+ # clean and ignore the results
+ $cmd = "make clean";
+ ($out, $err) = myrun3($cmd);
+
+ my $makepl_arg = $c->{makepl_arg} || '';
+ $cmd = "$c->{perl_exec} Makefile.PL $makepl_arg";
+ ($out, $err) = myrun3($cmd);
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ $cmd = "make";
+ ($out, $err) = myrun3($cmd);
+ is $err, "", $cmd;
+
+ {
+ my $in;
+ my $expected = '';
+ my @cmd = qw(make test);
+ push @cmd, "TEST_VERBOSE=1" if $c->{test_verbose};
+ $cmd = join " ", @cmd;
+
+ # bypass the -t STDIN checks to still ensure the interactive
+ # config prompts
+ $ENV{APACHE_TEST_INTERACTIVE_PROMPT_OK} = 1;
+
+ $in = '';
+ $out = '';
+ $err = '';
+ my $h = start \@cmd, \$in, \$out, \$err, timeout($c->{timeout});
+
+ # here the expect fails if the interactive config doesn't kick
+ # in, but for example somehow figures out the needed
+ # information (httpd/apxs) and runs the test suite normally
+ $expected = "Please provide a full path to 'httpd' executable";
+ eval { $h->pump until $out =~ /$expected/gc };
+ my $reset_std = 1;
+ check_eval($cmd, $out, $err, $reset_std,
+ "interactive config wasn't invoked");
+
+ $in .= "$c->{httpd_exec}\n" ;
+ $expected = "Please provide a full path to .*? 'apxs' executable";
+ eval { $h->pump until $out =~ /$expected/gc };
+ $reset_std = 1;
+ check_eval($cmd, $out, $err, $reset_std,
+ "interactive config had a problem");
+
+ $in .= "$c->{apxs_exec}\n" ;
+ eval { $h->finish };
+ $reset_std = 0; # needed for later sub-tests
+ check_eval($cmd, $out, $err, $reset_std,
+ "failed to finish $cmd");
+ like $out, qr/using $c->{httpd_version} \($c->{httpd_mpm} MPM\)/,
+ "$cmd: using $c->{httpd_version} \($c->{httpd_mpm} MPM";
+ like $out, qr/All tests successful/, "$cmd: All tests successful";
+ unlike $err, qr/\[ error\]/, "$cmd: no error messages";
+ }
+
+ $cmd = "make install";
+ ($out, $err) = myrun3($cmd);
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ # test that httpd is found in t/REPORT (if exists)
+ SKIP: {
+ $cmd = "t/REPORT";
+ skip "$cmd doesn't exist", 1 unless -e $cmd;
+
+ ($out, $err) = myrun3($cmd);
+ like $out, qr/Server version: $c->{httpd_version}/, $cmd;
+ }
+}
+
+__END__
+
diff --git a/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/minmaxclients.t b/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/minmaxclients.t
new file mode 100644
index 0000000..7ba65e0
--- /dev/null
+++ b/debian/perl-framework/Apache-Test/Apache-TestItSelf/t/minmaxclients.t
@@ -0,0 +1,101 @@
+#
+# -minclients / -maxclients argument passed explicitly (to
+# Makefile.PL, to t/TEST, etc.)
+#
+
+use strict;
+use warnings FATAL => 'all';
+
+use Test::More;
+use MyTest::Util qw(myrun3 go_in go_out test_configs);
+use Apache::TestConfig ();
+
+my @configs = test_configs();
+my $tests_per_config = 18;
+plan tests => $tests_per_config * @configs;
+
+my $orig_dir = go_in();
+
+# min/maxclients of 10 should work for pretty much any test suite, so
+# for now hardcoded the number in this test
+my $clients = 10;
+for my $c (@configs) {
+ for my $opt_name (qw(minclients maxclients)) {
+ my $opt = "-$opt_name $clients";
+ makefile_pl_plus_opt($c, $opt);
+ t_TEST_plus_opt($c, $opt);
+ }
+}
+
+go_out($orig_dir);
+
+# 4 sub tests
+# explicit Makefile.PL -(mix|max)clients
+sub makefile_pl_plus_opt {
+ my $c = shift;
+ my $opt = shift;
+
+ my($cmd, $out, $err);
+
+ # clean and ignore the results
+ $cmd = "make clean";
+ ($out, $err) = myrun3($cmd);
+
+ my $makepl_arg = $c->{makepl_arg} || '';
+ $cmd = "$c->{perl_exec} Makefile.PL $makepl_arg $opt " .
+ "-httpd $c->{httpd_exec} -httpd_conf $c->{httpd_conf}";
+ ($out, $err) = myrun3($cmd);
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ $cmd = "make";
+ ($out, $err) = myrun3($cmd);
+ is $err, "", $cmd;
+
+ my $test_verbose = $c->{test_verbose} ? "TEST_VERBOSE=1" : "";
+ $cmd = "make test $test_verbose";
+ ($out, $err) = myrun3($cmd);
+ like $out, qr/All tests successful/, $cmd;
+ unlike $err, qr/\[ error\]/, $cmd;
+}
+
+# 5 tests
+# explicit t/TEST -(mix|max)clients
+sub t_TEST_plus_opt {
+ my $c = shift;
+ my $opt = shift;
+
+ my($cmd, $out, $err);
+
+ # clean and ignore the results
+ $cmd = "make clean";
+ ($out, $err) = myrun3($cmd);
+
+ my $makepl_arg = $c->{makepl_arg} || '';
+ $cmd = "$c->{perl_exec} Makefile.PL $makepl_arg";
+ ($out, $err) = myrun3($cmd);
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ $cmd = "make";
+ ($out, $err) = myrun3($cmd);
+ is $err, "", $cmd;
+
+ # the bug was:
+ # t/TEST -conf
+ # t/TEST -maxclients 1
+ #default_ VirtualHost overlap on port 8530, the first has precedence
+ #(98)Address already in use: make_sock: could not bind to address
+ #0.0.0.0:8530 no listening sockets available, shutting down
+
+ my $test_verbose = $c->{test_verbose} ? "-v " : "";
+ $cmd = "t/TEST -httpd $c->{httpd_exec} $test_verbose -conf";
+ ($out, $err) = myrun3($cmd);
+ unlike $err, qr/\[ error\]/, $cmd;
+
+ $cmd = "t/TEST -httpd $c->{httpd_exec} $test_verbose $opt";
+ ($out, $err) = myrun3($cmd);
+ like $out, qr/All tests successful/, $cmd;
+ unlike $err, qr/\[ error\]/, $cmd;
+}
+
+__END__
+