1 /*
2 * Copyright (c) 2018 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/ztest.h>
8
9 /**
10 * @brief Test delay during boot
11 * @defgroup kernel_init_tests Init
12 * @ingroup all_tests
13 * @{
14 */
15
16 /**
17 * @brief This module verifies the delay specified during boot.
18 */
ZTEST(boot_delay,test_bootdelay)19 ZTEST(boot_delay, test_bootdelay)
20 {
21 if (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC > 1000000000) {
22 /* Systems with very fast counters (like the x86 TSC)
23 * and long firmware startup (often 10+ seconds on a
24 * EFI PC!) can easily roll this over during startup,
25 * and there's no way to detect that case with a 32
26 * bit OS API. Just skip it if we have a GHz-scale
27 * counter.
28 */
29 ztest_test_skip();
30 }
31
32 uint32_t current_cycles = k_cycle_get_32();
33
34 /* compare this with the boot delay specified */
35 zassert_true(k_cyc_to_ns_floor64(current_cycles) >=
36 (NSEC_PER_MSEC * CONFIG_BOOT_DELAY),
37 "boot delay not executed: %d < %d",
38 (uint32_t)k_cyc_to_ns_floor64(current_cycles),
39 (NSEC_PER_MSEC * CONFIG_BOOT_DELAY));
40 }
41
42 extern void *common_setup(void);
43 ZTEST_SUITE(boot_delay, NULL, common_setup, NULL, NULL, NULL);
44
45 /**
46 * @}
47 */
48