From: Dan Fandrich Date: Fri, 19 May 2023 04:40:05 +0000 (-0700) Subject: runtests: use a per-runner random seed X-Git-Tag: curl-8_2_0~149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78d8bc4c639b9dce2ae4b774454069a7109f47bb;p=thirdparty%2Fcurl.git runtests: use a per-runner random seed 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 --- diff --git a/tests/globalconfig.pm b/tests/globalconfig.pm index e44781f957..af52760ff1 100644 --- a/tests/globalconfig.pm +++ b/tests/globalconfig.pm @@ -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 diff --git a/tests/runner.pm b/tests/runner.pm index 86867d0fd1..09467c2b6d 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -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; diff --git a/tests/runtests.pl b/tests/runtests.pl index e1f58ba5c3..2f13e8bdcf 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -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