Skip to content

Commit 61e9e05

Browse files
committed
tests: skip arch_nop test when machine timer uses divided sys clock
When the case machine timer clock uses the divided system clock, k_cycle_get_32() can't measure accurately how many cycles elapsed. For example, use the value as timer clock obtained by dividing the system clock by 4. In this case, measuring a duration with k_cycle_get32() has up to 3 (4-1) cycles systematic error. To run this test, we need to insert an appropriate of nops with consideration for the errors. 'nop' can not repeat with for loop. Must insert as separated statement. But we don't have a convenient function such as BOOST_PP_REPEAT in C++. At this time, Implementing a generic test is a bit difficult. Skipping this test in the case. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent ddb640c commit 61e9e05

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/kernel/common/src/irq_offload.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,27 @@ __no_optimization void test_nop(void)
121121
/* do 2 nop instructions more to cost cycles */
122122
arch_nop();
123123
arch_nop();
124+
#if defined(CONFIG_RISCV_MACHINE_TIMER_SYSTEM_CLOCK_DIVIDER)
125+
/* When the case machine timer clock uses the divided system clock,
126+
* k_cycle_get_32() can't measure accurately how many cycles elapsed.
127+
*
128+
* For example, use the value as timer clock obtained by dividing
129+
* the system clock by 4.
130+
* In this case, measuring a duration with k_cycle_get32() has up to 3
131+
* (4-1) cycles systematic error.
132+
*
133+
* To run this test, we need to insert an appropriate of nops
134+
* with consideration for the errors.
135+
* 'nop' can not repeat with for loop.
136+
* Must insert as separated statement.
137+
* But we don't have a convenient function such as
138+
* BOOST_PP_REPEAT in C++.
139+
*
140+
* At this time, Implementing a generic test is a bit difficult.
141+
* Skipping this test in the case.
142+
*/
143+
ztest_test_skip();
144+
#endif
124145
#elif defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) || \
125146
defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
126147
/* do 4 nop instructions more to cost cycles */

0 commit comments

Comments
 (0)