From 913868b6c492d08d4c6921f2582a8724b37efabb Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Thu, 27 Jan 2022 09:00:24 +0100 Subject: [PATCH] testsuite: ztress: Add test skipping if system clock is too high When system clock is set globally for the test which is executed on various qemu platforms it may happen that clock is set too high compared to CPU clock frequency. In that case test may stuck. Added check and test skipping in that case. Signed-off-by: Krzysztof Chruscinski --- subsys/testsuite/ztest/src/ztress.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subsys/testsuite/ztest/src/ztress.c b/subsys/testsuite/ztest/src/ztress.c index 42406648964..f3c6ce0d99a 100644 --- a/subsys/testsuite/ztest/src/ztress.c +++ b/subsys/testsuite/ztest/src/ztress.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include +#include #include #include #include @@ -319,6 +320,14 @@ int ztress_execute(struct ztress_context_data *timer_data, return -EINVAL; } + /* Skip test if system clock is set too high compared to CPU frequency. + * It can happen when system clock is set globally for the test which is + * run on various platforms. 1000 factor is an arbitrary value. + */ + if ((sys_clock_hw_cycles_per_sec() / CONFIG_SYS_CLOCK_TICKS_PER_SEC) < 1000) { + ztest_test_skip(); + } + ztress_init(thread_data); context_cnt = cnt + (timer_data ? 1 : 0);