Skip to content

Commit 8a0322d

Browse files
authored
Merge pull request #767 from jdemel/newtest
Add googletest based tests
2 parents bd4694d + 0858869 commit 8a0322d

File tree

9 files changed

+609
-128
lines changed

9 files changed

+609
-128
lines changed

.github/workflows/publish_docs.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v3.1.0
11-
with:
12-
submodules: 'recursive'
13-
- name: Install dependencies
14-
run: sudo apt install python3-mako liborc-dev doxygen
15-
- name: Configure
16-
run: mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-Werror" -DBUILD_EXECUTABLE=ON ..
17-
- name: Build
18-
run: cmake --build build --target volk_doc
19-
- name: Setup SSH Keys
20-
env:
21-
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
22-
run: |
23-
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
24-
ssh-add - <<< "${{ secrets.SSH_KEY }}"
25-
mkdir $HOME/.ssh
26-
echo -n "${{ secrets.SSH_KNOWN_HOST }}" > $HOME/.ssh/known_hosts
27-
- name: Upload via SSH
28-
env:
29-
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
30-
TARGET_DIR: "${{ github.ref_type }}/${{ github.ref_name }}"
31-
run: 'tar -cz build/html/ | ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_SERVER }} "mkdir -p /www/${{ env.TARGET_DIR }}/$(date +%Y.%m.%d); cd /www/${{ env.TARGET_DIR }}/$(date +%Y.%m.%d); tar --strip-components=2 -xz; rm /www/${{ env.TARGET_DIR }}/live; cd /www/${{ env.TARGET_DIR }}; ln -sf $(date +%Y.%m.%d) live;"'
32-
- uses: actions/upload-artifact@v4
33-
with:
34-
name: volk_docs
35-
path: build/html/
10+
- uses: actions/checkout@v4
11+
with:
12+
submodules: "recursive"
13+
- name: Install dependencies
14+
run: sudo apt install python3-mako liborc-dev doxygen
15+
- name: Configure
16+
run: mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-Werror" -DBUILD_EXECUTABLE=ON ..
17+
- name: Build
18+
run: cmake --build build --target volk_doc
19+
- name: Setup SSH Keys
20+
env:
21+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
22+
run: |
23+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
24+
ssh-add - <<< "${{ secrets.SSH_KEY }}"
25+
mkdir $HOME/.ssh
26+
echo -n "${{ secrets.SSH_KNOWN_HOST }}" > $HOME/.ssh/known_hosts
27+
- name: Upload via SSH
28+
env:
29+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
30+
TARGET_DIR: "${{ github.ref_type }}/${{ github.ref_name }}"
31+
run: 'tar -cz build/html/ | ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_SERVER }} "mkdir -p /www/${{ env.TARGET_DIR }}/$(date +%Y.%m.%d); cd /www/${{ env.TARGET_DIR }}/$(date +%Y.%m.%d); tar --strip-components=2 -xz; rm /www/${{ env.TARGET_DIR }}/live; cd /www/${{ env.TARGET_DIR }}; ln -sf $(date +%Y.%m.%d) live;"'
32+
- uses: actions/upload-artifact@v4
33+
with:
34+
name: volk_docs
35+
path: build/html/

.github/workflows/run-tests.yml

