Skip to content

Commit 1b7046f

Browse files
Update Tests
1 parent 1da075d commit 1b7046f

5 files changed

Lines changed: 56 additions & 32 deletions

File tree

.github/workflows/unit-tests.yml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,56 @@ on:
77
branches:
88
- '**'
99

10+
permissions:
11+
contents: read
12+
actions: read
13+
checks: write
14+
pull-requests: write
15+
1016
jobs:
1117
unit-tests:
1218
runs-on: cern-nextgen-h100
1319
container: registry.cern.ch/ngt-wp1.7/wp1.7-soa-wrapper@sha256:16432eae6635379637e67c4cc00334c46b6dce845b83da7e75fb754d24266897
1420
steps:
1521
- uses: actions/checkout@v4
16-
- name: cpu_gcc
17-
env:
18-
CXX: g++
19-
CC: gcc
20-
TEST_DIR: tests/cpu
21-
run: &build-and-test |
22-
cmake -B ${{github.workspace}}/build/ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON
23-
cmake --build ${{github.workspace}}/build/${TEST_DIR}
24-
ctest --test-dir ${{github.workspace}}/build/${TEST_DIR} --output-on-failure
25-
rm -rf ${{github.workspace}}/build
26-
- name: cpu_clang
27-
env:
28-
CXX: clang++
29-
CC: clang
30-
TEST_DIR: tests/cpu
31-
run: *build-and-test
32-
- name: gpu_gcc
22+
name: checkout repository
23+
- name: gcc
3324
env:
3425
CXX: g++
3526
CC: gcc
3627
NVCC_CCBIN: gcc
3728
CUDACXX: nvcc
38-
TEST_DIR: tests/gpu
39-
run: *build-and-test
40-
- name: gpu_clang
29+
TEST_TAG: gcc
30+
run: &build-and-test |
31+
cmake -B ${{github.workspace}}/build/ -DBUILD_TESTING=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON
32+
cmake --build ${{github.workspace}}/build/
33+
ctest --test-dir ${{github.workspace}}/build/tests --output-on-failure --output-junit /root/test_${TEST_TAG}.xml
34+
rm -rf ${{github.workspace}}/build
35+
- name: clang
4136
env:
4237
CXX: clang++
4338
CC: clang
4439
NVCC_CCBIN: clang
4540
CUDACXX: nvcc
46-
TEST_DIR: tests/gpu
41+
TEST_TAG: clang
4742
run: *build-and-test
43+
- name: upload artifact
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: junit-artifacts
47+
path: |
48+
/root/test_gcc.xml
49+
/root/test_clang.xml
50+
publish-test-results:
51+
needs: unit-tests
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: download artifact
55+
uses: actions/download-artifact@v5
56+
with:
57+
name: junit-artifacts
58+
- name: publish test results
59+
uses: EnricoMi/publish-unit-test-result-action@v2
60+
if: (!cancelled())
61+
with:
62+
files: "test_*.xml"

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
cmake_minimum_required(VERSION 4.0)
22
project(memlayout LANGUAGES CXX)
33

4-
#option(ENABLE_CPU "Build CPU tests" ON)
5-
#option(ENABLE_CUDA "Build CUDA tests" ON)
4+
option(BUILD_TESTING "Build unit tests" OFF)
5+
option(BUILD_DOCS "Build documentation" OFF)
66

77
add_subdirectory(memlayout)
88

9-
add_subdirectory(tests EXCLUDE_FROM_ALL)
9+
if(BUILD_TESTING)
10+
add_subdirectory(tests)
11+
endif()
1012

11-
add_subdirectory(docs EXCLUDE_FROM_ALL)
13+
if(BUILD_DOCS)
14+
add_subdirectory(docs)
15+
endif()

tests/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
set(CMAKE_CXX_STANDARD 20)
2+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
4+
15
include(FetchContent)
26
FetchContent_Declare(
37
googletest
@@ -10,4 +14,9 @@ include(GoogleTest)
1014

1115
add_subdirectory(cpu)
1216

13-
add_subdirectory(gpu)
17+
find_package(CUDAToolkit QUIET)
18+
if(CUDAToolkit_FOUND OR CMAKE_CUDA_COMPILER)
19+
add_subdirectory(gpu)
20+
else()
21+
message(STATUS "CUDA not found - skipping GPU tests")
22+
endif()

tests/cpu/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
set(CMAKE_CXX_STANDARD 20)
2-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
4-
51
add_executable(test_cpu test_cpu.cpp)
6-
target_include_directories(test_cpu PUBLIC ${CMAKE_SOURCE_DIR}/tests/include ${CMAKE_CURRENT_SOURCE_DIR})
2+
target_include_directories(test_cpu PUBLIC ${CMAKE_SOURCE_DIR}/tests/include)
73
target_link_libraries(test_cpu PRIVATE memlayout::Wrapper GTest::gtest_main)
84

95
gtest_discover_tests(test_cpu)

tests/gpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ enable_language(CUDA)
44
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr")
55

66
add_executable(test_cuda test_cuda.cu)
7-
target_include_directories(test_cuda PUBLIC ${CMAKE_SOURCE_DIR}/tests/include ${CMAKE_CURRENT_SOURCE_DIR})
7+
target_include_directories(test_cuda PUBLIC ${CMAKE_SOURCE_DIR}/tests/include)
88
target_link_libraries(test_cuda PRIVATE memlayout::Wrapper GTest::gtest_main)
99
set_target_properties(test_cuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON CUDA_ARCHITECTURES native)
1010

0 commit comments

Comments
 (0)