1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/*
* Copyright (c) 2026 Apidae Systems
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/ztest.h>
LOG_MODULE_REGISTER(kernel, LOG_LEVEL_INF);
ZTEST_SUITE(kernel, NULL, NULL, NULL, NULL, NULL);
ZTEST(kernel, test_uptime_advances)
{
int64_t t0 = k_uptime_get();
k_sleep(K_MSEC(50));
int64_t t1 = k_uptime_get();
zassert_true(t1 > t0,
"uptime did not advance: t0=%lld t1=%lld", t0, t1);
zassert_true((t1 - t0) >= 40,
"delta %lld ms is implausibly short", (t1 - t0));
}
ZTEST(kernel, test_log_subsystem_alive)
{
LOG_INF("kernel test ran at uptime=%lld ms", k_uptime_get());
}
ZTEST(kernel, test_constants_make_sense)
{
zassert_true(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC > 0,
"SYS_CLOCK_HW_CYCLES_PER_SEC=%d",
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
zassert_true(CONFIG_SYS_CLOCK_TICKS_PER_SEC > 0,
"SYS_CLOCK_TICKS_PER_SEC=%d",
CONFIG_SYS_CLOCK_TICKS_PER_SEC);
}
|