refactor: mock serial platform backend in test_serial
test_serial mocked log_write.h, which serial.c never calls. Split celrs_serial into celrs_serial (platform-agnostic logic) and celrs_serial_platform (real Win/POSIX backend), matching the celrs_logger/celrs_log_write split. test_serial now mocks celrs/platform/serial_internal.h and links only celrs_serial, so the list-ports tests verify the max_ports clamping and pass-through logic without hitting the real registry or /dev.
This commit is contained in:
@@ -38,12 +38,12 @@ target_compile_features(test_crsf PRIVATE c_std_23)
|
||||
add_test(NAME test_crsf COMMAND test_crsf)
|
||||
list(APPEND TEST_TARGETS test_crsf)
|
||||
|
||||
# Serial tests — mocks log_write.h for any logging calls
|
||||
# Serial tests — mocks the platform backend (serial_internal.h)
|
||||
add_executable(test_serial test_serial.c)
|
||||
target_include_directories(test_serial PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||
target_link_libraries(test_serial PRIVATE celrs_serial Unity::Unity CMock::CMock)
|
||||
target_compile_features(test_serial PRIVATE c_std_23)
|
||||
cmock_generate_mock(test_serial "${CMAKE_SOURCE_DIR}/celrs/log_write.h")
|
||||
cmock_generate_mock(test_serial "${CMAKE_SOURCE_DIR}/celrs/platform/serial_internal.h")
|
||||
add_test(NAME test_serial COMMAND test_serial)
|
||||
list(APPEND TEST_TARGETS test_serial)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user