Skip to content

Commit cdccb1a

Browse files
committed
Add first simple test
1 parent bc45d53 commit cdccb1a

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

.github/workflows/cmake.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ jobs:
3737
if: ${{ matrix.compiler == 'g++-12' && matrix.os == 'ubuntu-24.04' && matrix.build-type == 'RelWithDebInfo' && matrix.hw_breakpoint == 'ON' && github.event_name != 'pull_request'}}
3838
with:
3939
overwrite: true
40-
path: lo2s*.tar.bz2
40+
path: lo2s-*.tar.bz2
41+
- name: Test
42+
if: ${{ matrix.compiler == 'g++-12' && matrix.os == 'ubuntu-24.04' && matrix.build-type == 'RelWithDebInfo' && matrix.hw_breakpoint == 'ON' && github.event_name != 'pull_request'}}
43+
run: |
44+
sudo sysctl kernel.perf_event_paranoid=-1
45+
ctest --output-on-failure

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ include(cmake/UnsetIfUpdated.cmake)
1818
include(cmake/CheckNameExists.cmake)
1919
include(cmake/CheckStructHasBitField.cmake)
2020

21+
enable_testing()
22+
include(cmake/Tests.cmake)
23+
2124
# Intialize git submodules if not done already
2225
include(cmake/GitSubmoduleUpdate.cmake)
2326
git_submodule_update()

cmake/Tests.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(TESTS lo2s_user_sampling)
2+
3+
foreach(TEST ${TESTS})
4+
5+
add_test(NAME ${TEST} COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake/tests/${TEST}.sh)
6+
set_tests_properties(${TEST} PROPERTIES SKIP_RETURN_CODE 100)
7+
endforeach()

cmake/tests/lo2s_user_sampling.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
set -euo pipefail
2+
3+
paranoid=$(cat /proc/sys/kernel/perf_event_paranoid)
4+
5+
echo "perf_event_paranoid is: $paranoid"
6+
if [ $paranoid -gt 2 ]
7+
then
8+
# skip
9+
exit 100
10+
fi
11+
12+
#!/bin/bash
13+
rm -rf test_trace
14+
./lo2s -c 1 --output-trace test_trace -- sleep 1
15+
16+
if otf2-print test_trace/traces.otf2 | grep "SAMPLE"
17+
then
18+
exit 0
19+
else
20+
echo "Trace did not contain calling context samples!"
21+
exit 1
22+
fi
23+
rm -rf test_trace
24+

0 commit comments

Comments
 (0)