diff --git a/.github/workflows/host_tests.yml b/.github/workflows/host_tests.yml index b4cfba0..e08328d 100644 --- a/.github/workflows/host_tests.yml +++ b/.github/workflows/host_tests.yml @@ -17,4 +17,4 @@ mkdir __build && cd __build cmake .. -GNinja -DBUILD_GREENTEA_TESTS=FALSE -DBUILD_TESTING=TRUE ninja - ctest . --output-on-failure -V + ctest . --output-on-failure diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index 3cd9f95..f530e8b 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -3,7 +3,7 @@ if(MBED_OS_ENABLE_TESTS) if(BUILD_GREENTEA_TESTS) - # add greentea test + add_subdirectory(tests/TESTS) else() add_subdirectory(tests/UNITTESTS) endif() diff --git a/hal/tests/TESTS/CMakeLists.txt b/hal/tests/TESTS/CMakeLists.txt new file mode 100644 index 0000000..1197616 --- /dev/null +++ b/hal/tests/TESTS/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(mbed_hal) \ No newline at end of file diff --git a/hal/tests/TESTS/mbed_hal/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/CMakeLists.txt new file mode 100644 index 0000000..403a9c7 --- /dev/null +++ b/hal/tests/TESTS/mbed_hal/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(reset_reason) \ No newline at end of file diff --git a/hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt index e68344d..deff47f 100644 --- a/hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt @@ -1,18 +1,13 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-hal-reset-reason) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) +include(mbed_greentea) mbed_greentea_add_test( TEST_NAME - ${TEST_TARGET} + mbed-hal-reset-reason TEST_SOURCES main.cpp + HOST_TESTS_DIR + ../../host_tests ) diff --git a/hal/tests/TESTS/mbed_hal/reset_reason/main.cpp b/hal/tests/TESTS/mbed_hal/reset_reason/main.cpp index f449963..1717e93 100644 --- a/hal/tests/TESTS/mbed_hal/reset_reason/main.cpp +++ b/hal/tests/TESTS/mbed_hal/reset_reason/main.cpp @@ -27,7 +27,7 @@ #if DEVICE_WATCHDOG # include "hal/watchdog_api.h" # define MSG_VALUE_WATCHDOG_STATUS 1 -# define WDG_TIMEOUT_MS 50UL +# define WDG_TIMEOUT_MS 50ms #else # define MSG_VALUE_WATCHDOG_STATUS 0 #endif @@ -60,7 +60,7 @@ * (1 start_bit + 8 data_bits + 1 stop_bit) * 128 * 1000 / 9600 = 133.3 ms. * To be on the safe side, set the wait time to 150 ms. */ -#define SERIAL_FLUSH_TIME_MS 150 +#define SERIAL_FLUSH_TIME_MS 150ms typedef enum { CMD_STATUS_CONTINUE, @@ -108,7 +108,7 @@ if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) { greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK); ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. - watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS }; + watchdog_config_t config = { .timeout_ms = std::chrono::duration_cast(WDG_TIMEOUT_MS).count() }; if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) { TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error."); return CMD_STATUS_ERROR;