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
This commit is contained in:
Dan Fandrich 2023-05-18 21:40:05 -07:00
parent 4317c5549b
commit 78d8bc4c63
3 changed files with 9 additions and 1 deletions

View 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

View 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;

View File

@ -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