diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ca87dde74..4fde3ce39f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2066,6 +2066,12 @@ set_tests_properties(check_artifacts PROPERTIES LABELS "validation;artifacts" REQUIRED_FILES "${CMAKE_SOURCE_DIR}/release/idtech3_server") +add_test(NAME regression_run_vulkan_launcher + COMMAND /usr/bin/env bash ${CMAKE_SOURCE_DIR}/tests/scripts/test_run_vulkan.sh ${CMAKE_SOURCE_DIR}/scripts/run_vulkan.sh + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +set_tests_properties(regression_run_vulkan_launcher PROPERTIES + LABELS "unit;regression;scripts") + # --- Unit tests --- option(BUILD_UNIT_TESTS "Build unit tests" ON) if(BUILD_UNIT_TESTS) diff --git a/tests/scripts/test_run_vulkan.sh b/tests/scripts/test_run_vulkan.sh new file mode 100755 index 0000000000..e5c15e14f2 --- /dev/null +++ b/tests/scripts/test_run_vulkan.sh @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +# Regression tests for scripts/run_vulkan.sh launcher selection logic. +set -euo pipefail + +SCRIPT_UNDER_TEST="${1:-}" +if [ -z "$SCRIPT_UNDER_TEST" ] || [ ! -f "$SCRIPT_UNDER_TEST" ]; then + echo "Usage: $0 /absolute/path/to/scripts/run_vulkan.sh" >&2 + exit 2 +fi + +fail() { + echo "FAIL: $*" >&2 + exit 1 +} + +assert_contains() { + local haystack="$1" + local needle="$2" + local context="$3" + if [[ "$haystack" != *"$needle"* ]]; then + fail "$context: expected '$needle' in output: $haystack" + fi +} + +assert_not_contains() { + local haystack="$1" + local needle="$2" + local context="$3" + if [[ "$haystack" == *"$needle"* ]]; then + fail "$context: unexpected '$needle' in output: $haystack" + fi +} + +make_engine_stub() { + local path="$1" + local marker="$2" + cat > "$path" < "$bin_dir/uname" <