Skip to content

Commit

Permalink
Add first simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
cvonelm committed Jan 23, 2025
1 parent bc45d53 commit 64eaeeb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ jobs:
with:
overwrite: true
path: lo2s*.tar.bz2
- 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: |
sudo sysctl kernel.perf_event_paranoid=-1
ctest --output-on-failure
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions cmake/Tests.cmake
Original file line number Diff line number Diff line change
@@ -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()
24 changes: 24 additions & 0 deletions cmake/tests/lo2s_user_sampling.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 64eaeeb

Please sign in to comment.