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:
+10
-3
@@ -2,14 +2,21 @@ add_library(celrs_crsf STATIC crsf.c)
|
||||
target_include_directories(celrs_crsf PUBLIC "${CMAKE_SOURCE_DIR}")
|
||||
target_compile_features(celrs_crsf PRIVATE c_std_23)
|
||||
|
||||
# Platform-agnostic serial logic — calls cel_serial_platform_*();
|
||||
# symbol resolved by celrs_serial_platform (or a mock in tests)
|
||||
add_library(celrs_serial STATIC serial.c)
|
||||
target_include_directories(celrs_serial PUBLIC "${CMAKE_SOURCE_DIR}")
|
||||
target_compile_features(celrs_serial PRIVATE c_std_23)
|
||||
|
||||
# Real platform backend — linked into production binaries only
|
||||
add_library(celrs_serial_platform STATIC)
|
||||
target_include_directories(celrs_serial_platform PUBLIC "${CMAKE_SOURCE_DIR}")
|
||||
target_compile_features(celrs_serial_platform PRIVATE c_std_23)
|
||||
if (IS_WINDOWS)
|
||||
target_sources(celrs_serial PRIVATE platform/serial_win.c)
|
||||
target_link_libraries(celrs_serial PRIVATE advapi32)
|
||||
target_sources(celrs_serial_platform PRIVATE platform/serial_win.c)
|
||||
target_link_libraries(celrs_serial_platform PRIVATE advapi32)
|
||||
elseif(IS_LINUX OR IS_MACOS)
|
||||
target_sources(celrs_serial PRIVATE platform/serial_posix.c)
|
||||
target_sources(celrs_serial_platform PRIVATE platform/serial_posix.c)
|
||||
endif()
|
||||
|
||||
# Level-filtering logger — calls log_write(); symbol resolved by the final binary
|
||||
|
||||
Reference in New Issue
Block a user