]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
runtests: use a per-runner random seed
authorDan Fandrich <dan@coneharvesters.com>
Fri, 19 May 2023 04:40:05 +0000 (21:40 -0700)
committerDan Fandrich <dan@coneharvesters.com>
Mon, 5 Jun 2023 18:16:06 +0000 (11:16 -0700)
Each runner needs a unique random seed to reduce the chance of port
number collisions. The new scheme uses a consistent per-runner source of
randomness which results in deterministic behaviour, as it did before.

Ref: #10818

tests/globalconfig.pm
tests/runner.pm
tests/runtests.pl

index e44781f95741db19592c226a1e6ca6e7c1d0a6f1..af52760ff1c2f27c7e6ff9c678659c6339187cf8 100644 (file)
@@ -50,6 +50,7 @@ BEGIN {
         $proxy_address
         $PROXYIN
         $pwd
+        $randseed
         $run_event_based
         $SERVERIN
         $srcdir
@@ -80,6 +81,7 @@ our $run_event_based; # run curl with --test-event to test the event API
 our $automakestyle;   # use automake-like test status output format
 our $anyway;          # continue anyway, even if a test fail
 our $CURLVERSION="";  # curl's reported version number
+our $randseed = 0;    # random number seed
 
 # paths
 our $pwd = getcwd();  # current working directory
index 86867d0fd1fb105aae35a3c8a20cd2ec76609d67..09467c2b6d14819516feaac3d00b177f3f09305d 100644 (file)
@@ -168,6 +168,13 @@ sub runner_init {
     $ENV{'XDG_CONFIG_HOME'}=$ENV{'HOME'};
     $ENV{'COLUMNS'}=79; # screen width!
 
+    # Incorporate the $logdir into the random seed and re-seed the PRNG.
+    # This gives each runner a unique yet consistent seed which provides
+    # more unique port number selection in each runner, yet is deterministic
+    # across runs.
+    $randseed += unpack('%16C*', $logdir);
+    srand $randseed;
+
     # create pipes for communication with runner
     my ($thisrunnerr, $thiscontrollerw, $thiscontrollerr, $thisrunnerw);
     pipe $thisrunnerr, $thiscontrollerw;
index e1f58ba5c39f23d9ae39882e48dd6e406c6d32a5..2f13e8bdcfe670b8a818b894887947ff41a467d0 100755 (executable)
@@ -177,7 +177,6 @@ my $clearlocks;   # force removal of files by killing locking processes
 my $postmortem;   # display detailed info about failed tests
 my $run_disabled; # run the specific tests even if listed in DISABLED
 my $scrambleorder;
-my $randseed = 0;
 my $jobs = 0;
 
 # Azure Pipelines specific variables