From 77617b0d9815083f03bdf6e70906e9aa94a27a6d Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Wed, 31 Aug 2022 08:52:07 +0200 Subject: [PATCH] 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 --- subsys/testsuite/ztest/src/ztress.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subsys/testsuite/ztest/src/ztress.c b/subsys/testsuite/ztest/src/ztress.c index 1833e9627ad..9ab23a5f9b0 100644 --- a/subsys/testsuite/ztest/src/ztress.c +++ b/subsys/testsuite/ztest/src/ztress.c @@ -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; }