From f7c0434b6cafef2ae117f0f59f10b7380c39fa1b Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Mon, 12 Apr 2021 18:11:29 +0200 Subject: [PATCH 1/2] HAL ticker tests fix u64 (1000000 * LP/US_TICKER_PERIOD_DEN) > U32 --- hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp | 2 +- hal/tests/TESTS/mbed_hal/us_ticker/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp b/hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp index 43f8e39cdd..aa766c3bb6 100644 --- a/hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp +++ b/hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp @@ -112,7 +112,7 @@ void lp_ticker_info_test() TEST_ASSERT(p_ticker_info->bits >= 12); #ifdef LP_TICKER_PERIOD_NUM - TEST_ASSERT_UINT32_WITHIN(1, 1000000 * LP_TICKER_PERIOD_DEN / LP_TICKER_PERIOD_NUM, p_ticker_info->frequency); + TEST_ASSERT_UINT32_WITHIN(1, (uint64_t)1000000 * LP_TICKER_PERIOD_DEN / LP_TICKER_PERIOD_NUM, p_ticker_info->frequency); TEST_ASSERT_EQUAL_UINT32(LP_TICKER_MASK, ((uint64_t)1 << p_ticker_info->bits) - 1); #endif diff --git a/hal/tests/TESTS/mbed_hal/us_ticker/main.cpp b/hal/tests/TESTS/mbed_hal/us_ticker/main.cpp index 976b38f5ed..354e1485d3 100644 --- a/hal/tests/TESTS/mbed_hal/us_ticker/main.cpp +++ b/hal/tests/TESTS/mbed_hal/us_ticker/main.cpp @@ -47,7 +47,7 @@ void us_ticker_info_test() TEST_ASSERT(p_ticker_info->bits >= 16); #ifdef US_TICKER_PERIOD_NUM - TEST_ASSERT_UINT32_WITHIN(1, 1000000 * US_TICKER_PERIOD_DEN / US_TICKER_PERIOD_NUM, p_ticker_info->frequency); + TEST_ASSERT_UINT32_WITHIN(1, (uint64_t)1000000 * US_TICKER_PERIOD_DEN / US_TICKER_PERIOD_NUM, p_ticker_info->frequency); TEST_ASSERT_EQUAL_UINT32(US_TICKER_MASK, ((uint64_t)1 << p_ticker_info->bits) - 1); #endif } From 3b64279d3664b6850bd61642489b57d7b3822828 Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Thu, 15 Apr 2021 17:31:51 +0200 Subject: [PATCH 2/2] HAL ticker tests : add optional CHECK_TICKER_OPTIM define This will make build failure if ticker optim defines are not present --- hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp | 2 +- hal/tests/TESTS/mbed_hal/us_ticker/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp b/hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp index aa766c3bb6..570ca4a9b7 100644 --- a/hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp +++ b/hal/tests/TESTS/mbed_hal/lp_ticker/main.cpp @@ -111,7 +111,7 @@ void lp_ticker_info_test() TEST_ASSERT(p_ticker_info->frequency <= 64000); TEST_ASSERT(p_ticker_info->bits >= 12); -#ifdef LP_TICKER_PERIOD_NUM +#if defined(LP_TICKER_PERIOD_NUM) || defined(CHECK_TICKER_OPTIM) TEST_ASSERT_UINT32_WITHIN(1, (uint64_t)1000000 * LP_TICKER_PERIOD_DEN / LP_TICKER_PERIOD_NUM, p_ticker_info->frequency); TEST_ASSERT_EQUAL_UINT32(LP_TICKER_MASK, ((uint64_t)1 << p_ticker_info->bits) - 1); #endif diff --git a/hal/tests/TESTS/mbed_hal/us_ticker/main.cpp b/hal/tests/TESTS/mbed_hal/us_ticker/main.cpp index 354e1485d3..3729b0c5c5 100644 --- a/hal/tests/TESTS/mbed_hal/us_ticker/main.cpp +++ b/hal/tests/TESTS/mbed_hal/us_ticker/main.cpp @@ -46,7 +46,7 @@ void us_ticker_info_test() TEST_ASSERT(p_ticker_info->bits >= 16); -#ifdef US_TICKER_PERIOD_NUM +#if defined(US_TICKER_PERIOD_NUM) || defined(CHECK_TICKER_OPTIM) TEST_ASSERT_UINT32_WITHIN(1, (uint64_t)1000000 * US_TICKER_PERIOD_DEN / US_TICKER_PERIOD_NUM, p_ticker_info->frequency); TEST_ASSERT_EQUAL_UINT32(US_TICKER_MASK, ((uint64_t)1 << p_ticker_info->bits) - 1); #endif