|
| 1 | +cmake_minimum_required(VERSION 3.13 FATAL_ERROR) |
| 2 | +cmake_policy(SET CMP0057 NEW) |
| 3 | + |
| 4 | +project(regression_samples_rtos_test LANGUAGES C) |
| 5 | + |
| 6 | +# Paths |
| 7 | +get_filename_component(REG_DIR |
| 8 | + ${CMAKE_CURRENT_LIST_DIR}/../../../regression_samples_rtos ABSOLUTE) |
| 9 | +get_filename_component(SIM_DIR |
| 10 | + ${CMAKE_CURRENT_LIST_DIR}/../../../regression ABSOLUTE) |
| 11 | +get_filename_component(SAMPLE_DIR |
| 12 | + ${CMAKE_CURRENT_LIST_DIR}/../../../../samples ABSOLUTE) |
| 13 | + |
| 14 | +# --------------------------------------------------------------------------- |
| 15 | +# test_utility_samples — shared support library for all sample regression tests |
| 16 | +# |
| 17 | +# Unlike the full regression test_utility, this library: |
| 18 | +# * does NOT include ux_test.c (error injection not needed for samples) |
| 19 | +# * uses ux_test_utility_sim_stubs.c (no-op stubs) instead of the real |
| 20 | +# ux_test_utility_sim.c, so no OS API overriding takes place |
| 21 | +# --------------------------------------------------------------------------- |
| 22 | +set(test_utility_samples_files |
| 23 | + ${REG_DIR}/usbxtestcontrol.c |
| 24 | + ${SIM_DIR}/ux_test_dcd_sim_slave.c |
| 25 | + ${SIM_DIR}/ux_test_hcd_sim_host.c |
| 26 | + ${REG_DIR}/ux_test_utility_sim_stubs.c |
| 27 | +) |
| 28 | + |
| 29 | +add_library(test_utility_samples ${test_utility_samples_files}) |
| 30 | +target_link_libraries(test_utility_samples |
| 31 | + PUBLIC azrtos::usbx azrtos::threadx azrtos::netxduo azrtos::filex) |
| 32 | +target_compile_definitions(test_utility_samples PUBLIC CTEST) |
| 33 | + |
| 34 | +# Regression dir must come first so ux_test.h / ux_test_utility_sim.h resolve |
| 35 | +target_include_directories(test_utility_samples PUBLIC ${SIM_DIR}) |
| 36 | + |
| 37 | +# --------------------------------------------------------------------------- |
| 38 | +# Helper macro — builds one sample test executable |
| 39 | +# |
| 40 | +# Usage: |
| 41 | +# add_sample_test(<test_name> <test_source> <sample_source>) |
| 42 | +# |
| 43 | +# The sample source file is compiled with DEMO_TEST and EXTERNAL_MAIN so that: |
| 44 | +# DEMO_TEST — suppresses tx_application_define and exposes the |
| 45 | +# ux_demo_device_hid_init() wrapper function |
| 46 | +# EXTERNAL_MAIN — suppresses the sample's own main() entry point |
| 47 | +# UX_DEVICE_SIDE_ONLY is applied only to the sample translation unit so |
| 48 | +# that the USBX library itself is not restricted to device-only mode. |
| 49 | +# --------------------------------------------------------------------------- |
| 50 | +macro(add_sample_test test_name test_source sample_source) |
| 51 | + add_executable(${test_name} ${test_source} ${sample_source}) |
| 52 | + |
| 53 | + set_source_files_properties(${sample_source} |
| 54 | + PROPERTIES COMPILE_DEFINITIONS |
| 55 | + "UX_DEVICE_SIDE_ONLY;DEMO_TEST;EXTERNAL_MAIN") |
| 56 | + |
| 57 | + target_link_libraries(${test_name} PRIVATE test_utility_samples) |
| 58 | + add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name}) |
| 59 | +endmacro() |
| 60 | + |
| 61 | +# --------------------------------------------------------------------------- |
| 62 | +# Test cases |
| 63 | +# --------------------------------------------------------------------------- |
| 64 | + |
| 65 | +add_sample_test( |
| 66 | + usbx_hid_mouse_demo_device_rtos_test |
| 67 | + ${REG_DIR}/usbx_hid_mouse_demo_device_rtos_test.c |
| 68 | + ${SAMPLE_DIR}/demo_device_hid_mouse_rtos.c |
| 69 | +) |
| 70 | + |
| 71 | +add_sample_test( |
| 72 | + usbx_hid_keyboard_demo_device_rtos_test |
| 73 | + ${REG_DIR}/usbx_hid_keyboard_demo_device_rtos_test.c |
| 74 | + ${SAMPLE_DIR}/demo_device_hid_keyboard_rtos.c |
| 75 | +) |
0 commit comments