Skip to content

Commit 0638380

Browse files
committed
testsuite: enable valgrind tests and test planner and schema
Problem: the migration to cmake broke the ability to run Valngrind tests, and Valgrind doesn't detect leaks in important Fluxion components when running under Flux. Add capability to find Valgrind and run Valgrind tests. Add additional tests for planner and schema.
1 parent 7ca4649 commit 0638380

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ if(DEFINED ENV{WITH_GO})
172172
include(GolangSimple)
173173
endif()
174174

175+
include(FindValgrind) # Search for Valgrind
176+
175177
include_directories(.)
176178
add_subdirectory( etc )
177179
add_subdirectory( src )

cmake/FindValgrind.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Look for Valgrind headers and binary.
2+
#
3+
# Variables defined by this module:
4+
# Valgrind_FOUND System has valgrind
5+
# Valgrind_INCLUDE_DIR where to find valgrind/memcheck.h, etc.
6+
# Valgrind_EXECUTABLE the valgrind executable.
7+
# This module appends to config.h so t5000-valgrind.t succeeds.
8+
# We may need to change this behavior once remaining autotools
9+
# files are removed.
10+
11+
find_path(Valgrind_INCLUDE_DIR valgrind HINTS ${Valgrind_INCLUDE_PATH})
12+
find_program(Valgrind_EXECUTABLE NAMES valgrind PATH ${Valgrind_BINARY_PATH})
13+
14+
include(FindPackageHandleStandardArgs)
15+
find_package_handle_standard_args(Valgrind DEFAULT_MSG Valgrind_INCLUDE_DIR Valgrind_EXECUTABLE)
16+
17+
if(Valgrind_FOUND)
18+
file(APPEND config.h "#define HAVE_VALGRIND 1\n")
19+
endif()

t/t5000-valgrind.t

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test -n "$FLUX_TESTS_LOGFILE" && set -- "$@" --logfile
77
. `dirname $0`/sharness.sh
88

99
# Do not run valgrind test by default unless FLUX_ENABLE_VALGRIND_TEST
10-
# is set in environment (e.g. by CI), or the test run run with -d, --debug
10+
# is set in environment (e.g. by CI), or the test run run with -d, --debug
1111
#
1212
if test -z "$FLUX_ENABLE_VALGRIND_TEST" && test "$debug" = ""; then
1313
skip_all='skipping valgrind tests since FLUX_ENABLE_VALGRIND_TEST not set'
@@ -23,7 +23,7 @@ if ! test_have_prereq NO_ASAN; then
2323
test_done
2424
fi
2525

26-
# Do not run test by default unless valgrind/valgrind.h was found, since
26+
# Do not run test by default unless valgrind/valgrind.h was found, since
2727
# this has been known to introduce false positives (#1097). However, allow
2828
# run to be forced on the cmdline with -d, --debug.
2929
#
@@ -48,7 +48,7 @@ test_expect_success \
4848
run_timeout 900 \
4949
flux start -s ${VALGRIND_NBROKERS} \
5050
--killer-timeout=120 \
51-
--wrap=libtool,e,${VALGRIND} \
51+
--wrap=${VALGRIND} \
5252
--wrap=--tool=memcheck \
5353
--wrap=--leak-check=full \
5454
--wrap=--gen-suppressions=all \
@@ -60,4 +60,42 @@ test_expect_success \
6060
--wrap=--suppressions=$VALGRIND_SUPPRESSIONS \
6161
${VALGRIND_WORKLOAD}
6262
'
63+
64+
# The Valgrind test above doesn't detect memory leaks in planner or schema
65+
test_expect_success \
66+
"valgrind reports no new errors on planner test 01" '
67+
${VALGRIND} \
68+
--tool=memcheck \
69+
--leak-check=full \
70+
--error-exitcode=1 \
71+
${SHARNESS_BUILD_DIRECTORY}/resource/planner/test/planner_test01
72+
'
73+
74+
test_expect_success \
75+
"valgrind reports no new errors on planner test 02" '
76+
${VALGRIND} \
77+
--tool=memcheck \
78+
--leak-check=full \
79+
--error-exitcode=1 \
80+
${SHARNESS_BUILD_DIRECTORY}/resource/planner/test/planner_test02
81+
'
82+
83+
test_expect_success \
84+
"valgrind reports no new errors on schema test 01" '
85+
${VALGRIND} \
86+
--tool=memcheck \
87+
--leak-check=full \
88+
--error-exitcode=1 \
89+
${SHARNESS_BUILD_DIRECTORY}/resource/schema/test/schema_test01
90+
'
91+
92+
test_expect_success \
93+
"valgrind reports no new errors on schema test 02" '
94+
${VALGRIND} \
95+
--tool=memcheck \
96+
--leak-check=full \
97+
--error-exitcode=1 \
98+
${SHARNESS_BUILD_DIRECTORY}/resource/schema/test/schema_test02
99+
'
100+
63101
test_done

0 commit comments

Comments
 (0)