httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: perl-framework server startup
Date Wed, 23 Jan 2002 02:07:31 GMT
Rodent of Unusual Size wrote:

> Stas Bekman wrote:
> 
>>Of course, I thought that's what you want, so you can do a binary and
>>and figure out what has failed.
>>
> 
> Okey, how do a bitwise AND in the shell in a portable way?
> 
> 
>>OK, but harness may fail for different reasons, why do you want to
>>scratch the status code of the failure? Currently you don't care, but
>>someone may want to know the failure status and program the launching
>>program to act accordingly.
>>
> 
> Fine.  That's an excellent point.  Now, if only I can figure out
> a better way to test this than
> 
> STATUS=$?
> if perl -e "exit (($STATUS & 0xc8) == 0xc8);" ; then
>     harness_failed
> elif test "x$STATUS" != "x0" ; then
>     test_failed
> fi


Sorry, I know a little csh programming, much less sh, but I do know Perl :)

#!/usr/bin/perl


use constant TEST_FAILED => 0xC8;

test(q{perl -e 'exit 0xC9'});
test(q{perl -e 'exit 0x01'});

sub test {
    my $command = shift;
    system $command;
    $status = $? >> 8;
    print $status & TEST_FAILED ? "Test\n" : "Harness\n";
}


I realize that you want to do this in pure sh, but then I guess you need 
to lookup how to perform binary logic in sh. On the other hand why not 
to code your the scripts in Perl in first place? So much easier...


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Mime
View raw message