testsuite: ztress: First sys_rand_get32 from thread

Added a workaround to call random generator once during the
initialization. It is done to handle XOSHIRO generator limitation
which performs initialization in the first sys_rand32_get call.
And for some entropy generators it cannot be done from an interrupt
context and it happens if k_timer context is used which expires first.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2022-08-31 08:52:07 +02:00 committed by Anas Nashif
commit 77617b0d98

View file

@ -467,6 +467,12 @@ static int ztress_cpu_clock_to_sys_clock_check(const struct device *unused)
*/
cpu_sys_clock_ok = t <= 12;
/* Read first random number. There are some generators which do not support
* reading first random number from an interrupt context (initialization
* is performed at the first read).
*/
(void)sys_rand32_get();
return 0;
}