Lines changed: 96 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,51 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
compiler:
21-
- { name: g++-7, cc: gcc-7, cxx: g++-7, distro: ubuntu-20.04 }
22-
- { name: g++-8, cc: gcc-8, cxx: g++-8, distro: ubuntu-20.04 }
23-
- { name: g++-9, cc: gcc-9, cxx: g++-9, distro: ubuntu-latest }
24-
- { name: g++-10, cc: gcc-10, cxx: g++-10, distro: ubuntu-latest }
25-
- { name: clang-7, cc: clang-7, cxx: clang++-7, distro: ubuntu-20.04 }
26-
- { name: clang-8, cc: clang-8, cxx: clang++-8, distro: ubuntu-20.04 }
27-
- { name: clang-9, cc: clang-9, cxx: clang++-9, distro: ubuntu-20.04 }
21+
- { name: g++-9, cc: gcc-9, cxx: g++-9, distro: ubuntu-20.04 }
22+
- { name: g++-10, cc: gcc-10, cxx: g++-10, distro: ubuntu-20.04 }
23+
- { name: g++-11, cc: gcc-11, cxx: g++-11, distro: ubuntu-22.04 }
24+
- { name: g++-12, cc: gcc-12, cxx: g++-12, distro: ubuntu-22.04 }
25+
- { name: g++-13, cc: gcc-13, cxx: g++-13, distro: ubuntu-24.04 }
26+
- { name: g++-14, cc: gcc-14, cxx: g++-14, distro: ubuntu-24.04 }
2827
- { name: clang-10, cc: clang-10, cxx: clang++-10, distro: ubuntu-20.04 }
2928
- { name: clang-11, cc: clang-11, cxx: clang++-11, distro: ubuntu-20.04 }
30-
- { name: clang-12, cc: clang-12, cxx: clang++-12, distro: ubuntu-latest }
31-
- { name: clang-13, cc: clang-13, cxx: clang++-13, distro: ubuntu-latest }
32-
- { name: clang-14, cc: clang-14, cxx: clang++-14, distro: ubuntu-latest }
33-
# - { name: clang-15, cc: clang-15, cxx: clang++-15, distro: ubuntu-latest }
29+
- { name: clang-12, cc: clang-12, cxx: clang++-12, distro: ubuntu-22.04 }
30+
- { name: clang-13, cc: clang-13, cxx: clang++-13, distro: ubuntu-22.04 }
31+
- { name: clang-14, cc: clang-14, cxx: clang++-14, distro: ubuntu-22.04 }
32+
- { name: clang-15, cc: clang-15, cxx: clang++-15, distro: ubuntu-22.04 }
33+
- { name: clang-16, cc: clang-16, cxx: clang++-16, distro: ubuntu-24.04 }
34+
- { name: clang-17, cc: clang-17, cxx: clang++-17, distro: ubuntu-24.04 }
35+
- { name: clang-18, cc: clang-18, cxx: clang++-18, distro: ubuntu-24.04 }
3436

3537
runs-on: ${{ matrix.compiler.distro }}
3638

3739
steps:
38-
- uses: actions/checkout@v4
39-
with:
40-
submodules: 'recursive'
41-
- name: Install dependencies
42-
run: sudo apt install python3-mako liborc-dev ${{ matrix.compiler.name }}
43-
- name: Configure
44-
env:
45-
CC: ${{ matrix.compiler.cc }}
46-
CXX: ${{ matrix.compiler.cxx }}
47-
run: mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-Werror" -DBUILD_EXECUTABLE=ON ..
48-
- name: Build
49-
run: |
50-
echo "Build with $(nproc) thread(s)"
51-
cmake --build build -j$(nproc)
52-
- name: Print info
53-
run: |
54-
./build/cpu_features/list_cpu_features
55-
./build/apps/volk-config-info --alignment
56-
./build/apps/volk-config-info --avail-machines
57-
./build/apps/volk-config-info --all-machines
58-
./build/apps/volk-config-info --malloc
59-
./build/apps/volk-config-info --cc
60-
- name: Test
61-
run: |
62-
cd build
63-
ctest -V
40+
- uses: actions/checkout@v4
41+
with:
42+
submodules: "recursive"
43+
- name: Install dependencies
44+
run: sudo apt install python3-mako liborc-dev libgtest-dev libfmt-dev ${{ matrix.compiler.name }}
45+
- name: Configure
46+
env:
47+
CC: ${{ matrix.compiler.cc }}
48+
CXX: ${{ matrix.compiler.cxx }}
49+
run: mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-Werror" -DBUILD_EXECUTABLE=ON ..
50+
- name: Build
51+
run: |
52+
echo "Build with $(nproc) thread(s)"
53+
cmake --build build -j$(nproc)
54+
- name: Print info
55+
run: |
56+
./build/cpu_features/list_cpu_features
57+
./build/apps/volk-config-info --alignment
58+
./build/apps/volk-config-info --avail-machines
59+
./build/apps/volk-config-info --all-machines
60+
./build/apps/volk-config-info --malloc
61+
./build/apps/volk-config-info --cc
62+
- name: Test
63+
run: |
64+
cd build
65+
ctest -V
6466
6567
build-ubuntu-arm:
6668
# The host should always be linux
@@ -73,9 +75,6 @@ jobs:
7375
fail-fast: false
7476
matrix:
7577
include:
76-
- arch: aarch64
77-
distro: ubuntu20.04
78-
compiler: { name: g++-8, cc: gcc-8, cxx: g++-8 }
7978
- arch: aarch64
8079
distro: ubuntu20.04
8180
compiler: { name: g++-9, cc: gcc-9, cxx: g++-9 }
@@ -94,6 +93,9 @@ jobs:
9493
- arch: aarch64
9594
distro: ubuntu22.04
9695
compiler: { name: clang-14, cc: clang-14, cxx: clang++-14 }
96+
- arch: aarch64
97+
distro: ubuntu22.04
98+
compiler: { name: clang-15, cc: clang-15, cxx: clang++-15 }
9799
- arch: armv7
98100
distro: ubuntu22.04
99101
compiler: { name: g++, cc: gcc, cxx: g++ }
@@ -112,8 +114,8 @@ jobs:
112114
steps:
113115
- uses: actions/checkout@v4
114116
with:
115-
submodules: 'recursive'
116-
- uses: uraimo/run-on-arch-action@v2.5.0
117+
submodules: "recursive"
118+
- uses: uraimo/run-on-arch-action@v2.7.2
117119
name: Build in non-x86 container
118120
id: build
119121
with:
@@ -139,7 +141,7 @@ jobs:
139141
case "${{ matrix.distro }}" in
140142
ubuntu*|jessie|stretch|buster)
141143
apt-get update -q -y
142-
apt-get install -q -y git cmake python3-mako liborc-dev ${{ matrix.compiler.name }}
144+
apt-get install -q -y git cmake python3-mako liborc-dev libgtest-dev libfmt-dev ${{ matrix.compiler.name }}
143145
;;
144146
fedora*)
145147
dnf -y update
@@ -169,44 +171,41 @@ jobs:
169171
runs-on: ubuntu-latest
170172

