[client] tests: replace test defines with the unified ENABLE_TEST define

This commit is contained in:
Geoffrey McRae
2026-07-31 13:32:53 +10:00
parent 9a3d994204
commit 1a2e92beae
6 changed files with 69 additions and 86 deletions

View File

@@ -262,8 +262,7 @@ jobs:
cmake -S client -B client/build-client-tests \
-DOPTIMIZE_FOR_NATIVE=OFF \
-DENABLE_LIBDECOR=OFF \
-DENABLE_TEST_TRANSPORT=ON \
-DENABLE_RENDER_TESTS=ON
-DENABLE_TESTS=ON
- name: Build
run: cmake --build client/build-client-tests --parallel

View File

@@ -34,25 +34,14 @@ add_feature_info(ENABLE_OPENGL ENABLE_OPENGL "Legacy OpenGL renderer.")
option(ENABLE_EGL "Enable the EGL renderer" ON)
add_feature_info(ENABLE_EGL ENABLE_EGL "EGL renderer.")
option(ENABLE_TEST_TRANSPORT "Enable the test transport" OFF)
add_feature_info(ENABLE_TEST_TRANSPORT ENABLE_TEST_TRANSPORT
"Synthetic frames for graphics-pipeline validation.")
if(ENABLE_TEST_TRANSPORT)
add_definitions(-D ENABLE_TEST_TRANSPORT)
endif()
option(ENABLE_RENDER_TESTS "Build framebuffer rendering integration tests" OFF)
add_feature_info(ENABLE_RENDER_TESTS ENABLE_RENDER_TESTS
"Pixel-accurate EGL rendering tests using the test transport.")
option(ENABLE_TRANSPORT_TESTS "Build transport integration tests"
${ENABLE_RENDER_TESTS})
add_feature_info(ENABLE_TRANSPORT_TESTS ENABLE_TRANSPORT_TESTS
"Transport lifecycle and protocol integration tests.")
if(ENABLE_RENDER_TESTS AND NOT ENABLE_TEST_TRANSPORT)
message(FATAL_ERROR "ENABLE_RENDER_TESTS requires ENABLE_TEST_TRANSPORT")
endif()
if(ENABLE_RENDER_TESTS AND NOT ENABLE_EGL)
message(FATAL_ERROR "ENABLE_RENDER_TESTS requires ENABLE_EGL")
option(ENABLE_TESTS "Build all client tests and test support" OFF)
add_feature_info(ENABLE_TESTS ENABLE_TESTS
"Client unit and integration tests with synthetic transport support.")
if(ENABLE_TESTS)
if(NOT ENABLE_EGL)
message(FATAL_ERROR "ENABLE_TESTS requires ENABLE_EGL")
endif()
add_definitions(-D ENABLE_TESTS)
endif()
option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON)
@@ -249,7 +238,7 @@ target_link_libraries(looking-glass-client
cimgui
)
if(ENABLE_RENDER_TESTS OR ENABLE_TRANSPORT_TESTS)
if(ENABLE_TESTS)
include(CTest)
enable_testing()
add_subdirectory(tests)

View File

