From 7e359bccd2420a88bccf5d174275bfaf0b819e13 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 18 Apr 2020 23:41:07 +0200 Subject: 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... --- tests/server/sockfilt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'tests/server') diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 82bc7b8cf..84c72f960 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -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); -- cgit v1.2.3