171173
steps:
172-
- uses: actions/checkout@v4
173-
with:
174-
submodules: 'recursive'
175-
- name: dependencies
176-
run: sudo apt install python3-mako liborc-dev
177-
- name: configure
178-
run: mkdir build && cd build && cmake -DENABLE_STATIC_LIBS=True -DBUILD_EXECUTABLE=ON ..
179-
- name: build
180-
run: cmake --build build -j$(nproc)
181-
- name: Print info
182-
run: |
183-
./build/cpu_features/list_cpu_features
184-
./build/apps/volk-config-info --alignment
185-
./build/apps/volk-config-info --avail-machines
186-
./build/apps/volk-config-info --all-machines
187-
./build/apps/volk-config-info --malloc
188-
./build/apps/volk-config-info --cc
189-
- name: test
190-
run: cd build && ctest -V
191-
192-
174+
- uses: actions/checkout@v4
175+
with:
176+
submodules: "recursive"
177+
- name: dependencies
178+
run: sudo apt install python3-mako liborc-dev libgtest-dev libfmt-dev
179+
- name: configure
180+
run: mkdir build && cd build && cmake -DENABLE_STATIC_LIBS=True -DBUILD_EXECUTABLE=ON ..
181+
- name: build
182+
run: cmake --build build -j$(nproc)
183+
- name: Print info
184+
run: |
185+
./build/cpu_features/list_cpu_features
186+
./build/apps/volk-config-info --alignment
187+
./build/apps/volk-config-info --avail-machines
188+
./build/apps/volk-config-info --all-machines
189+
./build/apps/volk-config-info --malloc
190+
./build/apps/volk-config-info --cc
191+
- name: test
192+
run: cd build && ctest -V
193193

194194
build-windows:
195-
196195
runs-on: windows-latest
197196

198197
steps:
199-
- uses: actions/checkout@v4
200-
with:
201-
submodules: 'recursive'
202-
- name: dependencies
203-
run: pip install mako
204-
- name: configure
205-
run: mkdir build && cd build && cmake ..
206-
- name: build
207-
run: cmake --build build --config Release --target INSTALL -j2
208-
- name: test
209-
run: cd build && ctest -V -C Release
198+
- uses: actions/checkout@v4
199+
with:
200+
submodules: "recursive"
201+
- name: dependencies
202+
run: pip install mako
203+
- name: configure
204+
run: mkdir build && cd build && cmake ..
205+
- name: build
206+
run: cmake --build build --config Release --target INSTALL -j4
207+
- name: test
208+
run: cd build && ctest -V -C Release
210209

