diff options
author | Yang Tse <yangsita@gmail.com> | 2007-02-19 02:03:58 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2007-02-19 02:03:58 +0000 |
commit | 31e598d2f39e2d4afc1e6f0a0b960f378e86da31 (patch) | |
tree | d777ed14663ee680c3a8c3baf63f00ce850558a8 /tests/server | |
parent | cbf58d88d0a84042d9dd8a7a6b1644f15242cf02 (diff) |
add debug messages for initialization failures
Diffstat (limited to 'tests/server')
-rw-r--r-- | tests/server/sockfilt.c | 10 | ||||
-rw-r--r-- | tests/server/sws.c | 19 | ||||
-rw-r--r-- | tests/server/tftpd.c | 19 | ||||
-rw-r--r-- | tests/server/util.c | 4 |
4 files changed, 43 insertions, 9 deletions
diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index b1fd71980..ab6682ec5 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -353,7 +353,7 @@ static int juggle(curl_socket_t *sockfdp, client connecting. */ sockfd = accept(sockfd, NULL, NULL); if(CURL_SOCKET_BAD == sockfd) - logmsg("accept() failed\n"); + logmsg("accept() failed"); else { logmsg("====> Client connect"); write(fileno(stdout), "CNCT\n", 5); @@ -438,7 +438,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock, if(getsockname(sock, (struct sockaddr *) &add, &socksize)<0) { - fprintf(stderr, "getsockname() failed"); + logmsg("getsockname() failed with error: %d", SOCKERRNO); return CURL_SOCKET_BAD; } *port = ntohs(add.sin_port); @@ -489,6 +489,7 @@ int main(int argc, char *argv[]) FILE *pidfile; char *pidname= (char *)".sockfilt.pid"; int rc; + int error; int arg=1; enum sockmode mode = PASSIVE_LISTEN; /* default */ @@ -631,7 +632,10 @@ int main(int argc, char *argv[]) logmsg("Wrote pid %d to %s", pid, pidname); } else { - fprintf(stderr, "Couldn't write pid file\n"); + error = ERRNO; + logmsg("fopen() failed with error: %d %s\n", error, strerror(error)); + logmsg("Error opening file: %s\n", pidname); + logmsg("Couldn't write pid file\n"); sclose(sock); return 1; } diff --git a/tests/server/sws.c b/tests/server/sws.c index 88f72218f..2ff9eb80c 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -197,6 +197,7 @@ int ProcessRequest(struct httprequest *req) char logbuf[256]; int prot_major, prot_minor; char *end; + int error; end = strstr(line, END_OF_HEADERS); logmsg("ProcessRequest() called"); @@ -263,6 +264,9 @@ int ProcessRequest(struct httprequest *req) stream=fopen(filename, "rb"); if(!stream) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", filename); logmsg("Couldn't open test file %d", req->testno); req->open = FALSE; /* closes connection */ return 1; /* done */ @@ -569,6 +573,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) FILE *dump; int persistant = TRUE; size_t responsesize; + int error; static char weare[256]; @@ -646,6 +651,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) stream=fopen(filename, "rb"); if(!stream) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", filename); logmsg("Couldn't open test file"); return 0; } @@ -658,6 +666,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) /* re-open the same file again */ stream=fopen(filename, "rb"); if(!stream) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", filename); logmsg("Couldn't open test file"); return 0; } @@ -670,6 +681,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) dump = fopen(RESPONSE_DUMP, "ab"); /* b is for windows-preparing */ if(!dump) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", RESPONSE_DUMP); logmsg("couldn't create logfile: " RESPONSE_DUMP); return -1; } @@ -872,7 +886,10 @@ int main(int argc, char *argv[]) fclose(pidfile); } else { - fprintf(stderr, "Couldn't write pid file\n"); + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", pidname); + logmsg("Couldn't write pid file"); sclose(sock); return 1; } diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index a97325b7a..e7fae0d47 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -424,6 +424,7 @@ int main(int argc, char **argv) curl_socket_t sock; int flag; int rc; + int error; struct testcase test; while(argc>arg) { @@ -513,8 +514,12 @@ int main(int argc, char **argv) fprintf(pidfile, "%d\n", (int)getpid()); fclose(pidfile); } - else - fprintf(stderr, "Couldn't write pid file\n"); + else { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", pidname); + logmsg("Couldn't write pid file"); + } logmsg("Running IPv%d version on port UDP/%d", #ifdef ENABLE_IPV6 @@ -554,8 +559,12 @@ int main(int argc, char **argv) if (tp->th_opcode == RRQ || tp->th_opcode == WRQ) { memset(&test, 0, sizeof(test)); server = fopen(REQUEST_DUMP, "ab"); - if(!server) + if(!server) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", REQUEST_DUMP); break; + } test.server = server; tftp(&test, tp, n); if(test.buffer) @@ -645,6 +654,7 @@ static int validate_access(struct testcase *test, { char *ptr; long testno; + int error; logmsg("trying to get file: %s mode %x", filename, mode); @@ -684,6 +694,9 @@ static int validate_access(struct testcase *test, if(file) { FILE *stream=fopen(file, "rb"); if(!stream) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", file); logmsg("Couldn't open test file: %s", file); return EACCESS; } diff --git a/tests/server/util.c b/tests/server/util.c index 7db611597..080ef4759 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -130,7 +130,7 @@ void win32_init(void) if (err != 0) { perror("Winsock init failed"); - logmsg("Error initialising winsock -- aborting\n"); + logmsg("Error initialising winsock -- aborting"); exit(1); } @@ -139,7 +139,7 @@ void win32_init(void) WSACleanup(); perror("Winsock init failed"); - logmsg("No suitable winsock.dll found -- aborting\n"); + logmsg("No suitable winsock.dll found -- aborting"); exit(1); } } |