Skip to content

Commit dacfe95

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

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-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}}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![SpellCheck](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/spellcheck.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/spellcheck.yml)
66
[![GitHubPages](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/docs.yml)
77
[![Benchmarks](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/benchmarks.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/benchmarks.yml)
8+
[![Nightly](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/nightly.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/nightly.yml)
89
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/oneapi-src/unified-memory-framework/badge)](https://securityscorecards.dev/viewer/?uri=github.com/oneapi-src/unified-memory-framework)
910

1011
The Unified Memory Framework (UMF) is a library for constructing allocators and memory pools. It also contains broadly useful abstractions and utilities for memory management. UMF allows users to manage multiple memory pools characterized by different attributes, allowing certain allocation types to be isolated from others and allocated using different hardware resources as required.

test/test_valgrind.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
TOOL=$1
9+
10+
function print_usage() {
11+
echo "$(basename $0) - run UMF tests under valgrind tools (memcheck, drd or helgrind)"
12+
echo "This script must be run in the UMF build directory. It looks for './test/umf_test-*' test executables."
13+
echo "Usage: $(basename $0) <memcheck|drd|helgrind>"
14+
}
15+
16+
if ! valgrind --version > /dev/null; then
17+
echo "error: valgrind not found"
18+
exit 1
19+
fi
20+
21+
if [ $(ls -1 ./test/umf_test-* 2>/dev/null | wc -l) -eq 0 ]; then
22+
echo "error: UMF tests ./test/umf_test-* not found (perhaps wrong directory)"
23+
print_usage
24+
exit 1
25+
fi
26+
27+
if [ "$TOOL" == "" ]; then
28+
echo "error: valgrind tool is missing"
29+
print_usage
30+
exit 1
31+
fi
32+
33+
case $TOOL in
34+
memcheck)
35+
OPTION="--leak-check=full"
36+
;;
37+
drd)
38+
OPTION="--tool=drd"
39+
;;
40+
helgrind)
41+
OPTION="--tool=helgrind"
42+
;;
43+
*)
44+
echo "error: unknown tool: $TOOL"
45+
print_usage
46+
exit 1
47+
;;
48+
esac
49+
50+
FAIL=0
51+
52+
echo "Running: \"valgrind $OPTION\" for the following tests:"
53+
54+
for tf in $(ls -1 ./test/umf_test-*); do
55+
[ ! -x $tf ] && continue
56+
echo -n "$tf "
57+
LOG=${tf}.log
58+
valgrind $OPTION $tf >$LOG 2>&1 || echo -n "(valgrind failed) "
59+
if grep -q -e "ERROR SUMMARY: 0 errors from 0 contexts" $LOG; then
60+
echo "- OK"
61+
rm $LOG
62+
else
63+
echo "- FAILED! : $(grep -e "ERROR SUMMARY:" $LOG | cut -d' ' -f2-)"
64+
FAIL=1
65+
fi || true
66+
done
67+
68+
[ $FAIL -eq 0 ] && echo PASSED && exit 0
69+
70+
echo
71+
echo "======================================================================"
72+
echo
73+
74+
for log in $(ls -1 ./test/umf_test-*.log); do
75+
echo ">>>>>>> LOG $log"
76+
cat $log
77+
echo
78+
echo
79+
done
80+
81+
exit 1

0 commit comments

Comments
 (0)