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.
This commit is contained in:
Daniel Stenberg 2020-04-17 09:58:42 +02:00
parent 5e2f4a33fe
commit d009bc2e56
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 171 additions and 177 deletions

View file

@ -194,11 +194,21 @@ void win32_cleanup(void)
/* set by the main code to point to where the test dir is */
const char *path = ".";
char *test2file(long testno)
FILE *test2fopen(long testno)
{
static char filename[256];
FILE *stream;
char filename[256];
/* first try the alternative, preprocessed, file */
msnprintf(filename, sizeof(filename), ALTTEST_DATA_PATH, path, testno);
stream = fopen(filename, "rb");
if(stream)
return stream;
/* then try the source version */
msnprintf(filename, sizeof(filename), TEST_DATA_PATH, path, testno);
return filename;
stream = fopen(filename, "rb");
return stream;
}
/*