gitlab-ci: fix randomizing tests in "nm-ci-run.sh"

The code was just wrong. Usually in gitlab-ci, NMTST_SEED_RANDOM is
unset, so the previous code  would not have set it. Which means that our
tests run with NMTST_SEED_RANDOM="0".

Fuzzing (or randomizing tests) is very useful, we should do that for the
unit tests that run in gitlab-ci. Fix this.

But don't let the test choose a random number. Instead, let the calling
script choose it. That is, because we might run the tests more than once
(without debugging and no valgrind; in case of failure return with
debugging; with valgrind). Those runs should use the same seed.

This fixes commit 70487d9ff8 ('ci: randomize tests during our CI'),
but as fixing randomization can break previously running tests, we may
only want to backport this commit after careful evaluation.
This commit is contained in:
Thomas Haller
2023-01-26 13:24:07 +01:00
parent 67da2b8e42
commit 3bad3f8b24

View File

@@ -69,9 +69,13 @@ if [ $IS_ALPINE = 1 ]; then
_WITH_SYSTEMD_LOGIND="$_FALSE"
fi
if [ "$NMTST_SEED_RAND" != "" ]; then
export NMTST_SEED_RAND=
if [ -z "${NMTST_SEED_RAND+x}" ]; then
NMTST_SEED_RAND="$SRANDOM"
if [ -z "$NMTST_SEED_RAND" ]; then
NMTST_SEED_RAND="$(( ( (RANDOM<<15|RANDOM)<<15|RANDOM ) % 0xfffffffe ))"
fi
fi
export NMTST_SEED_RAND
case "$CI" in
""|"true"|"default"|"gitlab")