Skip to content

Commit

Permalink
Merge pull request #767 from jdemel/newtest
Browse files Browse the repository at this point in the history
Add googletest based tests
  • Loading branch information
jdemel authored Oct 28, 2024
2 parents bd4694d + 0858869 commit 8a0322d
Show file tree
Hide file tree
Showing 9 changed files with 609 additions and 128 deletions.
52 changes: 26 additions & 26 deletions .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.1.0
with:
submodules: 'recursive'
- name: Install dependencies
run: sudo apt install python3-mako liborc-dev doxygen
- name: Configure
run: mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-Werror" -DBUILD_EXECUTABLE=ON ..
- name: Build
run: cmake --build build --target volk_doc
- name: Setup SSH Keys
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_KEY }}"
mkdir $HOME/.ssh
echo -n "${{ secrets.SSH_KNOWN_HOST }}" > $HOME/.ssh/known_hosts
- name: Upload via SSH
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
TARGET_DIR: "${{ github.ref_type }}/${{ github.ref_name }}"
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;"'
- uses: actions/upload-artifact@v4
with:
name: volk_docs
path: build/html/
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install dependencies
run: sudo apt install python3-mako liborc-dev doxygen
- name: Configure
run: mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-Werror" -DBUILD_EXECUTABLE=ON ..
- name: Build
run: cmake --build build --target volk_doc
- name: Setup SSH Keys
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_KEY }}"
mkdir $HOME/.ssh
echo -n "${{ secrets.SSH_KNOWN_HOST }}" > $HOME/.ssh/known_hosts
- name: Upload via SSH
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
TARGET_DIR: "${{ github.ref_type }}/${{ github.ref_name }}"
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;"'
- uses: actions/upload-artifact@v4
with:
name: volk_docs
path: build/html/
196 changes: 96 additions & 100 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,51 @@ jobs:
fail-fast: false
matrix:
compiler:
- { name: g++-7, cc: gcc-7, cxx: g++-7, distro: ubuntu-20.04 }
- { name: g++-8, cc: gcc-8, cxx: g++-8, distro: ubuntu-20.04 }
- { name: g++-9, cc: gcc-9, cxx: g++-9, distro: ubuntu-latest }
- { name: g++-10, cc: gcc-10, cxx: g++-10, distro: ubuntu-latest }
- { name: clang-7, cc: clang-7, cxx: clang++-7, distro: ubuntu-20.04 }
- { name: clang-8, cc: clang-8, cxx: clang++-8, distro: ubuntu-20.04 }
- { name: clang-9, cc: clang-9, cxx: clang++-9, distro: ubuntu-20.04 }
- { name: g++-9, cc: gcc-9, cxx: g++-9, distro: ubuntu-20.04 }
- { name: g++-10, cc: gcc-10, cxx: g++-10, distro: ubuntu-20.04 }
- { name: g++-11, cc: gcc-11, cxx: g++-11, distro: ubuntu-22.04 }
- { name: g++-12, cc: gcc-12, cxx: g++-12, distro: ubuntu-22.04 }
- { name: g++-13, cc: gcc-13, cxx: g++-13, distro: ubuntu-24.04 }
- { name: g++-14, cc: gcc-14, cxx: g++-14, distro: ubuntu-24.04 }
- { name: clang-10, cc: clang-10, cxx: clang++-10, distro: ubuntu-20.04 }
- { name: clang-11, cc: clang-11, cxx: clang++-11, distro: ubuntu-20.04 }
- { name: clang-12, cc: clang-12, cxx: clang++-12, distro: ubuntu-latest }
- { name: clang-13, cc: clang-13, cxx: clang++-13, distro: ubuntu-latest }
- { name: clang-14, cc: clang-14, cxx: clang++-14, distro: ubuntu-latest }
# - { name: clang-15, cc: clang-15, cxx: clang++-15, distro: ubuntu-latest }
- { name: clang-12, cc: clang-12, cxx: clang++-12, distro: ubuntu-22.04 }
- { name: clang-13, cc: clang-13, cxx: clang++-13, distro: ubuntu-22.04 }
- { name: clang-14, cc: clang-14, cxx: clang++-14, distro: ubuntu-22.04 }
- { name: clang-15, cc: clang-15, cxx: clang++-15, distro: ubuntu-22.04 }
- { name: clang-16, cc: clang-16, cxx: clang++-16, distro: ubuntu-24.04 }
- { name: clang-17, cc: clang-17, cxx: clang++-17, distro: ubuntu-24.04 }
- { name: clang-18, cc: clang-18, cxx: clang++-18, distro: ubuntu-24.04 }

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

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install dependencies
run: sudo apt install python3-mako liborc-dev ${{ matrix.compiler.name }}
- name: Configure
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
run: mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-Werror" -DBUILD_EXECUTABLE=ON ..
- name: Build
run: |
echo "Build with $(nproc) thread(s)"
cmake --build build -j$(nproc)
- name: Print info
run: |
./build/cpu_features/list_cpu_features
./build/apps/volk-config-info --alignment
./build/apps/volk-config-info --avail-machines
./build/apps/volk-config-info --all-machines
./build/apps/volk-config-info --malloc
./build/apps/volk-config-info --cc
- name: Test
run: |
cd build
ctest -V
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install dependencies
run: sudo apt install python3-mako liborc-dev libgtest-dev libfmt-dev ${{ matrix.compiler.name }}
- name: Configure
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
run: mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-Werror" -DBUILD_EXECUTABLE=ON ..
- name: Build
run: |
echo "Build with $(nproc) thread(s)"
cmake --build build -j$(nproc)
- name: Print info
run: |
./build/cpu_features/list_cpu_features
./build/apps/volk-config-info --alignment
./build/apps/volk-config-info --avail-machines
./build/apps/volk-config-info --all-machines
./build/apps/volk-config-info --malloc
./build/apps/volk-config-info --cc
- name: Test
run: |
cd build
ctest -V
build-ubuntu-arm:
# The host should always be linux
Expand All @@ -73,9 +75,6 @@ jobs:
fail-fast: false
matrix:
include:
- arch: aarch64
distro: ubuntu20.04
compiler: { name: g++-8, cc: gcc-8, cxx: g++-8 }
- arch: aarch64
distro: ubuntu20.04
compiler: { name: g++-9, cc: gcc-9, cxx: g++-9 }
Expand All @@ -94,6 +93,9 @@ jobs:
- arch: aarch64
distro: ubuntu22.04
compiler: { name: clang-14, cc: clang-14, cxx: clang++-14 }
- arch: aarch64
distro: ubuntu22.04
compiler: { name: clang-15, cc: clang-15, cxx: clang++-15 }
- arch: armv7
distro: ubuntu22.04
compiler: { name: g++, cc: gcc, cxx: g++ }
Expand All @@ -112,8 +114,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: uraimo/run-on-arch-action@v2.5.0
submodules: "recursive"
- uses: uraimo/run-on-arch-action@v2.7.2
name: Build in non-x86 container
id: build
with:
Expand All @@ -139,7 +141,7 @@ jobs:
case "${{ matrix.distro }}" in
ubuntu*|jessie|stretch|buster)
apt-get update -q -y
apt-get install -q -y git cmake python3-mako liborc-dev ${{ matrix.compiler.name }}
apt-get install -q -y git cmake python3-mako liborc-dev libgtest-dev libfmt-dev ${{ matrix.compiler.name }}
;;
fedora*)
dnf -y update
Expand Down Expand Up @@ -169,44 +171,41 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: dependencies
run: sudo apt install python3-mako liborc-dev
- name: configure
run: mkdir build && cd build && cmake -DENABLE_STATIC_LIBS=True -DBUILD_EXECUTABLE=ON ..
- name: build
run: cmake --build build -j$(nproc)
- name: Print info
run: |
./build/cpu_features/list_cpu_features
./build/apps/volk-config-info --alignment
./build/apps/volk-config-info --avail-machines
./build/apps/volk-config-info --all-machines
./build/apps/volk-config-info --malloc
./build/apps/volk-config-info --cc
- name: test
run: cd build && ctest -V


- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: dependencies
run: sudo apt install python3-mako liborc-dev libgtest-dev libfmt-dev
- name: configure
run: mkdir build && cd build && cmake -DENABLE_STATIC_LIBS=True -DBUILD_EXECUTABLE=ON ..
- name: build
run: cmake --build build -j$(nproc)
- name: Print info
run: |
./build/cpu_features/list_cpu_features
./build/apps/volk-config-info --alignment
./build/apps/volk-config-info --avail-machines
./build/apps/volk-config-info --all-machines
./build/apps/volk-config-info --malloc
./build/apps/volk-config-info --cc
- name: test
run: cd build && ctest -V

build-windows:

runs-on: windows-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: dependencies
run: pip install mako
- name: configure
run: mkdir build && cd build && cmake ..
- name: build
run: cmake --build build --config Release --target INSTALL -j2
- name: test
run: cd build && ctest -V -C Release
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: dependencies
run: pip install mako
- name: configure
run: mkdir build && cd build && cmake ..
- name: build
run: cmake --build build --config Release --target INSTALL -j4
- name: test
run: cd build && ctest -V -C Release

# build-windows-msys2:
# name: Build on windows-latest using MinGW and MSYS2
Expand All @@ -226,7 +225,7 @@ jobs:
# python-six
# mingw-w64-x86_64-gcc
# mingw-w64-x86_64-cmake
# - uses: actions/checkout@v2
# - uses: actions/checkout@v4
# - name: Checkout submodules
# run: git submodule update --init --recursive
# - name: Configure
Expand All @@ -242,32 +241,29 @@ jobs:
# ctest -V

