aboutsummaryrefslogtreecommitdiff
path: root/tests/server/sws.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-04-17 09:58:42 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-04-18 22:46:04 +0200
commitd009bc2e565844db030d7098624b39b2903a808d (patch)
tree1ccef4e0c1a22960befd8bd413d6fc34e264e806 /tests/server/sws.c
parent5e2f4a33fe663c2ae8cc92c02193a7261c524867 (diff)
tests: introduce preprocessed test cases
The runtests script now always performs variable replacement on the entire test source file before the test gets executed, and saves the updated version in a temporary file (log/test[num]) so that all test case readers/servers can use that version (if present) and thus enjoy the powers of test case variable substitution. This is necessary to allow complete port number freedom. Test 309 is updated to work with a non-fixed port number thanks to this.
Diffstat (limited to 'tests/server/sws.c')
-rw-r--r--tests/server/sws.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index faa1143d9..48ea26d5e 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -235,18 +235,15 @@ static bool socket_domain_is_ip(void)
static int parse_servercmd(struct httprequest *req)
{
FILE *stream;
- char *filename;
int error;
- filename = test2file(req->testno);
+ stream = test2fopen(req->testno);
req->close = FALSE;
req->connmon = FALSE;
- stream = fopen(filename, "rb");
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
- logmsg(" [1] Error opening file: %s", filename);
logmsg(" Couldn't open test file %ld", req->testno);
req->open = FALSE; /* closes connection */
return 1; /* done */
@@ -991,7 +988,6 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
}
else {
char partbuf[80];
- char *filename = test2file(req->testno);
/* select the <data> tag for "normal" requests and the <connect> one
for CONNECT requests (within the <reply> section) */
@@ -1004,11 +1000,10 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
logmsg("Send response test%ld section <%s>", req->testno, partbuf);
- stream = fopen(filename, "rb");
+ stream = test2fopen(req->testno);
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
- logmsg(" [3] Error opening file: %s", filename);
return 0;
}
else {
@@ -1027,11 +1022,10 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
}
/* re-open the same file again */
- stream = fopen(filename, "rb");
+ stream = test2fopen(req->testno);
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
- logmsg(" [4] Error opening file: %s", filename);
free(ptr);
return 0;
}