Support deterministic random seeding of tests

Add a new option `ODIN_TEST_RANDOM_SEED` which is picked from the cycle
counter at startup, if it's not specified by the user.

This number is sent to every test in the `T` struct and reset every test
(just in case).
This commit is contained in:
Feoramund
2024-05-29 18:04:59 -04:00
parent a27b167218
commit 1f6a6f2cd3
2 changed files with 24 additions and 0 deletions
+10
View File
@@ -29,6 +29,16 @@ Internal_Cleanup :: struct {
T :: struct {
error_count: int,
// If your test needs to perform random operations, it's advised to use
// this value to seed a local random number generator rather than relying
// on the non-thread-safe global one.
//
// This way, your results will be deterministic.
//
// This value is chosen at startup of the test runner, logged, and may be
// specified by the user. It is the same for all tests of a single run.
seed: u64,
channel: Update_Channel_Sender,
cleanups: [dynamic]Internal_Cleanup,