summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-08-05 15:11:22 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-08-06 23:51:48 +0200
commitf117396f346dd6969d092e1702c6c610fb13058d (patch)
tree8648a4bb63158a027abd5c1d72b55d07fe45a66c
parent337a28d810e9e3c1803f69a6801004c0c944ba90 (diff)
downloadcurl-bagder/dictserver-dynamic-port.tar.gz
runtests: run the DICT server on a random port numberbagder/dictserver-dynamic-port
Removed support for -b (base port number) Closes #5783
-rw-r--r--tests/runtests.12
-rwxr-xr-xtests/runtests.pl69
2 files changed, 25 insertions, 46 deletions
diff --git a/tests/runtests.1 b/tests/runtests.1
index 661616fab..e5037c8af 100644
--- a/tests/runtests.1
+++ b/tests/runtests.1
@@ -55,8 +55,6 @@ Prefix a keyword with a tilde (~) to still run it, but ignore the results.
.IP "-a"
Continue running the rest of the test cases even if one test fails. By
default, the test script stops as soon as an error is detected.
-.IP "-bN"
-Use N as the base TCP/UDP port number on which to start the test servers.
.IP "-c <curl>"
Provide a path to a custom curl binary to run the tests with. Default is the
curl executable in the build tree.
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 24ddaeeae..203301400 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -127,10 +127,6 @@ my $HOST6IP="[::1]"; # address on which the test server listens
my $CLIENTIP="127.0.0.1"; # address which curl uses for incoming connections
my $CLIENT6IP="[::1]"; # address which curl uses for incoming connections
-my $base = 8990; # base port number
-my $minport; # minimum used port number
-my $maxport; # maximum used port number
-
my $noport="[not running]";
my $NOLISTENPORT=47; # port number we use for a local non-listening service
@@ -2405,7 +2401,7 @@ sub runsocksserver {
# start the dict server
#
sub rundictserver {
- my ($verbose, $alt, $port) = @_;
+ my ($verbose, $alt) = @_;
my $proto = "dict";
my $ip = $HOSTIP;
my $ipvnum = 4;
@@ -2442,38 +2438,35 @@ sub rundictserver {
$flags .= "--verbose 1 " if($debugprotocol);
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--id $idnum " if($idnum > 1);
- $flags .= "--port $port --srcdir \"$srcdir\" ";
+ $flags .= "--srcdir \"$srcdir\" ";
$flags .= "--host $HOSTIP";
- my $cmd = "$srcdir/dictserver.py $flags";
- my ($dictpid, $pid2) = startnew($cmd, $pidfile, 15, 0);
-
- if($dictpid <= 0 || !pidexists($dictpid)) {
- # it is NOT alive
- logmsg "RUN: failed to start the $srvrname server\n";
- stopserver($server, "$pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
+ my $port = 29000;
+ my ($dictpid, $pid2);
+ for(1 .. 10) {
+ $port += int(rand(900));
+ my $aflags = "--port $port $flags";
+ my $cmd = "$srcdir/dictserver.py $aflags";
+ ($dictpid, $pid2) = startnew($cmd, $pidfile, 15, 0);
- # Server is up. Verify that we can speak to it.
- my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
- if(!$pid3) {
- logmsg "RUN: $srvrname server failed verification\n";
- # failed to talk to it properly. Kill the server and return failure
- stopserver($server, "$dictpid $pid2");
- displaylogs($testnumcheck);
- $doesntrun{$pidfile} = 1;
- return (0,0);
- }
- $pid2 = $pid3;
+ if($dictpid <= 0 || !pidexists($dictpid)) {
+ # it is NOT alive
+ logmsg "RUN: failed to start the $srvrname server\n";
+ stopserver($server, "$pid2");
+ displaylogs($testnumcheck);
+ $doesntrun{$pidfile} = 1;
+ $dictpid = $pid2 = 0;
+ next;
+ }
+ $doesntrun{$pidfile} = 0;
- if($verbose) {
- logmsg "RUN: $srvrname server is now running PID $dictpid\n";
+ if($verbose) {
+ logmsg "RUN: $srvrname server PID $dictpid port $port\n";
+ }
+ last;
}
- return ($dictpid, $pid2);
+ return ($dictpid, $pid2, $port);
}
#######################################################################
@@ -3217,7 +3210,6 @@ sub checksystem {
$run_event_based?"event-based ":"");
logmsg sprintf("%s\n", $libtool?"Libtool ":"");
logmsg ("* Seed: $randseed\n");
- logmsg ("* Port range: $minport-$maxport\n");
if($verbose) {
if($has_unix) {
@@ -4960,7 +4952,7 @@ sub startservers {
}
elsif($what eq "dict") {
if(!$run{'dict'}) {
- ($pid, $pid2) = rundictserver($verbose, "", $DICTPORT);
+ ($pid, $pid2, $DICTPORT) = rundictserver($verbose, "");
if($pid <= 0) {
return "failed starting DICT server";
}
@@ -5209,12 +5201,6 @@ while(@ARGV) {
# verbose output
$verbose=1;
}
- elsif($ARGV[0] =~ /^-b(.*)/) {
- my $portno=$1;
- if($portno =~ s/(\d+)$//) {
- $base = int $1;
- }
- }
elsif ($ARGV[0] eq "-c") {
# use this path to curl instead of default
$DBGCURL=$CURL="\"$ARGV[1]\"";
@@ -5336,7 +5322,6 @@ while(@ARGV) {
Usage: runtests.pl [options] [test selection(s)]
-a continue even if a test fails
-am automake style output PASS/FAIL: [number] [name]
- -bN use base port number N for test servers (default $base)
-c path use this curl executable
-d display server debug info
-e event-based execution
@@ -5484,12 +5469,8 @@ if ($gdbthis) {
}
}
-$minport = $base; # original base port number
-$DICTPORT = $base++; # DICT port
$HTTPUNIXPATH = "http$$.sock"; # HTTP server Unix domain socket path
-$maxport = $base-1; # updated base port number
-
#######################################################################
# clear and create logging directory:
#