osdir.com
mailing list archive

Subject: cvs: curl/tests/server sws.c,1.25,1.26 - msg#00050

List: web.curl.cvs

Date: Prev Next Index Thread: Prev Next Index
Update of /cvsroot/curl/curl/tests/server
In directory sc8-pr-cvs1:/tmp/cvs-serv21748/server

Modified Files:
sws.c
Log Message:
report pid back in the WE ROOLZ message


Index: sws.c
===================================================================
RCS file: /cvsroot/curl/curl/tests/server/sws.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- sws.c 15 Mar 2003 16:05:47 -0000 1.25
+++ sws.c 15 Mar 2003 16:39:45 -0000 1.26
@@ -88,10 +88,6 @@
"HTTP/1.1 501 Forbidden you fool\r\n"
"\r\n";

-/* sent as reply to the magic to find out if we are the test server or
- not */
-static const char *docfriends = "HTTP/1.1 200 Mighty fine indeed\r\n\r\nWE
ROOLZ\r\n";
-
/* send back this on 404 file not found */
static const char *doc404 = "HTTP/1.1 404 Not Found\n"
"Server: " VERSION "\n"
@@ -332,6 +328,8 @@
int cmdsize=0;
FILE *dump;

+ static char weare[256];
+
char filename[256];
char partbuf[80]="data";

@@ -340,7 +338,9 @@
case DOCNUMBER_WERULEZ:
/* we got a "friends?" question, reply back that we sure are */
logmsg("Identifying ourselves as friends");
- buffer = docfriends;
+ sprintf(weare, "HTTP/1.1 200 OK\r\n\r\nWE ROOLZ: %d\r\n",
+ getpid());
+ buffer = weare;
break;
case DOCNUMBER_INTERNAL:
logmsg("Bailing out due to internal error");



-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open!
Get cracking and register here for some mind boggling fun and
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en




Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

cvs: curl/tests ftpserver.pl,1.29,1.30

Update of /cvsroot/curl/curl/tests In directory sc8-pr-cvs1:/tmp/cvs-serv21596 Modified Files: ftpserver.pl Log Message: report pid back in the WE ROOLZ message Index: ftpserver.pl =================================================================== RCS file: /cvsroot/curl/curl/tests/ftpserver.pl,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- ftpserver.pl 26 Feb 2003 17:05:36 -0000 1.29 +++ ftpserver.pl 15 Mar 2003 16:39:15 -0000 1.30 @@ -211,9 +211,12 @@ # this is the secret command that verifies that this actually is # the curl test server print "150 Binary junk (10 bytes).\r\n"; - print SOCK "WE ROOLZ\r\n"; + print SOCK "WE ROOLZ: $$\r\n"; close(SOCK); print "226 File transfer complete\r\n"; + if($verbose) { + print STDERR "FTPD: We returned proof we are the test server\n"; + } return 0; } @@ -439,8 +442,9 @@ print @welcome; if($verbose) { - print STDERR "OUT:\n"; - print STDERR @welcome; + for(@welcome) { + print STDERR "OUT: $_"; + } } my $state="fresh"; ------------------------------------------------------- This SF.net email is sponsored by:Crypto Challenge is now open! Get cracking and register here for some mind boggling fun and the chance of winning an Apple iPod: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en

Next Message by Date: click to view message preview

cvs: curl/tests runtests.pl,1.73,1.74

