summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/Apache-Test/Apache-TestItSelf/t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-07 02:04:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-07 02:04:07 +0000
commit1221c736f9a90756d47ea6d28320b6b83602dd2a (patch)
treeb453ba7b1393205258c9b098a773b4330984672f /debian/perl-framework/Apache-Test/Apache-TestItSelf/t
parentAdding upstream version 2.4.38. (diff)
downloadapache2-debian/2.4.38-3+deb10u8.tar.xz
apache2-debian/2.4.38-3+deb10u8.zip
Adding debian version 2.4.38-3+deb10u8.debian/2.4.38-3+deb10u8debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/perl-framework/Apache-Test/Apache-TestItSelf/t')
-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
4 files changed, 499 insertions, 0 deletions
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__
+