Skip to content

Commit

Permalink
common: separate test to verify if Valgrind enabled in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
  • Loading branch information
grom72 committed Mar 20, 2024
1 parent fb28242 commit e53bbb3
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 += \
Expand Down
1 change: 1 addition & 0 deletions src/test/valgrind_check/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
valgrind_check
10 changes: 10 additions & 0 deletions src/test/valgrind_check/Makefile
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions src/test/valgrind_check/README
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions src/test/valgrind_check/TEST0
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions src/test/valgrind_check/valgrind_check.c
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit e53bbb3

Please sign in to comment.