Update of /cvsroot/curl/curl/tests In directory sc8-pr-cvs1:/tmp/cvs-serv22198 Modified Files: runtests.pl Log Message: * use the pid returned back from test-servers and kill them before starting them the first time * verify that the server we start really comes up fine and works as expected before continue * count test cases where the server can't be run (for whatever reason) * prefix lots of messages with RUN: to make it easier to realize which script is saying what when running tests verbose * remove the generic sleep(1) from each test, makes the suite fly! ;-) I hope these changes will make the tests run somewhat more reliably on more platforms. Index: runtests.pl =================================================================== RCS file: /cvsroot/curl/curl/tests/runtests.pl,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- runtests.pl 27 Jan 2003 13:51:35 -0000 1.73 +++ runtests.pl 15 Mar 2003 16:43:58 -0000 1.74 @@ -66,7 +66,8 @@ my $ssl_version; # set if libcurl is built with SSL support -my $skipped=0; # number of tests skipped; reported in main loop +my $skipped=0; # number of tests skipped; reported in main loop +my $problems=0; # number of tests that didn't run due to run-time problems ####################################################################### # variables the command line options may set @@ -94,7 +95,7 @@ sub serverpid { my $PIDFILE = $_[0]; open(PFILE, "<$PIDFILE"); - my $PID=<PFILE>; + my $PID=0+<PFILE>; close(PFILE); return $PID; } @@ -112,10 +113,10 @@ unlink $PIDFILE; # server is killed if($res && $verbose) { - print "Test server pid $PID signalled to die\n"; + print "RUN: Test server pid $PID signalled to die\n"; } elsif($verbose) { - print "Test server pid $PID didn't exist\n"; + print "RUN: Test server pid $PID didn't exist\n"; } } } @@ -157,42 +158,36 @@ $pid = checkserver ($HTTPPIDFILE); # verify if our/any server is running on this port - my $data=`$CURL --silent -i $HOSTIP:$HOSTPORT/verifiedserver 2>/dev/null`; - - if ( $data =~ /WE ROOLZ(: |)(\d*)/ ) { - if($2) { - $pid = 0+$2; - } - - if(!$pid) { - print "Test server already running with unknown pid! Use it...\n"; - return; - } - - if($verbose) { - print "Test server already running with pid $pid, killing it...\n"; - } - } - elsif($data ne "") { - print "GOT: $data\n"; - print "An alien HTTP server is running on port $HOSTPORT\n", - "Edit runtests.pl to use another port and rerun the test script\n"; - exit; - } - else { - if($verbose) { - print "No server running, start it\n"; - } + my $cmd = "$CURL -o log/verifiedserver --silent -i $HOSTIP:$HOSTPORT/verifiedserver 2>/dev/null"; + print "CMD; $cmd" if ($verbose); + my $res = system($cmd); + + $res >>= 8; # rotate the result + my $data; + + print "RUN: curl command returned $res\n" if ($verbose); + + open(FILE, "<log/verifiedserver"); + my @file=<FILE>; + close(FILE); + $data=$file[0]; # first line + + if ( $data =~ /WE ROOLZ: (\d+)/ ) { + $pid = 0+$1; + } + elsif($data) { + print "RUN: Unknown HTTP server is running on port $HOSTPORT\n"; + return 2; } if($pid > 0) { my $res = kill (9, $pid); # die! if(!$res) { - print "Failed to kill our HTTP test server, do it manually and", + print "RUN: Failed to kill test HTTP server, do it manually and", " restart the tests.\n"; exit; } - sleep(2); + sleep(1); } my $flag=$debugprotocol?"-v ":""; @@ -202,6 +197,30 @@ print "CMD: $cmd\n"; } + my $verified; + for(1 .. 5) { + # verify that our server is up and running: + my $data=`$CURL --silent -i $HOSTIP:$HOSTPORT/verifiedserver 2>/dev/null`; + + if ( $data !~ /WE ROOLZ/ ) { + sleep(1); + next; + } + else { + $verified = 1; + last; + } + } + if(!$verified) { + print STDERR "RUN: failed to start our HTTP server\n"; + return 1; + } + + if($verbose) { + print "RUN: HTTP server is now verified to be our server\n"; + } + + return 0; } ####################################################################### @@ -216,7 +235,7 @@ if($PID > 0) { # kill previous stunnel! if($verbose) { - print "kills off running stunnel at $PID\n"; + print "RUN: kills off running stunnel at $PID\n"; } stopserver($HTTPSPIDFILE); } @@ -227,6 +246,7 @@ if($verbose) { print "CMD: $cmd\n"; } + sleep(1); } ####################################################################### @@ -240,42 +260,72 @@ my $pid = checkserver ($FTPPIDFILE ); if ($pid <= 0) { - my $flag=$debugprotocol?"-v ":""; + print "RUN: Check port $FTPPORT for our own FTP server\n" + if ($verbose); - # verify that our server is NOT running on this port: - my $data=`$CURL --silent -i ftp://$HOSTIP:$FTPPORT/verifiedserver 2>/dev/null`; - if ( $data =~ /WE ROOLZ/ ) { - print "A previous FTP server session is already running and we ", - "can't kill it!\n"; - exit; + my $time=time(); + # check if this is our server running on this port: + my $data=`$CURL -m4 --silent -i ftp://$HOSTIP:$FTPPORT/verifiedserver 2>/dev/null`; + + # if this took more than 2 secs, we assume it "hung" on a weird server + my $took = time()-$time; + + if ( $data =~ /WE ROOLZ: (\d+)/ ) { + # this is our test server with a known pid! + $pid = $1; } - - my $cmd="$perl $srcdir/ftpserver.pl $flag $FTPPORT &"; - if($verbose) { - print "CMD: $cmd\n"; + else { + if($data || ($took > 2)) { + # this is not a known server + print "RUN: Unknown server on our favourite port: $FTPPORT\n"; + return 1; + } } - system($cmd); } - else { - if($verbose) { - print "ftpd ($pid) is already running\n"; + + if($pid > 0) { + print "RUN: Killing a previous server using pid $pid\n" if($verbose); + my $res = kill (9, $pid); # die! + if(!$res) { + print "RUN: Failed to kill our FTP test server, do it manually and", + " restart the tests.\n"; + exit; } + sleep(1); + } + + # now (re-)start our server: + my $flag=$debugprotocol?"-v ":""; + my $cmd="$perl $srcdir/ftpserver.pl $flag $FTPPORT &"; + if($verbose) { + print "CMD: $cmd\n"; + } + system($cmd); - # verify that our server is one one running on this port: + my $verified; + for(1 .. 5) { + # verify that our server is up and running: my $data=`$CURL --silent -i ftp://$HOSTIP:$FTPPORT/verifiedserver 2>/dev/null`; if ( $data !~ /WE ROOLZ/ ) { - print "Another FTP server is running on port $FTPPORT\n", - "Edit runtests.pl to use another FTP port and rerun the ", - "test script\n"; - exit; + sleep(1); + next; } - - if($verbose) { - print "The running FTP server has been verified to be our server\n"; + else { + $verified = 1; + last; } } + if(!$verified) { + die "RUN: failed to start our FTP server\n"; + } + + if($verbose) { + print "RUN: FTP server is now verified to be our server\n"; + } + + return 0; } ####################################################################### @@ -301,6 +351,7 @@ if($verbose) { print "CMD: $cmd\n"; } + sleep(1); } ####################################################################### @@ -440,7 +491,7 @@ if(loadtest("${TESTDIR}/test${testnum}")) { if($verbose) { # this is not a test - print "$testnum doesn't look like a test case!\n"; + print "RUN: $testnum doesn't look like a test case!\n"; } return -1; } @@ -450,7 +501,13 @@ if($serverproblem) { # there's a problem with the server, don't run # this particular server, but count it as "skipped" - $skipped++; + if($serverproblem> 1) { + print "RUN: test case $testnum couldn't run!\n"; + $problems++; + } + else { + $skipped++; + } return -1; } @@ -868,13 +925,17 @@ $what =~ s/[^a-z]//g; if($what eq "ftp") { if(!$run{'ftp'}) { - runftpserver($verbose); + if(runftpserver($verbose)) { + return 2; # error starting it + } $run{'ftp'}=$FTPPIDFILE; } } elsif($what eq "http") { if(!$run{'http'}) { - runhttpserver($verbose); + if(runhttpserver($verbose)) { + return 2; # error starting + } $run{'http'}=$HTTPPIDFILE; } } @@ -885,7 +946,9 @@ return 1; } if(!$run{'ftp'}) { - runftpserver($verbose); + if(runftpserver($verbose)) { + return 2; # error starting it + } $run{'ftp'}=$FTPPIDFILE; } if(!$run{'ftps'}) { @@ -903,7 +966,9 @@ return 1; } if(!$run{'http'}) { - runhttpserver($verbose); + if(runhttpserver($verbose)) { + return 2; # problems starting server + } $run{'http'}=$HTTPPIDFILE; } if(!$run{'https'}) { @@ -915,7 +980,6 @@ warn "we don't support a server for $what"; } } - sleep 1; # give a second for the server(s) to startup return 0; # ok } @@ -1100,6 +1164,9 @@ } 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; ------------------------------------------------------- This SF.net email is sponsored by:Crypto Challenge is now open! Get cracking and register here for some mind boggling fun and the chance of winning an Apple iPod: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en

