forked from LuaJIT/LuaJIT
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds CI testing with Valgrind in three scenarios: - Full checks enabled. - No leak checks, with memory fill set to `--malloc-fill=0x00` and `--free-fill=0x00`. - No leak checks, with memory fill set to `--malloc-fill=0xFF` and `--free-fill=0xFF`.
- Loading branch information
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Setup environment on Linux | ||
|
||
Action setups the environment on Linux runners (install requirements, setup the | ||
workflow environment, etc) for testing with Valgrind. | ||
|
||
## How to use Github Action from Github workflow | ||
|
||
Add the following code to the running steps before LuaJIT configuration: | ||
``` | ||
- uses: ./.github/actions/setup-linux | ||
if: ${{ matrix.OS == 'Linux' }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Setup CI environment on Linux | ||
description: Common part to tweak Linux CI runner environment | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup CI environment | ||
uses: ./.github/actions/setup | ||
- name: Set CMAKE_BUILD_PARALLEL_LEVEL | ||
run: | | ||
# Set CMAKE_BUILD_PARALLEL_LEVEL environment variable to | ||
# limit the number of parallel jobs for build/test step. | ||
NPROC=$(nproc) | ||
echo CMAKE_BUILD_PARALLEL_LEVEL=$(($NPROC + 1)) | tee -a $GITHUB_ENV | ||
shell: bash | ||
- name: Install build and test dependencies | ||
run: | | ||
apt -y update | ||
apt -y install cmake gcc make ninja-build perl valgrind | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Valgrind testing | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- '**-notest' | ||
- 'upstream-**' | ||
tags-ignore: | ||
- '**' | ||
|
||
concurrency: | ||
# An update of a developer branch cancels the previously | ||
# scheduled workflow run for this branch. However, the default | ||
# branch, and long-term branch (tarantool/release/2.11, | ||
# tarantool/release/2.10, etc) workflow runs are never canceled. | ||
# | ||
# We use a trick here: define the concurrency group as 'workflow | ||
# run ID' + # 'workflow run attempt' because it is a unique | ||
# combination for any run. So it effectively discards grouping. | ||
# | ||
# XXX: we cannot use `github.sha` as a unique identifier because | ||
# pushing a tag may cancel a run that works on a branch push | ||
# event. | ||
group: ${{ startsWith(github.ref, 'refs/heads/tarantool/') | ||
&& format('{0}-{1}', github.run_id, github.run_attempt) | ||
|| format('{0}-{1}', github.workflow, github.ref) }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test-valgrind: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# XXX: Let's start with only Linux/x86_64 | ||
BUILDTYPE: [Debug, Release] | ||
VALGRIND_OPTIONS: | ||
- --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose | ||
- --leak-check=no --malloc-fill=0x00 --free-fill=0x00 | ||
- --leak-check=no --malloc-fill=0xFF --free-fill=0xFF | ||
include: | ||
- BUILDTYPE: Debug | ||
CMAKEFLAGS: -DCMAKE_BUILD_TYPE=Debug -DLUA_USE_ASSERT=ON -DLUA_USE_APICHECK=ON | ||
- BUILDTYPE: Release | ||
CMAKEFLAGS: -DCMAKE_BUILD_TYPE=RelWithDebInfo | ||
|
||
runs-on: [self-hosted, regular, Linux, x86_64] | ||
name: > | ||
LuaJIT with Valgrind (Linux/x86_64) | ||
${{ matrix.BUILDTYPE }} | ||
CC: gcc | ||
GC64:ON SYSMALLOC:ON | ||
leak-check: ${{ matrix.VALGRIND_OPTIONS | regex_replace('--leak-check=([a-zA-Z0-9]+).*', '$1') }} | ||
malloc/free-fill: ${{ matrix.VALGRIND_OPTIONS | regex_replace('.*--malloc-fill=0x([0-9A-Fa-f]+).*', '$1', 'none') }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- name: setup Linux for Valgrind | ||
uses: ./.github/actions/setup-valgrind | ||
- name: configure | ||
# XXX: LuaJIT configuration requires a couple of tweaks: | ||
# LUAJIT_USE_SYSMALLOC=ON: Unfortunately, internal LuaJIT | ||
# memory allocator is not instrumented yet, so to find | ||
# any memory errors it's better to build LuaJIT with | ||
# system provided memory allocator (i.e. run CMake | ||
# configuration phase with -DLUAJIT_USE_SYSMALLOC=ON). | ||
# For more info, see root CMakeLists.txt. | ||
# LUAJIT_ENABLE_GC64=ON: LUAJIT_USE_SYSMALLOC cannot be | ||
# enabled on x64 without GC64, since realloc usually | ||
# doesn't return addresses in the right address range. | ||
# For more info, see root CMakeLists.txt. | ||
run: > | ||
CC=gcc | ||
cmake -S . -B ${{ env.BUILDDIR }} | ||
-G Ninja | ||
${{ matrix.CMAKEFLAGS }} | ||
-DLUAJIT_USE_VALGRIND=ON | ||
-DLUAJIT_ENABLE_GC64=ON | ||
-DLUAJIT_USE_SYSMALLOC=ON | ||
- name: build | ||
run: cmake --build . --parallel | ||
working-directory: ${{ env.BUILDDIR }} | ||
- name: test | ||
env: | ||
VALGRIND_OPTIONS: ${{ matrix.VALGRIND_OPTIONS }} | ||
run: cmake --build . --parallel --target LuaJIT-test | ||
working-directory: ${{ env.BUILDDIR }} |