MPS issue job003481

TitleTest case seed generation is not random enough
Assigned userGareth Rees
DescriptionTest case seed generation in the function randomize() in testlib.c [1] is not very good, the output of time() is in seconds. This means that you if run a fast test case many times in succession, you get at most one different run per second.
AnalysisThe comment in testlib.c [1] line 269 says

    /* time_t uses an arbitrary encoding, but hopefully the low order */
    /* 31 bits will have at least one bit changed from run to run. */

but time() "shall return the value of time in seconds since the Epoch" [2].

This should use a clock with higher resolution, perhaps gettimeofday(), but we need to check that it's available on all the platforms we support, and that we don't break compatibility of old random number seeds.
How foundmanual_test
Evidence[1] //
[2] <>
Observed in1.111.0
Created byGareth Rees
Created on2013-05-15 16:46:24
Last modified byGareth Rees
Last modified on2013-05-16 13:17:42
History2013-05-15 GDR Created.


Change Effect Date User Description
181855 closed 2013-05-16 13:17:42 Gareth Rees EventClock has enough entropy on all the platforms we support that we can use it to choose the random number seed.