zephyr/tests/kernel/common/src/boot_delay.c
Alberto Escolar Piedras ba4bbe91b4 Revert "tests: kernel: update test case with sys_clock_hw_cycles_per_sec"
This reverts commit fd8ca83e9a.

https://github.com/zephyrproject-rtos/zephyr/pull/69705
Introduced a regression in main in which
tests/subsys/logging/log_timestamp
started failing. (See
https://github.com/zephyrproject-rtos/zephyr/issues/72344
for more info).
Let's revert the PR. It can be submitted after with the issue
fixed.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-05-06 14:52:29 +03:00

48 lines
1.1 KiB
C

/*
* Copyright (c) 2018 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/ztest.h>
/**
* @brief Test delay during boot
* @defgroup kernel_init_tests Init
* @ingroup all_tests
* @{
*/
/**
* @brief This module verifies the delay specified during boot.
*/
ZTEST(boot_delay, test_bootdelay)
{
if (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC > 1000000000) {
/* Systems with very fast counters (like the x86 TSC)
* and long firmware startup (often 10+ seconds on a
* EFI PC!) can easily roll this over during startup,
* and there's no way to detect that case with a 32
* bit OS API. Just skip it if we have a GHz-scale
* counter.
*/
ztest_test_skip();
}
uint32_t current_cycles = k_cycle_get_32();
/* compare this with the boot delay specified */
zassert_true(k_cyc_to_ns_floor64(current_cycles) >=
(NSEC_PER_MSEC * CONFIG_BOOT_DELAY),
"boot delay not executed: %d < %d",
(uint32_t)k_cyc_to_ns_floor64(current_cycles),
(NSEC_PER_MSEC * CONFIG_BOOT_DELAY));
}
extern void *common_setup(void);
ZTEST_SUITE(boot_delay, NULL, common_setup, NULL, NULL, NULL);
/**
* @}
*/