diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0218db60..cdf0ea4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index f05f0d52..770ecd1f 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -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) diff --git a/client/src/main.c b/client/src/main.c index c8602f8c..6762001d 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -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, diff --git a/client/tests/CMakeLists.txt b/client/tests/CMakeLists.txt index c1231568..f5485aa3 100644 --- a/client/tests/CMakeLists.txt +++ b/client/tests/CMakeLists.txt @@ -17,64 +17,60 @@ set_tests_properties(font-tests PROPERTIES TIMEOUT 10 ) -if(ENABLE_TRANSPORT_TESTS) - add_executable(lgmp-transport-tests - lgmp_transport_test.c - ) - target_link_libraries(lgmp-transport-tests - ${EXE_FLAGS} - transport_LGMP - lg_common - lgmp - ) - add_test(NAME lgmp-transport-tests - COMMAND lgmp-transport-tests - ) - set_tests_properties(lgmp-transport-tests PROPERTIES - TIMEOUT 10 - ) +add_executable(lgmp-transport-tests + lgmp_transport_test.c +) +target_link_libraries(lgmp-transport-tests + ${EXE_FLAGS} + transport_LGMP + lg_common + lgmp +) +add_test(NAME lgmp-transport-tests + COMMAND lgmp-transport-tests +) +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 + render_test.cpp +) +add_dependencies(render-tests looking-glass-client) - add_executable(render-tests - render_test.cpp - ) - add_dependencies(render-tests looking-glass-client) +set_target_properties(render-tests PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON +) - set_target_properties(render-tests PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - ) +target_compile_definitions(render-tests PRIVATE + LG_CLIENT_PATH="$" +) - target_compile_definitions(render-tests PRIVATE - LG_CLIENT_PATH="$" - ) +target_include_directories(render-tests PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/../include" + "${PROJECT_TOP}/common/include" +) - target_include_directories(render-tests PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../include" - "${PROJECT_TOP}/common/include" - ) - - if(TARGET GTest::gtest_main) - target_link_libraries(render-tests GTest::gtest_main) - else() - target_link_libraries(render-tests GTest::Main) - endif() - - add_test(NAME render-tests - COMMAND /bin/bash - "${CMAKE_CURRENT_SOURCE_DIR}/run-with-weston.sh" - "${WESTON_EXECUTABLE}" - "$" - ) - - set_tests_properties(render-tests PROPERTIES - TIMEOUT 120 - ) +if(TARGET GTest::gtest_main) + target_link_libraries(render-tests GTest::gtest_main) +else() + target_link_libraries(render-tests GTest::Main) endif() + +add_test(NAME render-tests + COMMAND /bin/bash + "${CMAKE_CURRENT_SOURCE_DIR}/run-with-weston.sh" + "${WESTON_EXECUTABLE}" + "$" +) + +set_tests_properties(render-tests PROPERTIES + TIMEOUT 120 +) diff --git a/client/tests/README.md b/client/tests/README.md index 1a581c28..02b422f3 100644 --- a/client/tests/README.md +++ b/client/tests/README.md @@ -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. diff --git a/client/transports/CMakeLists.txt b/client/transports/CMakeLists.txt index 1a40eb32..26ca2b71 100644 --- a/client/transports/CMakeLists.txt +++ b/client/transports/CMakeLists.txt @@ -20,7 +20,7 @@ endfunction() # Add/remove transports here! add_transport(LGMP) -if(ENABLE_TEST_TRANSPORT) +if(ENABLE_TESTS) add_transport(Test) endif()