Newer
Older
if(!$what[0]) {
warn "Test case $testnum has no server(s) specified!";
return 99;
for(@what) {
my $what = lc($_);
$what =~ s/[^a-z]//g;
if($what eq "ftp") {
if(!$run{'ftp'}) {
$pid = runftpserver($verbose);
if($pid <= 0) {
Daniel Stenberg
committed
return 2; # error starting it
}
$run{'ftp'}=$pid;
}
}
elsif($what eq "http") {
if(!$run{'http'}) {
$pid = runhttpserver($verbose);
if($pid <= 0) {
Daniel Stenberg
committed
return 2; # error starting
}
$run{'http'}=$pid;
}
}
elsif($what eq "ftps") {
if(!$checkstunnel || !$ssl_version) {
# we can't run https tests without stunnel
# or if libcurl is SSL-less
return 1;
}
$pid = runftpserver($verbose);
if($pid <= 0) {
Daniel Stenberg
committed
return 2; # error starting it
}
$run{'ftp'}=$pid;
$pid = runftpsserver($verbose);
if($pid <= 0) {
return 2;
}
$run{'ftps'}=$pid;
elsif($what eq "file") {
# we support it but have no server!
}
elsif($what eq "https") {
if(!$checkstunnel || !$ssl_version) {
# we can't run https tests without stunnel
# or if libcurl is SSL-less
return 1;
}
if(!$run{'http'}) {
$pid = runhttpserver($verbose);
if($pid <= 0) {
Daniel Stenberg
committed
return 2; # problems starting server
}
$run{'http'}=$pid;
$pid = runhttpsserver($verbose);
if($pid <= 0) {
return 2;
}
$run{'https'}=$pid;
else {
warn "we don't support a server for $what";
#######################################################################
# Check options to this test program
#
my $number=0;
my $fromnum=-1;
my @testthis;
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;
}
elsif($ARGV[0] eq "-a") {
# continue anyway, even if a test fail
$anyway=1;
}
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;
}
elsif($ARGV[0] eq "-h") {
# show help text
print <<EOHELP
-d display server debug info
-g run the test case with gdb
-k keep stdout and stderr files present after tests
[num] like "5 6 9" or " 5 to 22 " to run those tests only
elsif($ARGV[0] =~ /^(\d+)/) {
$number = $1;
if($fromnum >= 0) {
for($fromnum .. $number) {
push @testthis, $_;
}
$fromnum = -1;
}
else {
push @testthis, $1;
}
}
elsif($ARGV[0] =~ /^to$/i) {
}
} while(shift @ARGV);
if($testthis[0] ne "") {
$TESTCASES=join(" ", @testthis);
}
#######################################################################
# Output curl version and host info being tested
#
checkcurl();
#######################################################################
# 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);
closedir DIR;
$TESTCASES=""; # start with no test cases
# cut off everything but the digits
for(@cmds) {
$_ =~ s/[a-z\/\.]*//g;
}
# the the numbers from low to high
for(sort { $a <=> $b } @cmds) {
$TESTCASES .= " $_";
}
#######################################################################
# Start the command line log
#
open(CMDLOG, ">$CURLLOG") ||
print "can't log command lines to $CURLLOG\n";
#######################################################################
# The main test-loop
#
my $ok=0;
my $total=0;
my $lasttest;
foreach $testnum (split(" ", $TESTCASES)) {
$lasttest = $testnum if($testnum > $lasttest);
my $error = singletest($testnum);
if($error < 0) {
# not a test we can run
$total++; # number of tests we've run
if($error>0) {
if(!$anyway) {
# a test failed, abort
print "\n - abort tests\n";
last;
}
elsif(!$error) {
$ok++; # successful test counter
#######################################################################
# Close command log
#
close(CMDLOG);
#######################################################################
# Tests done, stop the servers
print "Shutting down test suite servers:\n" if (!$short);
printf ("* kill pid for %-5s => %-5d\n", $_, $run{$_}) if(!$short);
stopserver($run{$_}); # the pid file is in the hash table
}
Daniel Stenberg
committed
my $all = $total + $skipped;
if($total) {
printf("TESTDONE: $ok tests out of $total reported OK: %d%%\n",
if($ok != $total) {
print "TESTFAIL: These test cases failed: $failed\n";
}
else {
print "TESTFAIL: No tests were performed!\n";
Daniel Stenberg
committed
if($all) {
print "TESTDONE: $all tests were considered.\n";
}
my $s=0;
print "TESTINFO: $skipped tests were skipped due to these restraints:\n";
for(keys %skipped) {
my $r = $_;
Daniel Stenberg
committed
printf "TESTINFO: \"%s\" %d times (", $r, $skipped{$_};
# now show all test case numbers that had this reason for being
# skipped
my $c=0;
for(0 .. $lasttest) {
my $t = $_;
if($teststat[$_] eq $r) {
print ", " if($c);
print $_;
$c++;
}
}
print ")\n";
}
Daniel Stenberg
committed
}
if($total && ($ok != $total)) {
exit 1;
}