Skip to content

Commit

Permalink
tests: Add "make check-valgrind" to run the unit tests under Valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift committed Jan 8, 2020
1 parent fcef6db commit 2a57a15
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile.am
Expand Up @@ -323,6 +323,9 @@ docs:
@echo "error: doxygen not found"
endif

check-valgrind:
$(MAKE) -C src/ check-valgrind

clean-docs:
rm -rf doc/doxygen

Expand Down
25 changes: 25 additions & 0 deletions src/Makefile.test.include
Expand Up @@ -613,6 +613,31 @@ if EMBEDDED_UNIVALUE
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
endif

if ENABLE_BENCH
if ENABLE_QT_TESTS
check-valgrind: $(TEST_BINARY) $(BENCH_BINARY) test_bitcoin_qt
else
check-valgrind: $(TEST_BINARY) $(BENCH_BINARY)
endif
else
if ENABLE_QT_TESTS
check-valgrind: $(TEST_BINARY) test_bitcoin_qt
else
check-valgrind: $(TEST_BINARY)
endif
endif
@echo "Using the valgrind memory error detector: expect a 10-50x slowdown and ~2x memory usage. valgrind 3.14 or later required."
@echo "Running $(TEST_BINARY) under valgrind -- this will take a a while..."
valgrind --suppressions=$(top_builddir)/contrib/valgrind.supp --gen-suppressions=all --exit-on-first-error=yes --error-exitcode=1 --quiet $(TEST_BINARY)
if ENABLE_BENCH
@echo "Running $(BENCH_BINARY) -evals=1 -scaling=0 under valgrind -- this will take a while..."
valgrind --suppressions=$(top_builddir)/contrib/valgrind.supp --gen-suppressions=all --exit-on-first-error=yes --error-exitcode=1 --quiet $(BENCH_BINARY) -evals=1 -scaling=0 > /dev/null
endif
if ENABLE_QT_TESTS
@echo "Running qt/test/test_bitcoin-qt under valgrind -- this will take a while..."
valgrind --suppressions=$(top_builddir)/contrib/valgrind.supp --gen-suppressions=all --exit-on-first-error=yes --error-exitcode=1 --quiet qt/test/test_bitcoin-qt > /dev/null
endif

%.cpp.test: %.cpp
@echo Running tests: `cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1` from $<
$(AM_V_at)$(TEST_BINARY) -l test_suite -t "`cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1`" > $<.log 2>&1 || (cat $<.log && false)
Expand Down

0 comments on commit 2a57a15

Please sign in to comment.