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 /**
11  * @defgroup kernel_init_tests Kernel Initialization
12  * @ingroup all_tests
13  * @{
14  * @}
15  *
16  * @addtogroup kernel_init_tests
17  * @{
18  */
19 
20 /**
21  * @brief This module verifies the delay specified during boot.
22  */
ZTEST(boot_delay,test_bootdelay)23 ZTEST(boot_delay, test_bootdelay)
24 {
25 	if (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC > 1000000000) {
26 		/* Systems with very fast counters (like the x86 TSC)
27 		 * and long firmware startup (often 10+ seconds on a
28 		 * EFI PC!)  can easily roll this over during startup,
29 		 * and there's no way to detect that case with a 32
30 		 * bit OS API.  Just skip it if we have a GHz-scale
31 		 * counter.
32 		 */
33 		ztest_test_skip();
34 	}
35 
36 	uint32_t current_cycles = k_cycle_get_32();
37 
38 	/* compare this with the boot delay specified */
39 	zassert_true(k_cyc_to_ns_floor64(current_cycles) >=
40 			(NSEC_PER_MSEC * CONFIG_BOOT_DELAY),
41 			"boot delay not executed: %d < %d",
42 			(uint32_t)k_cyc_to_ns_floor64(current_cycles),
43 			(NSEC_PER_MSEC * CONFIG_BOOT_DELAY));
44 }
45 
46 /**
47  * @}
48  */
49 
50 extern void *common_setup(void);
51 ZTEST_SUITE(boot_delay, NULL, common_setup, NULL, NULL, NULL);
52