Run the shared C++ runtime test suite through CTest

This commit is contained in:
patchzyy
2026-09-07 23:12:18 +02:00
parent 05d6a0b1ab
commit 9066cb3560
3 changed files with 72 additions and 98 deletions
+8 -16
View File
@@ -47,8 +47,8 @@ jobs:
- name: Test
run: dotnet test translator/Translator.sln -c Release --no-build --verbosity normal
nand:
name: NAND regression tests (${{ matrix.os }})
cpp:
name: C++ runtime tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
@@ -59,17 +59,9 @@ jobs:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Compile and run NAND tests
shell: bash
run: |
flags=(-std=c++17 -Wall -Wextra -Werror)
if [[ "$RUNNER_OS" != Windows ]]; then flags+=(-pthread); fi
clang++ "${flags[@]}" -Iruntime/src/hle/storage \
runtime/tests/nand_move_tests.cpp runtime/src/hle/storage/nand_file_ops.cpp \
-o "$RUNNER_TEMP/nand_move_tests.exe"
"$RUNNER_TEMP/nand_move_tests.exe"
for test in nand_save nand_settings; do
clang++ "${flags[@]}" -Iruntime/include "runtime/tests/${test}_tests.cpp" \
-o "$RUNNER_TEMP/${test}_tests.exe"
"$RUNNER_TEMP/${test}_tests.exe"
done
- name: Configure
run: cmake -S runtime/tests -B build/tests -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build/tests --config Release --parallel
- name: Test
run: ctest --test-dir build/tests -C Release --output-on-failure --no-tests=error
+1 -82
View File
@@ -269,89 +269,8 @@ target_include_directories(mkw_platform PUBLIC "${CMAKE_CURRENT_LIST_DIR}/includ
target_compile_features(mkw_platform PUBLIC cxx_std_17)
set_target_properties(mkw_platform PROPERTIES UNITY_BUILD OFF)
# Keep these independent from Aurora's BUILD_TESTING option: they validate the
# project's host-platform contracts, not Aurora's third-party test suite.
enable_testing()
add_executable(mkw_platform_paths_tests "${CMAKE_CURRENT_LIST_DIR}/tests/platform_paths_tests.cpp")
target_link_libraries(mkw_platform_paths_tests PRIVATE mkw_platform)
target_compile_features(mkw_platform_paths_tests PRIVATE cxx_std_17)
add_test(NAME mkw_platform_paths_tests COMMAND mkw_platform_paths_tests)
add_executable(mkw_nand_save_tests "${CMAKE_CURRENT_LIST_DIR}/tests/nand_save_tests.cpp")
target_include_directories(mkw_nand_save_tests PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")
target_compile_features(mkw_nand_save_tests PRIVATE cxx_std_17)
add_test(NAME mkw_nand_save_tests COMMAND mkw_nand_save_tests)
add_executable(mkw_nand_move_tests
"${CMAKE_CURRENT_LIST_DIR}/tests/nand_move_tests.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/hle/storage/nand_file_ops.cpp")
find_package(Threads REQUIRED)
target_link_libraries(mkw_nand_move_tests PRIVATE Threads::Threads)
target_include_directories(mkw_nand_move_tests PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src/hle/storage")
target_compile_features(mkw_nand_move_tests PRIVATE cxx_std_17)
add_test(NAME mkw_nand_move_tests COMMAND mkw_nand_move_tests)
add_executable(mkw_nand_settings_tests "${CMAKE_CURRENT_LIST_DIR}/tests/nand_settings_tests.cpp")
find_package(Threads REQUIRED)
target_link_libraries(mkw_nand_settings_tests PRIVATE Threads::Threads)
target_include_directories(mkw_nand_settings_tests PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")
target_compile_features(mkw_nand_settings_tests PRIVATE cxx_std_17)
add_test(NAME mkw_nand_settings_tests COMMAND mkw_nand_settings_tests)
add_executable(mkw_sc_serial_tests "${CMAKE_CURRENT_LIST_DIR}/tests/sc_serial_tests.cpp")
target_include_directories(mkw_sc_serial_tests PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")
target_compile_features(mkw_sc_serial_tests PRIVATE cxx_std_17)
add_test(NAME mkw_sc_serial_tests COMMAND mkw_sc_serial_tests)
# The input expression engine is self-contained, so it can be exercised without
# linking the runtime or SDL.
add_executable(mkw_input_expr_tests
"${CMAKE_CURRENT_LIST_DIR}/tests/test_expr.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/input_expr.cpp")
target_include_directories(mkw_input_expr_tests PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")
target_compile_features(mkw_input_expr_tests PRIVATE cxx_std_17)
add_test(NAME mkw_input_expr_tests COMMAND mkw_input_expr_tests)
# HostContext deliberately keeps the platform-specific context primitive out
# of fiber_manager.cpp. Exercise the Linux libco handoff directly so future
# refactors cannot silently remove its headers, implementation, or link edge.
if(MKW_PLATFORM_LINUX)
add_executable(mkw_linux_host_context_tests
"${CMAKE_CURRENT_LIST_DIR}/tests/host_context_tests.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/host_context.cpp")
target_include_directories(mkw_linux_host_context_tests PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/include"
"${CMAKE_CURRENT_LIST_DIR}/third_party/libco")
target_compile_features(mkw_linux_host_context_tests PRIVATE cxx_std_17)
target_link_libraries(mkw_linux_host_context_tests PRIVATE mkw::libco)
add_test(NAME mkw_linux_host_context_tests COMMAND mkw_linux_host_context_tests)
endif()
if(MKW_PLATFORM_MACOS)
# Exercise the Apple Silicon context ABI and the public host-memory
# contracts separately from translated products.
enable_language(ASM)
add_executable(mkw_macos_context_abi_tests
"${CMAKE_CURRENT_LIST_DIR}/tests/macos_context_abi_tests.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/platform/macos/co_switch.S")
target_compile_features(mkw_macos_context_abi_tests PRIVATE cxx_std_17)
add_test(NAME mkw_macos_context_abi_tests COMMAND mkw_macos_context_abi_tests)
add_executable(mkw_macos_host_context_tests
"${CMAKE_CURRENT_LIST_DIR}/tests/host_context_tests.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/host_context.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/platform/macos/co_switch.S")
target_include_directories(mkw_macos_host_context_tests PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")
target_compile_features(mkw_macos_host_context_tests PRIVATE cxx_std_17)
add_test(NAME mkw_macos_host_context_tests COMMAND mkw_macos_host_context_tests)
add_executable(mkw_macos_guest_flat_memory_tests
"${CMAKE_CURRENT_LIST_DIR}/tests/macos_guest_flat_memory_tests.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/guest_flat_memory_macos.cpp")
target_include_directories(mkw_macos_guest_flat_memory_tests PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")
target_compile_features(mkw_macos_guest_flat_memory_tests PRIVATE cxx_std_17)
add_test(NAME mkw_macos_guest_flat_memory_tests COMMAND mkw_macos_guest_flat_memory_tests)
endif()
add_subdirectory(tests)
# The translator emits the complete, content-addressed source graph. Consuming
# this one manifest keeps configure independent of the 28k generated function
+63
View File
@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.16)
# Share the same test registrations with the full runtime build, while allowing
# CI and developers to run them without translated game files or Aurora.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(WiiCompiledRuntimeTests LANGUAGES C CXX)
enable_testing()
endif()
get_filename_component(runtime_root "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
find_package(Threads REQUIRED)
function(mkw_add_test name)
add_executable(${name} ${ARGN})
target_include_directories(${name} PRIVATE "${runtime_root}/include")
target_compile_features(${name} PRIVATE cxx_std_17)
target_link_libraries(${name} PRIVATE Threads::Threads)
add_test(NAME ${name} COMMAND ${name})
endfunction()
if(NOT TARGET mkw_platform)
add_library(mkw_platform STATIC "${runtime_root}/src/platform/host_platform.cpp")
target_include_directories(mkw_platform PUBLIC "${runtime_root}/include")
target_compile_features(mkw_platform PUBLIC cxx_std_17)
endif()
if(WIN32)
target_link_libraries(mkw_platform PUBLIC shell32 ole32)
endif()
mkw_add_test(mkw_platform_paths_tests platform_paths_tests.cpp)
target_link_libraries(mkw_platform_paths_tests PRIVATE mkw_platform)
mkw_add_test(mkw_nand_save_tests nand_save_tests.cpp)
mkw_add_test(mkw_nand_move_tests nand_move_tests.cpp
"${runtime_root}/src/hle/storage/nand_file_ops.cpp")
target_include_directories(mkw_nand_move_tests PRIVATE "${runtime_root}/src/hle/storage")
mkw_add_test(mkw_nand_settings_tests nand_settings_tests.cpp)
mkw_add_test(mkw_sc_serial_tests sc_serial_tests.cpp)
mkw_add_test(mkw_input_expr_tests test_expr.cpp "${runtime_root}/src/input_expr.cpp")
if(WIN32)
mkw_add_test(mkw_windows_host_context_tests host_context_tests.cpp
"${runtime_root}/src/host_context.cpp")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(NOT TARGET mkw::libco)
add_library(mkw_libco STATIC "${runtime_root}/third_party/libco/libco.c")
add_library(mkw::libco ALIAS mkw_libco)
target_include_directories(mkw_libco PUBLIC "${runtime_root}/third_party/libco")
endif()
mkw_add_test(mkw_linux_host_context_tests host_context_tests.cpp
"${runtime_root}/src/host_context.cpp")
target_link_libraries(mkw_linux_host_context_tests PRIVATE mkw::libco)
elseif(APPLE)
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64|aarch64)$")
message(FATAL_ERROR "The macOS runtime tests require Apple Silicon")
endif()
enable_language(ASM)
set(context_asm "${runtime_root}/src/platform/macos/co_switch.S")
mkw_add_test(mkw_macos_context_abi_tests macos_context_abi_tests.cpp "${context_asm}")
mkw_add_test(mkw_macos_host_context_tests host_context_tests.cpp
"${runtime_root}/src/host_context.cpp" "${context_asm}")
mkw_add_test(mkw_macos_guest_flat_memory_tests macos_guest_flat_memory_tests.cpp
"${runtime_root}/src/guest_flat_memory_macos.cpp")
endif()