Skip to content
runtests.pl 30.6 KiB
Newer Older
                $pid = runhttpserver($verbose);
                if($pid <= 0) {
            if(!$run{'https'}) {
                $pid = runhttpsserver($verbose);
                if($pid <= 0) {
                    return 2;
                }
                $run{'https'}=$pid;
Daniel Stenberg's avatar
Daniel Stenberg committed
        elsif($what eq "none") {
        }
        else {
            warn "we don't support a server for $what";

#######################################################################
# Check options to this test program
#

do {
    if ($ARGV[0] eq "-v") {
        # verbose output
        $verbose=1;
    }
    elsif ($ARGV[0] eq "-c") {
        # use this path to curl instead of default        
        $CURL=$ARGV[1];
        shift @ARGV;
    }
    elsif ($ARGV[0] eq "-d") {
        # have the servers display protocol output 
        $debugprotocol=1;
    }
    elsif ($ARGV[0] eq "-g") {
        # run this test with gdb
        $gdbthis=1;
    }
    elsif($ARGV[0] eq "-s") {
        # short output
        $short=1;
    }
Daniel Stenberg's avatar
Daniel Stenberg committed
    elsif($ARGV[0] eq "-a") {
        # continue anyway, even if a test fail
        $anyway=1;
    }
Daniel Stenberg's avatar
Daniel Stenberg committed
    elsif($ARGV[0] eq "-l") {
        # lists the test case names only
        $listonly=1;
    }
    elsif($ARGV[0] eq "-k") {
        # keep stdout and stderr files after tests
        $keepoutfiles=1;
    }
Daniel Stenberg's avatar
Daniel Stenberg committed
    elsif($ARGV[0] eq "-h") {
        # show help text
        print <<EOHELP
Usage: runtests.pl [options]
Daniel Stenberg's avatar
Daniel Stenberg committed
  -a       continue even if a test fails
  -g       run the test case with gdb
Daniel Stenberg's avatar
Daniel Stenberg committed
  -h       this help text
  -k       keep stdout and stderr files present after tests
Daniel Stenberg's avatar
Daniel Stenberg committed
  -l       list all test case names/descriptions
Daniel Stenberg's avatar
Daniel Stenberg committed
  -s       short output
  -v       verbose output
  [num]    like "5 6 9" or " 5 to 22 " to run those tests only
        $number = $1;
        if($fromnum >= 0) {
            for($fromnum .. $number) {
                push @testthis, $_;
            }
            $fromnum = -1;
        }
        else {
            push @testthis, $1;
        }
    }
    elsif($ARGV[0] =~ /^to$/i) {
        $fromnum = $number+1;
if($testthis[0] ne "") {
    $TESTCASES=join(" ", @testthis);
}

#######################################################################
# Output curl version and host info being tested
#

if(!$listonly) {
    displaydata();
}

#######################################################################
# clear and create logging directory:
cleardir($LOGDIR);
mkdir($LOGDIR, 0777);

#######################################################################
# If 'all' tests are requested, find out all test numbers
#

if ( $TESTCASES eq "all") {
    # Get all commands and find out their test numbers
    opendir(DIR, $TESTDIR) || die "can't opendir $TESTDIR: $!";
    my @cmds = grep { /^test([0-9]+)$/ && -f "$TESTDIR/$_" } readdir(DIR);
    $TESTCASES=""; # start with no test cases

    # cut off everything but the digits 
    }
    # the the numbers from low to high
    for(sort { $a <=> $b } @cmds) {
#######################################################################
# Start the command line log
#
open(CMDLOG, ">$CURLLOG") ||
    print "can't log command lines to $CURLLOG\n";

#######################################################################
# The main test-loop
#

Daniel Stenberg's avatar
Daniel Stenberg committed
my $testnum;
foreach $testnum (split(" ", $TESTCASES)) {

    my $error = singletest($testnum);
    if(-1 == $error) {
        # not a test we can run
        $failed.= "$testnum ";
        if(!$anyway) {
            # a test failed, abort
            print "\n - abort tests\n";
            last;
        }
#######################################################################
# Close command log
#
close(CMDLOG);

#######################################################################
# Tests done, stop the servers
print "Shutting down test suite servers:\n" if (!$short);
for(keys %run) {
Daniel Stenberg's avatar
Daniel Stenberg committed
    printf ("* kill pid for %-5s => %-5d\n", $_, $run{$_}) if(!$short);
    stopserver($run{$_}); # the pid file is in the hash table
}
    printf("TESTDONE: $ok tests out of $total reported OK: %d%%\n",
        print "TESTFAIL: These test cases failed: $failed\n";
    print "TESTFAIL: No tests were performed!\n";
if($skipped) {
    print "TESTINFO: $skipped tests were skipped due to restraints\n";
if($problems) {
    print "TESTINFO: $problems tests didn't run due to run-time problems\n";
}
if($total && ($ok != $total)) {
    exit 1;
}