Skip to content

Commit b47b310

Browse files
Add Linux UHID backend test hooks
Expose test-only hooks for the Linux UHID/uinput backend and add fake-syscall support for unit tests. Introduces LIBVIRTUALHID_ENABLE_TEST_HOOKS when BUILD_TESTS is enabled in CMake, adds system_* wrappers (open/close/read/write/ioctl/poll/access) and ScopedLinuxTestSyscalls to allow scripted syscall overrides. Adds extensive test helpers and fake backend behaviors in uhid_backend.cpp and a new header uhid_backend_test_hooks.hpp with public test APIs, plus related test CMake and unit test additions, enabling backend testing without real device nodes.
1 parent 4f28b95 commit b47b310

5 files changed

Lines changed: 2067 additions & 32 deletions

File tree

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ if(LIBVIRTUALHID_USES_THREADS)
1818
target_sources(${PROJECT_NAME}
1919
PRIVATE
2020
"${CMAKE_CURRENT_SOURCE_DIR}/platform/linux/uhid_backend.cpp")
21+
if(BUILD_TESTS)
22+
# Expose private Linux backend helpers only to tests so coverage does not depend on real device nodes.
23+
target_compile_definitions(${PROJECT_NAME}
24+
PRIVATE
25+
LIBVIRTUALHID_ENABLE_TEST_HOOKS=1)
26+
endif()
2127
target_link_libraries(${PROJECT_NAME}
2228
PUBLIC
2329
Threads::Threads)

0 commit comments

Comments
 (0)