diff --git a/src/test/Makefile b/src/test/Makefile index 961172eac35..c87dc875c2d 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -150,7 +150,8 @@ OTHER_TESTS = \ util_uuid_generate\ util_vec\ util_vecq\ - log_errno + log_errno\ + valgrind_check ifeq ($(ARCH), x86_64) OTHER_TESTS += \ diff --git a/src/test/valgrind_check/.gitignore b/src/test/valgrind_check/.gitignore new file mode 100644 index 00000000000..15bae9bd64e --- /dev/null +++ b/src/test/valgrind_check/.gitignore @@ -0,0 +1 @@ +valgrind_check diff --git a/src/test/valgrind_check/Makefile b/src/test/valgrind_check/Makefile new file mode 100644 index 00000000000..b6d2a7129e8 --- /dev/null +++ b/src/test/valgrind_check/Makefile @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2024, Intel Corporation + +# +# src/test/valgrind_check/Makefile -- build valgrind_check unit test +# +TARGET = valgrind_check +OBJS = valgrind_check.o + +include ../Makefile.inc diff --git a/src/test/valgrind_check/README b/src/test/valgrind_check/README new file mode 100644 index 00000000000..ba3ee397cd5 --- /dev/null +++ b/src/test/valgrind_check/README @@ -0,0 +1,7 @@ +Persistent Memory Development Kit + +This is src/test/valgrind_check/README. + +This directory contains a unit test for Valgrind enabling. + +The program in valgrind_check.c verifies if Valgrind was enabled during build. diff --git a/src/test/valgrind_check/TEST0 b/src/test/valgrind_check/TEST0 new file mode 100755 index 00000000000..d7ffd137f8c --- /dev/null +++ b/src/test/valgrind_check/TEST0 @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2024, Intel Corporation + +# +# src/test/valgrind_check/TEST0 -- unit test for valgrind_check +# + +. ../unittest/unittest.sh + +require_test_type short +require_valgrind + +setup + +expect_normal_exit ./valgrind_check$EXESUFFIX + +pass diff --git a/src/test/valgrind_check/valgrind_check.c b/src/test/valgrind_check/valgrind_check.c new file mode 100644 index 00000000000..b719be9a0b1 --- /dev/null +++ b/src/test/valgrind_check/valgrind_check.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* Copyright 2024, Intel Corporation */ + +/* + * valgrind_check.c -- unit test Valgrind enabled during build + * + * usage: valgrind_check + * + */ + +#include "valgrind_internal.h" + +#ifndef VALGRIND_ENABLED +#error Valgrind tools not properly configured +#endif + +int +main(int argc, char *argv[]) +{ +#if VALGRIND_ENABLED + return 0; +#else + return 1; +#endif +}