From 06615c148d3b8285efe7e6991dfc605ccb5f7ee7 Mon Sep 17 00:00:00 2001 From: Filip Kokosinski Date: Thu, 19 May 2022 12:17:36 +0200 Subject: [PATCH] tests/kernel/usage/thread_runtime_stats: relax precision test for RISC-V This commit relaxes the precision requirements for idle event statistic test when RISC-V machine timer driver is used. This is needed for some platforms (e.g. hifive1), for which the cycle count is too low to pass the checks where a percent deviation of peak cycles count is allowed. Signed-off-by: Filip Kokosinski --- .../thread_runtime_stats/src/test_thread_runtime_stats.c | 7 ++++++- tests/kernel/usage/thread_runtime_stats/testcase.yaml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/kernel/usage/thread_runtime_stats/src/test_thread_runtime_stats.c b/tests/kernel/usage/thread_runtime_stats/src/test_thread_runtime_stats.c index ad5f152affca..755225ffdc92 100644 --- a/tests/kernel/usage/thread_runtime_stats/src/test_thread_runtime_stats.c +++ b/tests/kernel/usage/thread_runtime_stats/src/test_thread_runtime_stats.c @@ -15,6 +15,11 @@ ((((val1) * 100) < ((val2) * (100 + (pcnt)))) && \ (((val1) * 100) > ((val2) * (100 - (pcnt))))) ? true : false +#if defined(CONFIG_RISCV_MACHINE_TIMER) +#define IDLE_EVENT_STATS_PRECISION 5 +#else +#define IDLE_EVENT_STATS_PRECISION 1 +#endif static struct k_thread helper_thread; static K_THREAD_STACK_DEFINE(helper_stack, HELPER_STACK_SIZE); @@ -162,7 +167,7 @@ void test_all_stats_usage(void) zassert_true(stats5.current_cycles > stats4.current_cycles, NULL); zassert_true(TEST_WITHIN_X_PERCENT(stats4.peak_cycles, - stats3.peak_cycles, 1), NULL); + stats3.peak_cycles, IDLE_EVENT_STATS_PRECISION), NULL); zassert_true(stats4.peak_cycles == stats5.peak_cycles, NULL); zassert_true(stats4.average_cycles > stats3.average_cycles, NULL); diff --git a/tests/kernel/usage/thread_runtime_stats/testcase.yaml b/tests/kernel/usage/thread_runtime_stats/testcase.yaml index 2815085d6202..67ab1ec7cb34 100644 --- a/tests/kernel/usage/thread_runtime_stats/testcase.yaml +++ b/tests/kernel/usage/thread_runtime_stats/testcase.yaml @@ -7,6 +7,6 @@ tests: # The following architectures are exluded as the necessary # thread runtime statistic hooks do not yet exist. # mips - arch_exclude: posix riscv32 sparc mips + arch_exclude: posix sparc mips # SMP is excluded as the test was only written for UP filter: not CONFIG_SMP