Skip to content

Add script for running valgrind tests and Nightly CI job #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Nightly

# This job is run at 00:00 UTC every day or on demand.
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

jobs:
Valgrind:
name: Valgrind
strategy:
fail-fast: false
matrix:
tool: ['memcheck'] # TODO: enable 'drd' and 'helgrind' when all issues are fixed
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install apt packages
run: |
sudo apt-get update
sudo apt-get install -y cmake libjemalloc-dev libnuma-dev libtbb-dev valgrind

- name: Configure CMake
run: >
cmake
-B ${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=Debug
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON

- name: Build
run: >
cmake --build ${{github.workspace}}/build --config Debug -j$(nproc)

- name: Run tests under valgrind
working-directory: ${{github.workspace}}/build
run: ../test/test_valgrind.sh ${{matrix.tool}}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![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)
[![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)
[![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)
[![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)
[![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)

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.
Expand Down
81 changes: 81 additions & 0 deletions test/test_valgrind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set -e

TOOL=$1

function print_usage() {
echo "$(basename $0) - run UMF tests under valgrind tools (memcheck, drd or helgrind)"
echo "This script must be run in the UMF build directory. It looks for './test/umf_test-*' test executables."
echo "Usage: $(basename $0) <memcheck|drd|helgrind>"
}

if ! valgrind --version > /dev/null; then
echo "error: valgrind not found"
exit 1
fi

if [ $(ls -1 ./test/umf_test-* 2>/dev/null | wc -l) -eq 0 ]; then
echo "error: UMF tests ./test/umf_test-* not found (perhaps wrong directory)"
print_usage
exit 1
fi

if [ "$TOOL" == "" ]; then
echo "error: valgrind tool is missing"
print_usage
exit 1
fi

case $TOOL in
memcheck)
OPTION="--leak-check=full"
;;
drd)
OPTION="--tool=drd"
;;
helgrind)
OPTION="--tool=helgrind"
;;
*)
echo "error: unknown tool: $TOOL"
print_usage
exit 1
;;
esac

FAIL=0

echo "Running: \"valgrind $OPTION\" for the following tests:"

for tf in $(ls -1 ./test/umf_test-*); do
[ ! -x $tf ] && continue
echo -n "$tf "
LOG=${tf}.log
valgrind $OPTION $tf >$LOG 2>&1 || echo -n "(valgrind failed) "
if grep -q -e "ERROR SUMMARY: 0 errors from 0 contexts" $LOG; then
echo "- OK"
rm $LOG
else
echo "- FAILED! : $(grep -e "ERROR SUMMARY:" $LOG | cut -d' ' -f2-)"
FAIL=1
fi || true
done

[ $FAIL -eq 0 ] && echo PASSED && exit 0

echo
echo "======================================================================"
echo

for log in $(ls -1 ./test/umf_test-*.log); do
echo ">>>>>>> LOG $log"
cat $log
echo
echo
done

exit 1