From 76e983aa46eb176addd81b98bc904c8c51cc49ef Mon Sep 17 00:00:00 2001 From: Christian von Elm Date: Thu, 23 Jan 2025 10:34:36 +0100 Subject: [PATCH] Add first simple test --- .github/workflows/cmake.yml | 4 +++- CMakeLists.txt | 3 +++ cmake/Tests.cmake | 7 +++++++ cmake/tests/lo2s_user_sampling.sh | 24 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 cmake/Tests.cmake create mode 100644 cmake/tests/lo2s_user_sampling.sh diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9edbe412..cc1c399f 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -33,8 +33,10 @@ jobs: - name: Create source tarball if: ${{ matrix.compiler == 'g++-12' && matrix.os == 'ubuntu-24.04' && matrix.build-type == 'RelWithDebInfo' && matrix.hw_breakpoint == 'ON' && github.event_name != 'pull_request'}} run: make dist + - name: Test + if: ${{ matrix.compiler == 'g++-12' && matrix.os == 'ubuntu-24.04' && matrix.build-type == 'RelWithDebInfo' && matrix.hw_breakpoint == 'ON' && github.event_name != 'pull_request'}} + run: ctest --output-on-failure - uses: actions/upload-artifact@v4 if: ${{ matrix.compiler == 'g++-12' && matrix.os == 'ubuntu-24.04' && matrix.build-type == 'RelWithDebInfo' && matrix.hw_breakpoint == 'ON' && github.event_name != 'pull_request'}} with: overwrite: true - path: lo2s*.tar.bz2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 14775e88..66da7a12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ include(cmake/UnsetIfUpdated.cmake) include(cmake/CheckNameExists.cmake) include(cmake/CheckStructHasBitField.cmake) +enable_testing() +include(cmake/Tests.cmake) + # Intialize git submodules if not done already include(cmake/GitSubmoduleUpdate.cmake) git_submodule_update() diff --git a/cmake/Tests.cmake b/cmake/Tests.cmake new file mode 100644 index 00000000..ed0c6c75 --- /dev/null +++ b/cmake/Tests.cmake @@ -0,0 +1,7 @@ +set(TESTS lo2s_user_sampling) + +foreach(TEST ${TESTS}) + + add_test(NAME ${TEST} COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake/tests/${TEST}.sh) + set_tests_properties(${TEST} PROPERTIES SKIP_RETURN_CODE 100) +endforeach() diff --git a/cmake/tests/lo2s_user_sampling.sh b/cmake/tests/lo2s_user_sampling.sh new file mode 100644 index 00000000..6d4f1769 --- /dev/null +++ b/cmake/tests/lo2s_user_sampling.sh @@ -0,0 +1,24 @@ +set -euo pipefail + +paranoid=$(cat /proc/sys/kernel/perf_event_paranoid) + +echo "perf_event_paranoid is: $paranoid" +if [ $paranoid -gt 2 ] +then + # skip + exit 100 +fi + +#!/bin/bash +rm -rf test_trace +./lo2s -c 1 --output-trace test_trace -- sleep 1 + +if otf2-print test_trace/traces.otf2 | grep "SAMPLE" +then + exit 0 +else + echo "Trace did not contain calling context samples!" + exit 1 +fi +rm -rf test_trace +