mirror of
https://github.com/curl/curl.git
synced 2026-07-28 00:53:06 +03:00
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:
parent
5e2f4a33fe
commit
d009bc2e56
10 changed files with 171 additions and 177 deletions
|
|
@ -944,16 +944,12 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
|
|||
static int parse_servercmd(struct testcase *req)
|
||||
{
|
||||
FILE *stream;
|
||||
char *filename;
|
||||
int error;
|
||||
|
||||
filename = test2file(req->testno);
|
||||
|
||||
stream = fopen(filename, "rb");
|
||||
stream = test2fopen(req->testno);
|
||||
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);
|
||||
return 1; /* done */
|
||||
}
|
||||
|
|
@ -1036,7 +1032,7 @@ static int validate_access(struct testcase *test,
|
|||
char partbuf[80]="data";
|
||||
long partno;
|
||||
long testno;
|
||||
char *file;
|
||||
FILE *stream;
|
||||
|
||||
ptr++; /* skip the slash */
|
||||
|
||||
|
|
@ -1061,40 +1057,33 @@ static int validate_access(struct testcase *test,
|
|||
|
||||
(void)parse_servercmd(test);
|
||||
|
||||
file = test2file(testno);
|
||||
stream = test2fopen(testno);
|
||||
|
||||
if(0 != partno)
|
||||
msnprintf(partbuf, sizeof(partbuf), "data%ld", partno);
|
||||
|
||||
if(file) {
|
||||
FILE *stream = fopen(file, "rb");
|
||||
if(!stream) {
|
||||
int 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);
|
||||
if(!stream) {
|
||||
int error = errno;
|
||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||
logmsg("Couldn't open test file for test : %d", testno);
|
||||
return EACCESS;
|
||||
}
|
||||
else {
|
||||
size_t count;
|
||||
int error = getpart(&test->buffer, &count, "reply", partbuf, stream);
|
||||
fclose(stream);
|
||||
if(error) {
|
||||
logmsg("getpart() failed with error: %d", error);
|
||||
return EACCESS;
|
||||
}
|
||||
else {
|
||||
size_t count;
|
||||
int error = getpart(&test->buffer, &count, "reply", partbuf, stream);
|
||||
fclose(stream);
|
||||
if(error) {
|
||||
logmsg("getpart() failed with error: %d", error);
|
||||
return EACCESS;
|
||||
}
|
||||
if(test->buffer) {
|
||||
test->rptr = test->buffer; /* set read pointer */
|
||||
test->bufsize = count; /* set total count */
|
||||
test->rcount = count; /* set data left to read */
|
||||
}
|
||||
else
|
||||
return EACCESS;
|
||||
if(test->buffer) {
|
||||
test->rptr = test->buffer; /* set read pointer */
|
||||
test->bufsize = count; /* set total count */
|
||||
test->rcount = count; /* set data left to read */
|
||||
}
|
||||
|
||||
else
|
||||
return EACCESS;
|
||||
}
|
||||
else
|
||||
return EACCESS;
|
||||
}
|
||||
else {
|
||||
logmsg("no slash found in path");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue