From d009bc2e565844db030d7098624b39b2903a808d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 17 Apr 2020 09:58:42 +0200 Subject: 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. --- tests/server/fake_ntlm.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'tests/server/fake_ntlm.c') diff --git a/tests/server/fake_ntlm.c b/tests/server/fake_ntlm.c index c6e36b6f6..c9211f7ea 100644 --- a/tests/server/fake_ntlm.c +++ b/tests/server/fake_ntlm.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2010, Mandy Wu, - * Copyright (C) 2011 - 2018, Daniel Stenberg, , et al. + * Copyright (C) 2011 - 2020, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -112,7 +112,6 @@ int main(int argc, char *argv[]) char buf[1024]; char logfilename[256]; FILE *stream; - char *filename; int error; char *type1_input = NULL, *type3_input = NULL; char *type1_output = NULL, *type3_output = NULL; @@ -186,12 +185,10 @@ int main(int argc, char *argv[]) path = env; } - filename = test2file(testnum); - stream = fopen(filename, "rb"); + stream = test2fopen(testnum); 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 %ld", testnum); exit(1); } @@ -205,13 +202,11 @@ int main(int argc, char *argv[]) } } - stream = fopen(filename, "rb"); + stream = test2fopen(testnum); 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 %ld", testnum); - exit(1); } else { size = 0; @@ -225,11 +220,10 @@ int main(int argc, char *argv[]) while(fgets(buf, sizeof(buf), stdin)) { if(strcmp(buf, type1_input) == 0) { - stream = fopen(filename, "rb"); + stream = test2fopen(testnum); 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 %ld", testnum); exit(1); } @@ -247,11 +241,10 @@ int main(int argc, char *argv[]) fflush(stdout); } else if(strncmp(buf, type3_input, strlen(type3_input)) == 0) { - stream = fopen(filename, "rb"); + stream = test2fopen(testnum); 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 %ld", testnum); exit(1); } -- cgit v1.2.3