Skip to content

Commit 0d884ce

Browse files
committed
Add script for running valgrind tests
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent e4b8a75 commit 0d884ce

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

.github/workflows/nightly.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Nightly
2+
3+
# This job is run at 00:00 UTC every day or on demand.
4+
on:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
Valgrind:
11+
name: Valgrind
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
tool: ['memcheck'] # TODO: enable 'drd' and 'helgrind' when all issues are fixed
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Install apt packages
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y cmake libjemalloc-dev libnuma-dev libtbb-dev valgrind
26+
27+
- name: Configure CMake
28+
run: >
29+
cmake
30+
-B ${{github.workspace}}/build
31+
-DCMAKE_BUILD_TYPE=Debug
32+
-DUMF_FORMAT_CODE_STYLE=OFF
33+
-DUMF_DEVELOPER_MODE=ON
34+
-DUMF_ENABLE_POOL_TRACKING=ON
35+
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
36+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
37+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
38+
39+
- name: Build
40+
run: >
41+
cmake --build ${{github.workspace}}/build --config Debug -j$(nproc)
42+
43+
- name: Run tests under valgrind
44+
working-directory: ${{github.workspace}}/build
45+
run: ../test/test_valgrind.sh ${{matrix.tool}}

test/test_valgrind.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
set -e
7+
8+
if ! valgrind --version > /dev/null; then
9+
echo "error: valgrind not found"
10+
exit 1
11+
fi
12+
13+
if [ "$1" == "" ]; then
14+
echo "Usage: $(basename $0) <memcheck|drd|helgrind>"
15+
exit 1
16+
fi
17+
18+
case $1 in
19+
memcheck)
20+
OPTION="--leak-check=full"
21+
;;
22+
drd)
23+
OPTION="--tool=drd"
24+
;;
25+
helgrind)
26+
OPTION="--tool=helgrind"
27+
;;
28+
*)
29+
echo "error: unknown option: $1"
30+
exit 1
31+
;;
32+
esac
33+
34+
FAIL=0
35+
36+
echo "Running: \"valgrind $OPTION\" for the following tests:"
37+
38+
for tf in $(ls -1 ./test/umf_test-*); do
39+
[ ! -x $tf ] && continue
40+
echo -n "$tf "
41+
LOG=${tf}.log
42+
valgrind $OPTION $tf >$LOG 2>&1 || echo -n "(valgrind failed) "
43+
if grep -q -e "ERROR SUMMARY: 0 errors from 0 contexts" $LOG; then
44+
echo "- OK"
45+
rm $LOG
46+
else
47+
echo "- FAILED! : $(grep -e "ERROR SUMMARY:" $LOG | cut -d' ' -f2-)"
48+
FAIL=1
49+
fi || true
50+
done
51+
52+
[ $FAIL -eq 0 ] && echo PASSED && exit 0
53+
54+
echo
55+
echo "======================================================================"
56+
echo
57+
58+
for log in $(ls -1 ./test/umf_test-*.log); do
59+
echo ">>>>>>> LOG $log"
60+
cat $log
61+
echo
62+
echo
63+
done
64+
65+
exit 1

0 commit comments

Comments
 (0)