Previous Message by Thread: click to view message preview

cvs: curl/tests ftpserver.pl,1.29,1.30

Update of /cvsroot/curl/curl/tests In directory sc8-pr-cvs1:/tmp/cvs-serv21596 Modified Files: ftpserver.pl Log Message: report pid back in the WE ROOLZ message Index: ftpserver.pl =================================================================== RCS file: /cvsroot/curl/curl/tests/ftpserver.pl,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- ftpserver.pl 26 Feb 2003 17:05:36 -0000 1.29 +++ ftpserver.pl 15 Mar 2003 16:39:15 -0000 1.30 @@ -211,9 +211,12 @@ # this is the secret command that verifies that this actually is # the curl test server print "150 Binary junk (10 bytes).\r\n"; - print SOCK "WE ROOLZ\r\n"; + print SOCK "WE ROOLZ: $$\r\n"; close(SOCK); print "226 File transfer complete\r\n"; + if($verbose) { + print STDERR "FTPD: We returned proof we are the test server\n"; + } return 0; } @@ -439,8 +442,9 @@ print @welcome; if($verbose) { - print STDERR "OUT:\n"; - print STDERR @welcome; + for(@welcome) { + print STDERR "OUT: $_"; + } } my $state="fresh"; ------------------------------------------------------- This SF.net email is sponsored by:Crypto Challenge is now open! Get cracking and register here for some mind boggling fun and the chance of winning an Apple iPod: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en

