Tor Unit Tests should TT_FORK before initialising global PRNG state
Tor unit tests are meant to TT_FORK before changing any global process state that can't be reverted.
In legacy/trac#17789 (moved), we discovered that one or more tests initialise the OpenSSL CSPRNG without forking first. (This can't be undone.)
While this isn't likely to cause any issues, (legacy/trac#17789 (moved) was marked as wontfix for other reasons), it would be nice to fix it eventually for correctness.
One way to do this is:
- initialise a static variable to 0.
- set it to 1 just after fork()ing via TT_FORK.
- tor_assert() that it's 1 in functions that irreversibly modify global test process state, if TOR_UNIT_TESTS is defined:
- crypto_early_init(), which seeds the OpenSSL CSPRNG,
- (I'm sure many other init functions do similar things)
- mark the tests that assert as TT_FORK
Marked as Low/Minor because this doesn't currently cause any issues, but if tests start failing due to interactions with previous global state, we should look at it again.