From bd7d4a3752273d3038d34c456d5f8d4c6c25e344 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Thu, 8 Aug 2024 10:21:42 +0200 Subject: [PATCH] Add comment about randomOrder and random seed --- src/test/SDL_test_harness.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index bbd794a35e..518253a170 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -551,6 +551,13 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user int tmp; a = SDLTest_RandomIntegerInRange(0, nbSuites - 1); b = SDLTest_RandomIntegerInRange(0, nbSuites - 1); + /* + * NB: prevent swapping here to make sure the tests start with the same + * random seed (whether they are run in order or not). + * So we consume same number of SDLTest_RandomIntegerInRange() in all cases. + * + * If some random value were used at initialization before the tests start, the --seed wouldn't do the same with or without randomOrder. + */ /* Swap */ if (randomOrder) { tmp = arraySuites[b]; @@ -602,6 +609,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user a = SDLTest_RandomIntegerInRange(0, nbTestCases - 1); b = SDLTest_RandomIntegerInRange(0, nbTestCases - 1); /* Swap */ + /* See previous note */ if (randomOrder) { tmp = arrayTestCases[b]; arrayTestCases[b] = arrayTestCases[a];