From 3894603fef517981359fb7aa737a0b3c7a003c5e Mon Sep 17 00:00:00 2001 From: sdong Date: Wed, 13 Apr 2016 19:27:52 -0700 Subject: [PATCH] Allow valgrind_check to run in parallel Summary: Extend "J=" to valgrind_check. For DBTest, modify the script to run valgrind. For other tests, prefix launch command with valgrind. Test Plan: Run valgrind_check with J=1 and J>1 and make sure tests run under valgrind. Manually change codes to introduce memory leak and make sure "make watch-log" correctly report it. Reviewers: yhchiang, yiwu, andrewkr, kradhakrishnan, IslamAbdelRahman Reviewed By: kradhakrishnan, IslamAbdelRahman Subscribers: leveldb, andrewkr, dhruba Differential Revision: https://reviews.facebook.net/D56727 --- Makefile | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 35d7aa367..a80ae65ca 100644 --- a/Makefile +++ b/Makefile @@ -522,7 +522,7 @@ $(t_run): Makefile db_test '#!/bin/sh' \ 'd=$(TMPD)/$(@F)' \ 'mkdir -p $$d' \ - 'TEST_TMPDIR=$$d ./db_test $(filter)' \ + 'TEST_TMPDIR=$$d $(DRIVER) ./db_test $(filter)' \ > $@-t $(AM_V_at)chmod a=rx $@-t $(AM_V_at)mv $@-t $@ @@ -574,6 +574,23 @@ check_0: $(t_run) | $(prioritize_long_running_tests) \ | grep -E '$(tests-regexp)' \ | parallel -j$(J) --joblog=LOG $$eta --gnu '{} >& t/log-{/}' + +.PHONY: valgrind_check_0 +valgrind_check_0: $(t_run) + $(AM_V_GEN)export TEST_TMPDIR=$(TMPD); \ + printf '%s\n' '' \ + 'To monitor subtest ,' \ + ' run "make watch-log" in a separate window' ''; \ + test -t 1 && eta=--eta || eta=; \ + { \ + printf './%s\n' $(filter-out db_test %skiplist_test options_settable_test, $(TESTS)); \ + printf '%s\n' $(t_run); \ + } \ + | $(prioritize_long_running_tests) \ + | grep -E '$(tests-regexp)' \ + | parallel -j$(J) --joblog=LOG $$eta --gnu \ + 'if [[ "{}" == "./"* ]] ; then $(DRIVER) {} >& t/valgrind_log-{/}; ' \ + 'else {} >& t/valgrind_log-{/}; fi' endif CLEAN_FILES += t LOG $(TMPD) @@ -645,13 +662,22 @@ ubsan_crash_test: $(MAKE) clean valgrind_check: $(TESTS) - for t in $(filter-out %skiplist_test options_settable_test,$(TESTS)); do \ - $(VALGRIND_VER) $(VALGRIND_OPTS) ./$$t; \ - ret_code=$$?; \ - if [ $$ret_code -ne 0 ]; then \ - exit $$ret_code; \ - fi; \ - done + $(AM_V_GEN)if test "$(J)" != 1 \ + && (parallel --gnu --help 2>/dev/null) | \ + grep -q 'GNU Parallel'; \ + then \ + t=$$($(test_names)); \ + $(MAKE) T="$$t" TMPD=$(TMPD) \ + DRIVER="$(VALGRIND_VER) $(VALGRIND_OPTS)" valgrind_check_0; \ + else \ + for t in $(filter-out %skiplist_test options_settable_test,$(TESTS)); do \ + $(VALGRIND_VER) $(VALGRIND_OPTS) ./$$t; \ + ret_code=$$?; \ + if [ $$ret_code -ne 0 ]; then \ + exit $$ret_code; \ + fi; \ + done; \ + fi ifneq ($(PAR_TEST),)