tests: move pingpong server to dynamic listening port

FTP, IMAP, POP3, SMTP and their IPv6 versions are now all on dynamic
ports

Test 842-845 are unfortunately a bit hard to move over to this concept
right now and require "default port" still...
This commit is contained in:
Daniel Stenberg 2020-04-18 23:41:07 +02:00
parent f99b007cd8
commit 7e359bccd2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 92 additions and 62 deletions

View file

@ -1304,6 +1304,7 @@ int main(int argc, char *argv[])
curl_socket_t msgsock = CURL_SOCKET_BAD;
int wrotepidfile = 0;
const char *pidname = ".sockfilt.pid";
const char *portfile = NULL; /* none by default */
bool juggle_again;
int rc;
int error;
@ -1331,6 +1332,11 @@ int main(int argc, char *argv[])
if(argc>arg)
pidname = argv[arg++];
}
else if(!strcmp("--portfile", argv[arg])) {
arg++;
if(argc > arg)
portfile = argv[arg++];
}
else if(!strcmp("--logfile", argv[arg])) {
arg++;
if(argc>arg)
@ -1360,12 +1366,6 @@ int main(int argc, char *argv[])
if(argc>arg) {
char *endptr;
unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
if((endptr != argv[arg] + strlen(argv[arg])) ||
((ulnum != 0UL) && ((ulnum < 1025UL) || (ulnum > 65535UL)))) {
fprintf(stderr, "sockfilt: invalid --port argument (%s)\n",
argv[arg]);
return 0;
}
port = curlx_ultous(ulnum);
arg++;
}
@ -1501,6 +1501,13 @@ int main(int argc, char *argv[])
write_stdout("FAIL\n", 5);
goto sockfilt_cleanup;
}
if(portfile) {
wrotepidfile = write_portfile(portfile, port);
if(!wrotepidfile) {
write_stdout("FAIL\n", 5);
goto sockfilt_cleanup;
}
}
do {
juggle_again = juggle(&msgsock, sock, &mode);