[patch] better failure diagnostics for config token substitution
if the config token get mistyped, e.g. @servrename@ the current replace() sub will simply die without helping to locate which token is unknown to Apache-Test. This patch reports the offensive token (of course it'd be nice to tell which file it comes from but the current implementation doesn't allow that) Index: Apache-Test/lib/Apache/TestConfig.pm === RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v retrieving revision 1.117 diff -u -r1.117 TestConfig.pm --- Apache-Test/lib/Apache/TestConfig.pm2001/12/21 12:44:16 1.117 +++ Apache-Test/lib/Apache/TestConfig.pm2001/12/23 16:36:50 @@ -755,7 +755,12 @@ sub replace { my $self = shift; -s/@(\w+)@/$self-{vars}-{lc $1}/g; +s[@(\w+)@] + [ my $key = lc $1; + exists $self-{vars}-{$key} + ? $self-{vars}-{$key} + : die qq{cannot substitute [EMAIL PROTECTED]@ token} + ]ge; } #need to configure the vhost port for redirects and $ENV{SERVER_PORT} we could do simpler: +s[@(\w+)@] + [ $self-{vars}-{lc $1} + || die qq{cannot substitute [EMAIL PROTECTED]@ token} + ]ge; But the value can be false (while valid), so it won't work for all cases. _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
[patch] don't complain about old core files
this patch: - s/scan/scan_core/ for consistency with warn_core - don't complain aload when an old core from some old run is found (i'm tired of remembering to remove old core files) Index: Apache-Test/lib/Apache/TestRun.pm === RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v retrieving revision 1.76 diff -u -r1.76 TestRun.pm --- Apache-Test/lib/Apache/TestRun.pm 2001/12/22 02:28:27 1.76 +++ Apache-Test/lib/Apache/TestRun.pm 2001/12/23 17:16:04 @@ -16,6 +16,8 @@ use constant STARTUP_TIMEOUT = 300; # secs (good for extreme debug cases) +my %core_files = (); + my @std_run = qw(start-httpd run-tests stop-httpd); my @others = qw(verbose configure clean help ssl http11); my @flag_opts= (@std_run, @others); @@ -274,7 +276,7 @@ local $?; # preserve the exit status eval { Apache::TestRun-new(test_config = - Apache::TestConfig-thaw)-scan; + Apache::TestConfig-thaw)-scan_core; }; }'; } @@ -573,7 +575,7 @@ $oh[ rand scalar @oh ]; } -sub scan { +sub scan_core { my $self = shift; my $vars = $self-{test_config}-{vars}; my $times = 0; @@ -581,10 +583,16 @@ finddepth(sub { return unless /^core$/; my $core = $File::Find::dir/$_; -my $oh = oh(); -my $again = $times++ ? again : ; -error oh $oh, server dumped core $again; -error for stacktrace, run: gdb $vars-{httpd} -core $core; +if (exists $core_files{$core} $core_files{$core} == -M $core) { +# we have seen this core file before the start of the test +info an old core file has been found: $core; +} +else { +my $oh = oh(); +my $again = $times++ ? again : ; +error oh $oh, server dumped core $again; +error for stacktrace, run: gdb $vars-{httpd} -core $core; +} }, $vars-{top_dir}); } @@ -594,11 +602,15 @@ sub warn_core { my $self = shift; my $vars = $self-{test_config}-{vars}; +%core_files = (); # reset global finddepth(sub { return unless /^core$/; my $core = $File::Find::dir/$_; error consider removing an old $core file before running tests; +# remember the timestamp of $core so we can check if it's the +# old core file at the end of the run and not complain then +$core_files{$core} = -M $core; }, $vars-{top_dir}); } _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: [patch] autogeneration of TEST/SMOKE/REPORT
Doug MacEachern wrote: On Fri, 21 Dec 2001, Stas Bekman wrote: This patch removes the need for t/TEST.PL, t/SMOKE.PL, build/bugreport.pl and implements in each set of the classes used by these scripts a generate_script() method, which generates these scripts. - If you try to generate t/SMOKE for ModPerl-Registry it'll need a different 'use lib' adjustments. you could pass a [EMAIL PROTECTED] arg to the generate methods that are added to the 'use lib ...' probably, but see below. So it's not than much re-usable after all. Are you sure that we really want this to be done in the way this patch does and not just to stick with .PL scripts? I really prefer a the .PL scripts because of their easy customizability. i mainly wanted to see the bugreport stuff be re-usable in a module, rather than having to copy a .pl script around to each project. having the methods to generate t/{TEST,SMOKE,REPORT} are just a bonus. if a project needs to customize more, then they just don't use the generation methods. I've almost committed the stuff, but then I've tried to apply it to httpd-test/perl-framework's t/TEST and couldn't do it because t/TEST had: %Apache::TestConfig::Argv = qw(apxs /home/stas/httpd/prefork/bin/apxs); which is not generic (and the same goes for t/SMOKE, but it doesn't need it), Apache-Test/t/ has a very non-generic t/TEST I suppose that t/REPORT and t/SMOKE are the only ones that are simple and can be re-used. I really doubt whether we have any added value in abstracting t/TEST. How about if I do this abstraction for SMOKE and REPORT but leave TEST.PL as is? _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: [patch] catch server dies early (was Re: perl-framework: mod_dav but not mod_dav?)
On Mon, 24 Dec 2001, Stas Bekman wrote: On Tue, 4 Dec 2001, Doug MacEachern wrote: On Wed, 5 Dec 2001, Stas Bekman wrote: ok, but that catches only syntax errors. if we can catch the return status from system() we can catch all errors, causing the failure. that would be great. ok, here it is. Have no clue whether you can re-use this for win32. prev patch was partially broken. This one preserves the original value of SIGCHLD and uses SIGINT instead of 15 in kill(). Index: Apache-Test/lib/Apache/TestServer.pm === RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v retrieving revision 1.46 diff -u -r1.46 TestServer.pm --- Apache-Test/lib/Apache/TestServer.pm2001/12/20 17:30:54 1.46 +++ Apache-Test/lib/Apache/TestServer.pm2001/12/23 19:42:34 @@ -402,6 +402,9 @@ } print $cmd\n; +my $child_pid; +my $child_in_pipe; +my $old_sig; if (Apache::TestConfig::WIN32) { #make sure only 1 process is started for win32 @@ -418,7 +421,18 @@ $config-{win32obj} = $obj; } else { -system $cmd ; +require POSIX; +$old_sig = $SIG{CHLD}; +$SIG{CHLD} = sub { +while ((my $child = waitpid(-1, POSIX::WNOHANG())) 0) { +my $status = $? 8; +if ($status) { +$self-failed_msg(\nserver has died with status $status); +kill POSIX::SIGINT(), $$; +} +} +}; +$child_pid = open $child_in_pipe, |$cmd; } while ($old_pid and $old_pid == $self-pid) { @@ -450,6 +464,10 @@ last; } } + +# now that the server has started don't abort the test run if it +# dies +$SIG{CHLD} = $old_sig || 'DEFAULT'; if (my $pid = $self-pid) { print server $self-{name} started\n; _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/