Skip to content

Commit 362bf32

Browse files
committed
refactor
1 parent 0237129 commit 362bf32

3 files changed

Lines changed: 445 additions & 0 deletions

File tree

.vscode/tasks.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,39 @@
898898
"command": ".\\4-example_with_glfw_c.exe",
899899
"problemMatcher": "$msCompile"
900900
}
901+
},
902+
{
903+
"label": "Run Device Hot-plug Test (Debug)",
904+
"type": "shell",
905+
"command": "bash",
906+
"args": [
907+
"-l",
908+
"-c",
909+
"( if [[ $(pwd) =~ ^/mnt ]]; then ./ccap_device_hotplug_test.exe; else ./ccap_device_hotplug_test; fi )"
910+
],
911+
"options": {
912+
"cwd": "${workspaceFolder}/build/tests/Debug"
913+
},
914+
"group": "test",
915+
"problemMatcher": "$gcc",
916+
"dependsOn": [
917+
"Build Project (Debug)"
918+
],
919+
"windows": {
920+
"command": ".\\ccap_device_hotplug_test.exe",
921+
"options": {
922+
"cwd": "${workspaceFolder}/build/tests/Debug"
923+
},
924+
"problemMatcher": "$msCompile"
925+
},
926+
"presentation": {
927+
"echo": true,
928+
"reveal": "always",
929+
"focus": true,
930+
"panel": "dedicated",
931+
"showReuseMessage": false,
932+
"clear": true
933+
}
901934
}
902935
]
903936
}

tests/CMakeLists.txt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,67 @@ else()
205205
-O3
206206
)
207207
endif()
208+
209+
# ============================================================
210+
# Interactive Device Hot-plug Test
211+
# Tests crash prevention when enumerating unplugged devices
212+
# with buggy drivers (Windows DirectShow)
213+
# This test requires manual interaction and is NOT part of
214+
# the automated test suite
215+
# ============================================================
216+
217+
add_executable(
218+
ccap_device_hotplug_test
219+
test_device_hotplug.cpp
220+
)
221+
222+
target_link_libraries(
223+
ccap_device_hotplug_test
224+
ccap
225+
)
226+
227+
set_target_properties(ccap_device_hotplug_test PROPERTIES
228+
CXX_STANDARD 17
229+
CXX_STANDARD_REQUIRED ON
230+
)
231+
232+
# Platform-specific compile options
233+
if(MSVC)
234+
target_compile_options(ccap_device_hotplug_test PRIVATE
235+
/MP
236+
/std:c++17
237+
/Zc:__cplusplus
238+
/Zc:preprocessor
239+
/source-charset:utf-8
240+
/bigobj
241+
/wd4996
242+
/D_CRT_SECURE_NO_WARNINGS
243+
)
244+
else()
245+
target_compile_options(ccap_device_hotplug_test PRIVATE
246+
-std=c++17
247+
)
248+
endif()
249+
250+
# Add a custom target to run this interactive test manually
251+
# Usage: cmake --build . --target run_device_hotplug_test
252+
if(WIN32)
253+
add_custom_target(run_device_hotplug_testg_test
254+
COMMAND ${CMAKE_COMMAND} -E echo "=========================================="
255+
COMMAND ${CMAKE_COMMAND} -E echo "Running Device Hot-plug Interactive Test"
256+
COMMAND ${CMAKE_COMMAND} -E echo "=========================================="
257+
COMMAND $<TARGET_FILE:ccap_device_hotplug_test>
258+
DEPENDS ccap_device_hotplug_test
259+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
260+
COMMENT "Running interactive device hot-plug test (buggy driver crash prevention)"
261+
)
262+
endif()
263+
264+
message(STATUS "Device hot-plug interactive test configured: ccap_device_hotplug_test")
265+
if(WIN32)
266+
message(STATUS " Run manually with: cmake --build . --target run_device_hotplug_test")
267+
message(STATUS " Or execute: ${CMAKE_BINARY_DIR}/tests/Debug/ccap_device_hotplug_test.exe")
268+
else()
269+
message(STATUS " Run manually with: ./ccap_device_hotplug_test")
270+
endif()
271+

0 commit comments

Comments
 (0)