bind(Server, sockaddr_in($port, INADDR_ANY))|| die "bind: $!";
listen(Server,SOMAXCONN) || die "listen: $!";
-print "HTTP server started on port $port\n";
+if($verbose) {
+ print "HTTP server started on port $port\n";
+}
open(PID, ">.server.pid");
print PID $$;
my $testnum;
if($path =~ /.*\/(\d*)/) {
$testnum=$1;
+
+ if($verbose) {
+ print STDERR "sending reply $testnum\n";
+ }
}
else {
- print STDERR "UKNOWN TEST CASE\n";
- exit;
+ $testnum=0;
}
open(INPUT, ">log/server.input");
for(@headers) {
}
close(INPUT);
- # send a reply to the client
- open(DATA, "<data/reply$testnum.txt");
- while(<DATA>) {
- print $_;
+ if(0 == $testnum ) {
+ print "HTTP/1.1 200 OK\r\n",
+ "header: yes\r\n",
+ "\r\n",
+ "You must select a test number to get good data back\r\n";
+ }
+ else {
+ # send a custom reply to the client
+ open(DATA, "<data/reply$testnum.txt");
+ while(<DATA>) {
+ print $_;
+ }
+ close(DATA);
}
- close(DATA);
}
# print "Hello there, $name, it's now ", scalar localtime, "\r\n";
};
my $short;
my $verbose;
+my $anyway;
#######################################################################
# Return the pid of the http server as found in the pid file
my $res = kill (9, $PID); # die!
unlink $PIDFILE; # server is killed
- if($res) {
+ if($res && $verbose) {
print "TCP server signalled to die\n";
}
}
$res = comparefiles($first, $sec);
if ($res != 0) {
- print " $text FAILED";
+ if(!$short) {
+ print " $text FAILED";
+ }
return 1;
}
- print " $text OK";
+ if(!$short) {
+ print " $text OK";
+ }
return 0;
}
print "Running tests on:\n",
"* $version",
- "* host $hostname",
- "* system $hosttype";
+ "* Host: $hostname",
+ "* System: $hosttype";
if( -r $memdump) {
# if this exists, curl was compiled with memory debugging
# enabled and we shall verify that no memory leaks exist
# after each and every test!
$memory_debug=1;
- print "** Memory debugging ENABLED\n";
}
+ printf("* Memory debugging: %s\n", $memory_debug?"ON":"OFF");
+
}
#######################################################################
return 1;
}
else {
- print " memory OK";
+ if(!$short) {
+ print " memory OK";
+ }
}
}
}
}
+ if($short) {
+ print "OK";
+ }
print "\n";
return 0;
# short output
$short=1;
}
+ elsif($ARGV[0] eq "-a") {
+ # continue anyway, even if a test fail
+ $anyway=1;
+ }
elsif($ARGV[0] eq "-h") {
# show help text
print <<EOHELP
Usage: runtests.pl [-h][-s][-v][numbers]
+ -a continue even if a test fails
-h this help text
-s short output
-v verbose output
my $testnum;
foreach $testnum (split(" ", $TESTCASES)) {
- if(singletest($testnum)) {
+ if(singletest($testnum) && !$anyway) {
# a test failed, abort
print "\n - abort tests\n";
last;