build-macos:

strategy:
matrix:
os: [macos-latest, flyci-macos-large-latest-m2]
os: [macos-13, macos-latest]

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

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: dependencies
run: pip3 install --break-system-packages mako && brew install orc
- name: configure
run: mkdir build && cd build && cmake -DBUILD_EXECUTABLE=ON ..
- name: build
run: cmake --build build --config Debug -j3
- name: Print info
run: |
./build/cpu_features/list_cpu_features
# ./build/apps/volk-config-info --alignment
# ./build/apps/volk-config-info --avail-machines
# ./build/apps/volk-config-info --all-machines
# ./build/apps/volk-config-info --malloc
# ./build/apps/volk-config-info --cc
- name: test
run: cd build && ctest -V


- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: dependencies
run: pip3 install --break-system-packages mako && brew install orc
- name: configure
run: mkdir build && cd build && cmake -DBUILD_EXECUTABLE=ON ..
- name: build
run: cmake --build build --config Debug -j4
- name: Print info
run: |
./build/cpu_features/list_cpu_features
# ./build/apps/volk-config-info --alignment
# ./build/apps/volk-config-info --avail-machines
# ./build/apps/volk-config-info --all-machines
# ./build/apps/volk-config-info --malloc
# ./build/apps/volk-config-info --cc
- name: test
run: cd build && ctest -V
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ message(STATUS " Modify using: -DENABLE_PROFILING=ON/OFF")
########################################################################
add_subdirectory(lib)

########################################################################
# Add tests
########################################################################
add_subdirectory(tests)

########################################################################
# And the utility apps
########################################################################
Expand Down
49 changes: 49 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Copyright 2022, 2024 Johannes Demel
#
# This file is part of VOLK.
#
# SPDX-License-Identifier: LGPL-3.0-or-later
#

if(NOT ENABLE_TESTING)
return()
endif(NOT ENABLE_TESTING)

find_package(fmt)
find_package(GTest)

if(NOT fmt_FOUND OR NOT GTest_FOUND)
message(warning "Missing fmtlib and/or googletest for this test suite")
return()
endif(NOT fmt_FOUND OR NOT GTest_FOUND)

file(GLOB volk_test_files "test_*.cc")

add_executable(
volk_tests
volk_test.cc
${volk_test_files}
)

target_compile_features(volk_tests PUBLIC cxx_std_20)

target_link_libraries(volk_tests
PRIVATE
GTest::gtest_main
volk
fmt::fmt
)

include(GoogleTest)
gtest_discover_tests(volk_tests)


target_include_directories(volk_tests
PRIVATE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/lib>
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib>
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)
Loading

0 comments on commit 8a0322d

Please sign in to comment.