Add script for running PyOCF with sanitization
GCC/Clang sanitizer can be used together with PyOCF to catch some errors during testing. CC was purposely removed from the Makefile. It always points to GCC on Linux by default. This allows to change the compiler and its options during the run of the script Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
8dc462e08e
commit
23abad76a8
@ -1,5 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Copyright(c) 2019-2022 Intel Corporation
|
# Copyright(c) 2019-2022 Intel Corporation
|
||||||
|
# Copyright(c) 2025 Huawei Technologies
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -11,9 +12,8 @@ INCDIR=$(ADAPTERDIR)/ocf/include
|
|||||||
WRAPDIR=$(ADAPTERDIR)/c/wrappers
|
WRAPDIR=$(ADAPTERDIR)/c/wrappers
|
||||||
HELPDIR=$(ADAPTERDIR)/c/helpers
|
HELPDIR=$(ADAPTERDIR)/c/helpers
|
||||||
|
|
||||||
CC=gcc
|
CFLAGS=-g -Wall -I$(INCDIR) -I$(SRCDIR)/ocf/env $(OPT_CFLAGS)
|
||||||
CFLAGS=-g -Wall -I$(INCDIR) -I$(SRCDIR)/ocf/env
|
LDFLAGS=-pthread #-lz
|
||||||
LDFLAGS=-pthread -lz
|
|
||||||
|
|
||||||
SRC=$(shell find $(SRCDIR) $(WRAPDIR) $(HELPDIR) -name \*.c)
|
SRC=$(shell find $(SRCDIR) $(WRAPDIR) $(HELPDIR) -name \*.c)
|
||||||
OBJS=$(patsubst %.c, %.o, $(SRC))
|
OBJS=$(patsubst %.c, %.o, $(SRC))
|
||||||
@ -48,6 +48,7 @@ distclean: clean
|
|||||||
@rm -rf $(OCFLIB) $(OBJS)
|
@rm -rf $(OCFLIB) $(OBJS)
|
||||||
@rm -rf $(SRCDIR)/ocf
|
@rm -rf $(SRCDIR)/ocf
|
||||||
@rm -rf $(INCDIR)/ocf
|
@rm -rf $(INCDIR)/ocf
|
||||||
|
@find . -name *.gc* -delete
|
||||||
@echo " DISTCLEAN "
|
@echo " DISTCLEAN "
|
||||||
|
|
||||||
.PHONY: all clean sync config_random distclean
|
.PHONY: all clean sync config_random distclean
|
||||||
|
37
tests/functional/run_with_sanitizers.sh
Executable file
37
tests/functional/run_with_sanitizers.sh
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
#
|
||||||
|
# Copyright(c) 2019-2022 Intel Corporation
|
||||||
|
# Copyright(c) 2025 Huawei Technologies
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
LIB_DIR="/lib/x86_64-linux-gnu/"
|
||||||
|
|
||||||
|
ASAN_LIB="$LIB_DIR/libasan.so.6"
|
||||||
|
TSAN_LIB="$LIB_DIR/libtsan.so.0"
|
||||||
|
UBSAN_LIB="$LIB_DIR/libubsan.so.1"
|
||||||
|
|
||||||
|
# Path to test file/directory
|
||||||
|
PYOCF_TESTS_PATH="tests/"
|
||||||
|
|
||||||
|
echo "Cleaning and building with Address Sanitizer"
|
||||||
|
make distclean
|
||||||
|
OPT_CFLAGS="-fsanitize=address" make -j >/dev/null
|
||||||
|
echo "Running tests, please wait..."
|
||||||
|
LD_PRELOAD=$ASAN_LIB ASAN_OPTIONS=log_output=asan_log.txt PYTHONMALLOC=malloc pytest $PYOCF_TESTS_PATH 2>&1 | tee asan_output.txt
|
||||||
|
echo "Done, check asan_log.txt"
|
||||||
|
|
||||||
|
echo "Cleaning and building with Thread Sanitizer"
|
||||||
|
make distclean
|
||||||
|
OPT_CFLAGS="-fsanitize=thread -fno-omit-frame-pointer" make -j >/dev/null
|
||||||
|
echo "Running tests, please wait..."
|
||||||
|
LD_PRELOAD=$TSAN_LIB TSAN_OPTIONS=log_output=tsan_log.txt pytest -s $PYOCF_TESTS_PATH 2>&1 | tee tsan_output.txt
|
||||||
|
echo "Done, check tsan_log.txt"
|
||||||
|
|
||||||
|
echo "Cleaning and building with Undefined Behaviour Sanitizer"
|
||||||
|
make distclean
|
||||||
|
OPT_CFLAGS="-fsanitize=undefined -fno-sanitize=alignment" make -j >/dev/null
|
||||||
|
echo "Running tests, please wait..."
|
||||||
|
LD_PRELOAD=$UBSAN_LIB UBSAN_OPTIONS=log_output=ubsan_log.txt pytest -s $PYOCF_TESTS_PATH 2>&1 | tee ubsan_output.txt
|
||||||
|
echo "Done, check ubsan_output.txt"
|
Loading…
Reference in New Issue
Block a user