aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-02-22 15:40:17 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-02-22 15:40:17 +0000
commit417c8fb602fb32bb1e97ffb607aec988dfbc5df4 (patch)
treee919696537fe82fa270596fe0477fb01c7ff1b8c
parent85efa64c31e7b4e5351e3d256bfe3365405a4523 (diff)
16 tests OK
-rwxr-xr-xtests/runtests.pl7
-rw-r--r--tests/server/sws.c20
2 files changed, 22 insertions, 5 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 931a22977..6e1136140 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -145,11 +145,18 @@ sub runhttpserver {
if ( $data =~ /WE ROOLZ(: |)(\d*)/ ) {
$pid = 0+$2;
+
+ if(!$pid) {
+ print "Test server already running with unkown 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;
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 1e75ef72d..9f3076aa5 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -29,7 +29,7 @@ char *spitout(FILE *stream, char *main, char *sub, int *size);
#define TEST_DATA_PATH "data/test%d"
-static char *docfriends = "WE ROOLZ\r\n";
+static char *docfriends = "HTTP/1.1 200 Mighty fine indeed\r\n\r\nWE ROOLZ\r\n";
static char *doc404 = "HTTP/1.1 404 Not Found\n"
"Server: " VERSION "\n"
"Connection: close\n"
@@ -125,7 +125,7 @@ void storerequest(char *reqbuf)
{
FILE *dump;
- dump = fopen(REQUEST_DUMP, "wb"); /* b is for windows-preparing */
+ dump = fopen(REQUEST_DUMP, "ab"); /* b is for windows-preparing */
if(dump) {
fwrite(reqbuf, 1, strlen(reqbuf), dump);
@@ -144,6 +144,7 @@ static int get_request(int sock, int *part)
char request[REQUEST_KEYWORD_SIZE];
unsigned int offset = 0;
int prot_major, prot_minor;
+ char logbuf[256];
*part = 0; /* part zero equals none */
@@ -189,7 +190,12 @@ static int get_request(int sock, int *part)
/* get the number after it */
if(ptr) {
- if(!strcmp("/verifiedserver", ptr)) {
+
+ sprintf(logbuf, "Got request: %s %s HTTP/%d.%d",
+ request, doc, prot_major, prot_minor);
+ logmsg(logbuf);
+
+ if(!strncmp("/verifiedserver", ptr, 15)) {
logmsg("Are-we-friendly question received");
return -2;
}
@@ -203,7 +209,8 @@ static int get_request(int sock, int *part)
test_no /= 10000;
}
- logmsg("Found test number in PATH");
+ sprintf(logbuf, "Found test number %d in path", test_no);
+ logmsg(logbuf);
}
else {
@@ -238,6 +245,8 @@ static int send_doc(int sock, int doc, int part_no)
buffer = doc404;
ptr = NULL;
stream=NULL;
+
+ count = strlen(buffer);
}
else {
sprintf(filename, TEST_DATA_PATH, doc);
@@ -258,7 +267,8 @@ static int send_doc(int sock, int doc, int part_no)
do {
written = send(sock, buffer, count, 0);
if (written < 0) {
- fclose(stream);
+ if(stream)
+ fclose(stream);
return -1;
}
count -= written;