Skip to content

Commit 7ea93a8

Browse files
cfriedtnashif
authored andcommitted
tests: kernel: cycle64: mark test as slow
Previously cycle64 was under `samples/`. It's been moved to `tests/` and has been marked with `slow: True` so that it will not disrupt CI by adding excessive delays. Fixes #40367 Signed-off-by: Christopher Friedt <[email protected]>
1 parent 4d6315a commit 7ea93a8

File tree

6 files changed

+37
-26
lines changed

6 files changed

+37
-26
lines changed

samples/kernel/cycle64/prj.conf

Lines changed: 0 additions & 3 deletions
This file was deleted.

samples/kernel/cycle64/sample.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.
File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_ZTEST=y
2+
CONFIG_PRINTK=y

samples/kernel/cycle64/src/main.c renamed to tests/kernel/timer/cycle64/src/main.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <ztest.h>
78
#include <zephyr.h>
89

910
static void swap64(uint64_t *a, uint64_t *b)
@@ -41,7 +42,7 @@ uint32_t timeout(uint64_t prev, uint64_t now)
4142
return (uint32_t)next;
4243
}
4344

44-
void main(void)
45+
static void test_32bit_wrap_around(void)
4546
{
4647
enum {
4748
CURR,
@@ -52,15 +53,15 @@ void main(void)
5253
uint64_t now;
5354
uint64_t c64[2];
5455

55-
printk("wrap-around should occur in %us\n",
56+
printk("32-bit wrap-around should occur every %us\n",
5657
(uint32_t)(BIT64(32) / (uint32_t)sys_clock_hw_cycles_per_sec()));
5758

5859
printk("[ddd:hh:mm:ss.0ms]\n");
5960

6061
c64[CURR] = k_cycle_get_64();
6162
msg(c64[CURR]);
6263

63-
for (i = 0; i < 3; ++i) {
64+
for (i = 0; i < 2; ++i) {
6465
k_sleep(Z_TIMEOUT_CYC(timeout(c64[CURR], k_cycle_get_64())));
6566

6667
now = k_cycle_get_64();
@@ -69,9 +70,15 @@ void main(void)
6970

7071
msg(c64[CURR]);
7172

72-
__ASSERT(((c64[CURR] - c64[PREV]) >> 32) == 1,
73-
"The 64-bit cycle counter did not increment!");
73+
zassert_equal(((c64[CURR] - c64[PREV]) >> 32), 1,
74+
"The 64-bit cycle counter did not increment by 2^32");
7475
}
76+
}
77+
78+
void test_main(void)
79+
{
80+
ztest_test_suite(cycle64_tests,
81+
ztest_unit_test(test_32bit_wrap_around));
7582

76-
printk("SUCCESS\n");
83+
ztest_run_test_suite(cycle64_tests);
7784
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Note: Re: slow vs fast
2+
#
3+
# Some platforms such as native_posix, qemu_riscv32, qemu_riscv64
4+
# complete these tests almost instantaneously because of qemu timer
5+
# quirks ("time warp") even though the test reports that it completes
6+
# in e.g. 14 s. We can take advantage of that for fast tests on each PR
7+
# but we also want to excercise this code path during daily builds or
8+
# otherwise when users specify "twister --enable-slow".
9+
#
10+
# As other platforms are added with varying timer frequencies, increase
11+
# timeout as necessary.
12+
tests:
13+
kernel.timer.cycle64:
14+
tags: kernel timer
15+
filter: CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER
16+
platform_exclude: native_posix
17+
timeout: 140
18+
slow: true
19+
kernel.timer.cycle64.fast:
20+
tags: kernel timer
21+
filter: CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER
22+
platform_allow: native_posix

0 commit comments

Comments
 (0)