@@ -69,7 +69,7 @@
#include "render_queue.h"
#include "evdev.h"
#ifdef ENABLE_TEST_TRANSPORT
#ifdef ENABLE_TESTS
#include "interface/test_capture.h"
_Static_assert((int)LG_CAPTURE_RGBA8 == (int)LG_TEST_CAPTURE_RGBA8,
"capture format mismatch");
@@ -99,7 +99,7 @@ struct CursorState g_cursor;
// this structure is initialized in config.c
struct AppParams g_params = { 0 };
#ifdef ENABLE_TEST_TRANSPORT
#ifdef ENABLE_TESTS
static struct
{
const char * path;
@@ -205,7 +205,7 @@ static void preSwapCallback(void * udata)
ringbuffer_push(g_state.renderDuration,
&(float) {(nanotime() - *renderStart) * 1e-6f});
#ifdef ENABLE_TEST_TRANSPORT
#ifdef ENABLE_TESTS
if (!l_testCapture.enabled || l_testCapture.complete)
return;
@@ -713,7 +713,7 @@ int main_frameThread(void * unused)
g_state.formatValid = true;
formatVersion = format->version;
#ifdef ENABLE_TEST_TRANSPORT
#ifdef ENABLE_TESTS
atomic_store_explicit(&l_testFrameType, format->type,
memory_order_release);
#endif
@@ -803,7 +803,7 @@ int main_frameThread(void * unused)
g_state.lastFrameTimeValid = true;
atomic_fetch_add_explicit(&g_state.frameCount, 1, memory_order_relaxed);
#ifdef ENABLE_TEST_TRANSPORT
#ifdef ENABLE_TESTS
atomic_store_explicit(&l_testFrameSerial, frame.serial,
memory_order_release);
#endif
@@ -1211,7 +1211,7 @@ static int transportSessionProbe(void * opaque)
static int lg_run(void)
{
#ifdef ENABLE_TEST_TRANSPORT
#ifdef ENABLE_TESTS
memset(&l_testCapture, 0, sizeof(l_testCapture));
atomic_store_explicit(&l_testFrameSerial, 0, memory_order_relaxed);
atomic_store_explicit(&l_testFrameType, FRAME_TYPE_INVALID,

View File

@@ -17,64 +17,60 @@ set_tests_properties(font-tests PROPERTIES
TIMEOUT 10
)
if(ENABLE_TRANSPORT_TESTS)
add_executable(lgmp-transport-tests
add_executable(lgmp-transport-tests
lgmp_transport_test.c
)
target_link_libraries(lgmp-transport-tests
)
target_link_libraries(lgmp-transport-tests
${EXE_FLAGS}
transport_LGMP
lg_common
lgmp
)
add_test(NAME lgmp-transport-tests
)
add_test(NAME lgmp-transport-tests
COMMAND lgmp-transport-tests
)
set_tests_properties(lgmp-transport-tests PROPERTIES
)
set_tests_properties(lgmp-transport-tests PROPERTIES
TIMEOUT 10
)
)
find_package(GTest REQUIRED)
find_program(WESTON_EXECUTABLE NAMES weston)
if(NOT WESTON_EXECUTABLE)
message(FATAL_ERROR "weston is required to run framebuffer rendering tests")
endif()
if(ENABLE_RENDER_TESTS)
find_package(GTest REQUIRED)
find_program(WESTON_EXECUTABLE NAMES weston)
if(NOT WESTON_EXECUTABLE)
message(FATAL_ERROR "weston is required to run framebuffer rendering tests")
endif()
add_executable(render-tests
add_executable(render-tests
render_test.cpp
)
add_dependencies(render-tests looking-glass-client)
)
add_dependencies(render-tests looking-glass-client)
set_target_properties(render-tests PROPERTIES
set_target_properties(render-tests PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
)
target_compile_definitions(render-tests PRIVATE
target_compile_definitions(render-tests PRIVATE
LG_CLIENT_PATH="$<TARGET_FILE:looking-glass-client>"
)
)
target_include_directories(render-tests PRIVATE
target_include_directories(render-tests PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
"${PROJECT_TOP}/common/include"
)
)
if(TARGET GTest::gtest_main)
if(TARGET GTest::gtest_main)
target_link_libraries(render-tests GTest::gtest_main)
else()
else()
target_link_libraries(render-tests GTest::Main)
endif()
endif()
add_test(NAME render-tests
add_test(NAME render-tests
COMMAND /bin/bash
"${CMAKE_CURRENT_SOURCE_DIR}/run-with-weston.sh"
"${WESTON_EXECUTABLE}"
"$<TARGET_FILE:render-tests>"
)
)
set_tests_properties(render-tests PROPERTIES
set_tests_properties(render-tests PROPERTIES
TIMEOUT 120
)
endif()
)

View File

@@ -22,14 +22,13 @@ luminance, MaxCLL, and MaxFALL in the client log.
```sh
cmake -S client -B client/build \
-DENABLE_TEST_TRANSPORT=ON \
-DENABLE_RENDER_TESTS=ON
-DENABLE_TESTS=ON
cmake --build client/build
ctest --test-dir client/build --output-on-failure \
-R render-tests
```
GoogleTest and Weston are required when `ENABLE_RENDER_TESTS` is enabled.
GoogleTest and Weston are required when `ENABLE_TESTS` is enabled.
Failed cases retain their capture and client log under `/tmp` and print the
artifact paths.

View File

@@ -20,7 +20,7 @@ endfunction()
# Add/remove transports here!
add_transport(LGMP)
if(ENABLE_TEST_TRANSPORT)
if(ENABLE_TESTS)
add_transport(Test)
endif()