211210
# build-windows-msys2:
212211
# name: Build on windows-latest using MinGW and MSYS2
@@ -226,7 +225,7 @@ jobs:
226225
# python-six
227226
# mingw-w64-x86_64-gcc
228227
# mingw-w64-x86_64-cmake
229-
# - uses: actions/checkout@v2
228+
# - uses: actions/checkout@v4
230229
# - name: Checkout submodules
231230
# run: git submodule update --init --recursive
232231
# - name: Configure
@@ -242,32 +241,29 @@ jobs:
242241
# ctest -V
243242

244243
build-macos:
245-
246244
strategy:
247245
matrix:
248-
os: [macos-latest, flyci-macos-large-latest-m2]
246+
os: [macos-13, macos-latest]
249247

250248
runs-on: ${{ matrix.os }}
251249

252250
steps:
253-
- uses: actions/checkout@v4
254-
with:
255-
submodules: 'recursive'
256-
- name: dependencies
257-
run: pip3 install --break-system-packages mako && brew install orc
258-
- name: configure
259-
run: mkdir build && cd build && cmake -DBUILD_EXECUTABLE=ON ..
260-
- name: build
261-
run: cmake --build build --config Debug -j3
262-
- name: Print info
263-
run: |
264-
./build/cpu_features/list_cpu_features
265-
# ./build/apps/volk-config-info --alignment
266-
# ./build/apps/volk-config-info --avail-machines
267-
# ./build/apps/volk-config-info --all-machines
268-
# ./build/apps/volk-config-info --malloc
269-
# ./build/apps/volk-config-info --cc
270-
- name: test
271-
run: cd build && ctest -V
272-
273-
251+
- uses: actions/checkout@v4
252+
with:
253+
submodules: "recursive"
254+
- name: dependencies
255+
run: pip3 install --break-system-packages mako && brew install orc
256+
- name: configure
257+
run: mkdir build && cd build && cmake -DBUILD_EXECUTABLE=ON ..
258+
- name: build
259+
run: cmake --build build --config Debug -j4
260+
- name: Print info
261+
run: |
262+
./build/cpu_features/list_cpu_features
263+
# ./build/apps/volk-config-info --alignment
264+
# ./build/apps/volk-config-info --avail-machines
265+
# ./build/apps/volk-config-info --all-machines
266+
# ./build/apps/volk-config-info --malloc
267+
# ./build/apps/volk-config-info --cc
268+
- name: test
269+
run: cd build && ctest -V

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ message(STATUS " Modify using: -DENABLE_PROFILING=ON/OFF")
371371
########################################################################
372372
add_subdirectory(lib)
373373

374+
########################################################################
375+
# Add tests
376+
########################################################################
377+
add_subdirectory(tests)
378+
374379
########################################################################
375380
# And the utility apps
376381
########################################################################

tests/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Copyright 2022, 2024 Johannes Demel
3+
#
4+
# This file is part of VOLK.
5+
#
6+
# SPDX-License-Identifier: LGPL-3.0-or-later
7+
#
8+
9+
if(NOT ENABLE_TESTING)
10+
return()
11+
endif(NOT ENABLE_TESTING)
12+
13+
find_package(fmt)
14+
find_package(GTest)
15+
16+
if(NOT fmt_FOUND OR NOT GTest_FOUND)
17+
message(warning "Missing fmtlib and/or googletest for this test suite")
18+
return()
19+
endif(NOT fmt_FOUND OR NOT GTest_FOUND)
20+
21+
file(GLOB volk_test_files "test_*.cc")
22+
23+
add_executable(
24+
volk_tests
25+
volk_test.cc
26+
${volk_test_files}
27+
)
28+
29+
target_compile_features(volk_tests PUBLIC cxx_std_20)
30+
31+
target_link_libraries(volk_tests
32+
PRIVATE
33+
GTest::gtest_main
34+
volk
35+
fmt::fmt
36+
)
37+
38+
include(GoogleTest)
39+
gtest_discover_tests(volk_tests)
40+
41+
42+
target_include_directories(volk_tests
43+
PRIVATE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
44+
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
45+
PRIVATE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/lib>
46+
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib>
47+
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
48+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
49+
)

0 commit comments

Comments
 (0)