Next Message by Thread: click to view message preview

cvs: curl/tests runtests.pl,1.73,1.74

Update of /cvsroot/curl/curl/tests In directory sc8-pr-cvs1:/tmp/cvs-serv22198 Modified Files: runtests.pl Log Message: * use the pid returned back from test-servers and kill them before starting them the first time * verify that the server we start really comes up fine and works as expected before continue * count test cases where the server can't be run (for whatever reason) * prefix lots of messages with RUN: to make it easier to realize which script is saying what when running tests verbose * remove the generic sleep(1) from each test, makes the suite fly! ;-) I hope these changes will make the tests run somewhat more reliably on more platforms. Index: runtests.pl =================================================================== RCS file: /cvsroot/curl/curl/tests/runtests.pl,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- runtests.pl 27 Jan 2003 13:51:35 -0000 1.73 +++ runtests.pl 15 Mar 2003 16:43:58 -0000 1.74 @@ -66,7 +66,8 @@ my $ssl_version; # set if libcurl is built with SSL support -my $skipped=0; # number of tests skipped; reported in main loop +my $skipped=0; # number of tests skipped; reported in main loop +my $problems=0; # number of tests that didn't run due to run-time problems ####################################################################### # variables the command line options may set @@ -94,7 +95,7 @@ sub serverpid { my $PIDFILE = $_[0]; open(PFILE, "<$PIDFILE"); - my $PID=<PFILE>; + my $PID=0+<PFILE>; close(PFILE); return $PID; } @@ -112,10 +113,10 @@ unlink $PIDFILE; # server is killed if($res && $verbose) { - print "Test server pid $PID signalled to die\n"; + print "RUN: Test server pid $PID signalled to die\n"; } elsif($verbose) { - print "Test server pid $PID didn't exist\n"; + print "RUN: Test server pid $PID didn't exist\n"; } } } @@ -157,42 +158,36 @@ $pid = checkserver ($HTTPPIDFILE); # verify if our/any server is running on this port - my $data=`$CURL --silent -i $HOSTIP:$HOSTPORT/verifiedserver 2>/dev/null`; - - if ( $data =~ /WE ROOLZ(: |)(\d*)/ ) { - if($2) { - $pid = 0+$2; - } - - if(!$pid) { - print "Test server already running with unknown pid! Use it...\n"; - return; - } - - if($verbose) { - print "Test server already running with pid $pid, killing it...\n"; - } - } - elsif($data ne "") { - print "GOT: $data\n"; - print "An alien HTTP server is running on port $HOSTPORT\n", - "Edit runtests.pl to use another port and rerun the test script\n"; - exit; - } - else { - if($verbose) { - print "No server running, start it\n"; - } + my $cmd = "$CURL -o log/verifiedserver --silent -i $HOSTIP:$HOSTPORT/verifiedserver 2>/dev/null"; + print "CMD; $cmd" if ($verbose); + my $res = system($cmd); + + $res >>= 8; # rotate the result + my $data; + + print "RUN: curl command returned $res\n" if ($verbose); + + open(FILE, "<log/verifiedserver"); + my @file=<FILE>; + close(FILE); + $data=$file[0]; # first line + + if ( $data =~ /WE ROOLZ: (\d+)/ ) { + $pid = 0+$1; + } + elsif($data) { + print "RUN: Unknown HTTP server is running on port $HOSTPORT\n"; + return 2; } if($pid > 0) { my $res = kill (9, $pid); # die! if(!$res) { - print "Failed to kill our HTTP test server, do it manually and", + print "RUN: Failed to kill test HTTP server, do it manually and", " restart the tests.\n"; exit; } - sleep(2); + sleep(1); } my $flag=$debugprotocol?"-v ":""; @@ -202,6 +197,30 @@ print "CMD: $cmd\n"; } + my $verified; + for(1 .. 5) { + # verify that our server is up and running: + my $data=`$CURL --silent -i $HOSTIP:$HOSTPORT/verifiedserver 2>/dev/null`; + + if ( $data !~ /WE ROOLZ/ ) { + sleep(1); + next; + } + else { + $verified = 1; + last; + } + } + if(!$verified) { + print STDERR "RUN: failed to start our HTTP server\n"; + return 1; + } + + if($verbose) { + print "RUN: HTTP server is now verified to be our server\n"; + } + + return 0; } ####################################################################### @@ -216,7 +235,7 @@ if($PID > 0) { # kill previous stunnel! if($verbose) { - print "kills off running stunnel at $PID\n"; + print "RUN: kills off running stunnel at $PID\n"; } stopserver($HTTPSPIDFILE); } @@ -227,6 +246,7 @@ if($verbose) { print "CMD: $cmd\n"; } + sleep(1); } ####################################################################### @@ -240,42 +260,72 @@ my $pid = checkserver ($FTPPIDFILE ); if ($pid <= 0) { - my $flag=$debugprotocol?"-v ":""; + print "RUN: Check port $FTPPORT for our own FTP server\n" + if ($verbose); - # verify that our server is NOT running on this port: - my $data=`$CURL --silent -i ftp://$HOSTIP:$FTPPORT/verifiedserver 2>/dev/null`; - if ( $data =~ /WE ROOLZ/ ) { - print "A previous FTP server session is already running and we ", - "can't kill it!\n"; - exit; + my $time=time(); + # check if this is our server running on this port: + my $data=`$CURL -m4 --silent -i ftp://$HOSTIP:$FTPPORT/verifiedserver 2>/dev/null`; + + # if this took more than 2 secs, we assume it "hung" on a weird server + my $took = time()-$time; + + if ( $data =~ /WE ROOLZ: (\d+)/ ) { + # this is our test server with a known pid! + $pid = $1; } - - my $cmd="$perl $srcdir/ftpserver.pl $flag $FTPPORT &"; - if($verbose) { - print "CMD: $cmd\n"; + else { + if($data || ($took > 2)) { + # this is not a known server + print "RUN: Unknown server on our favourite port: $FTPPORT\n"; + return 1; + } } - system($cmd); } - else { - if($verbose) { - print "ftpd ($pid) is already running\n"; + + if($pid > 0) { + print "RUN: Killing a previous server using pid $pid\n" if($verbose); + my $res = kill (9, $pid); # die! + if(!$res) { + print "RUN: Failed to kill our FTP test server, do it manually and", + " restart the tests.\n"; + exit; } + sleep(1); + } + + # now (re-)start our server: + my $flag=$debugprotocol?"-v ":""; + my $cmd="$perl $srcdir/ftpserver.pl $flag $FTPPORT &"; + if($verbose) { + print "CMD: $cmd\n"; + } + system($cmd); - # verify that our server is one one running on this port: + my $verified; + for(1 .. 5) { + # verify that our server is up and running: my $data=`$CURL --silent -i ftp://$HOSTIP:$FTPPORT/verifiedserver 2>/dev/null`; if ( $data !~ /WE ROOLZ/ ) { - print "Another FTP server is running on port $FTPPORT\n", - "Edit runtests.pl to use another FTP port and rerun the ", - "test script\n"; - exit; + sleep(1); + next; } - - if($verbose) { - print "The running FTP server has been verified to be our server\n"; + else { + $verified = 1; + last; } } + if(!$verified) { + die "RUN: failed to start our FTP server\n"; + } + + if($verbose) { + print "RUN: FTP server is now verified to be our server\n"; + } + + return 0; } ####################################################################### @@ -301,6 +351,7 @@ if($verbose) { print "CMD: $cmd\n"; } + sleep(1); } ####################################################################### @@ -440,7 +491,7 @@ if(loadtest("${TESTDIR}/test${testnum}")) { if($verbose) { # this is not a test - print "$testnum doesn't look like a test case!\n"; + print "RUN: $testnum doesn't look like a test case!\n"; } return -1; } @@ -450,7 +501,13 @@ if($serverproblem) { # there's a problem with the server, don't run # this particular server, but count it as "skipped" - $skipped++; + if($serverproblem> 1) { + print "RUN: test case $testnum couldn't run!\n"; + $problems++; + } + else { + $skipped++; + } return -1; } @@ -868,13 +925,17 @@ $what =~ s/[^a-z]//g; if($what eq "ftp") { if(!$run{'ftp'}) { - runftpserver($verbose); + if(runftpserver($verbose)) { + return 2; # error starting it + } $run{'ftp'}=$FTPPIDFILE; } } elsif($what eq "http") { if(!$run{'http'}) { - runhttpserver($verbose); + if(runhttpserver($verbose)) { + return 2; # error starting + } $run{'http'}=$HTTPPIDFILE; } } @@ -885,7 +946,9 @@ return 1; } if(!$run{'ftp'}) { - runftpserver($verbose); + if(runftpserver($verbose)) { + return 2; # error starting it + } $run{'ftp'}=$FTPPIDFILE; } if(!$run{'ftps'}) { @@ -903,7 +966,9 @@ return 1; } if(!$run{'http'}) { - runhttpserver($verbose); + if(runhttpserver($verbose)) { + return 2; # problems starting server + } $run{'http'}=$HTTPPIDFILE; } if(!$run{'https'}) { @@ -915,7 +980,6 @@ warn "we don't support a server for $what"; } } - sleep 1; # give a second for the server(s) to startup return 0; # ok } @@ -1100,6 +1164,9 @@ } 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; ------------------------------------------------------- This SF.net email is sponsored by:Crypto Challenge is now open! Get cracking and register here for some mind boggling fun and the chance of winning an Apple iPod: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by