diff --git a/Makefile b/Makefile index f37881750..fe995b927 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,9 @@ MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o) TESTUTIL = ./util/testutil.o TESTHARNESS = ./util/testharness.o $(TESTUTIL) - +VALGRIND_ERROR = 2 +VALGRIND_DIR = "VALGRIND_LOGS" +VALGRIND_OPTS = --error-exitcode=$(VALGRIND_ERROR) --leak-check=full TESTS = \ arena_test \ @@ -114,7 +116,18 @@ ldb_tests: all $(PROGRAMS) $(TOOLS) python tools/ldb_test.py valgrind_check: all $(PROGRAMS) $(TESTS) - for t in $(TESTS); do valgrind ./$$t || exit 1; done + echo TESTS THAT HAVE VALGRIND ERRORS > $(VALGRIND_DIR)/valgrind_failed_tests; \ + echo TIMES in seconds TAKEN BY TESTS ON VALGRIND > $(VALGRIND_DIR)/valgrind_tests_times; \ + for t in $(filter-out skiplist_test,$(TESTS)); do \ + stime=`date '+%s'`; \ + valgrind $(VALGRIND_OPTS) \ + --log-file=$(VALGRIND_DIR)/valgrind_log_$$t ./$$t; \ + if [ $$? -eq $(VALGRIND_ERROR) ] ; then \ + echo $$t >> $(VALGRIND_DIR)/valgrind_failed_tests; \ + fi; \ + etime=`date '+%s'`; \ + echo $$t $$((etime - stime)) >> $(VALGRIND_DIR)/valgrind_tests_times; \ + done clean: -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) $(THRIFTSERVER) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk diff --git a/VALGRIND_LOGS/README b/VALGRIND_LOGS/README new file mode 100644 index 000000000..bdaf738b6 --- /dev/null +++ b/VALGRIND_LOGS/README @@ -0,0 +1,4 @@ +This directory stores the tests that failed valgrind and the logs associated +with the failed runs. +"make valgrind_check" can be invoked to call valgrind on the rocksdb tests and +generate files in this directory diff --git a/valgrind_test.sh b/valgrind_test.sh new file mode 100755 index 000000000..09fc41232 --- /dev/null +++ b/valgrind_test.sh @@ -0,0 +1,18 @@ +#!/bin/bash +#A shell script for Jenknis to run valgrind on rocksdb tests +#Returns 0 on success when there are no failed tests + +VALGRIND_DIR=VALGRIND_LOGS +make valgrind_check +NUM_FAILED_TESTS=`wc -l $VALGRIND_DIR/valgrind_failed_tests | awk '{print $1}'` +if [ $NUM_FAILED_TESTS -le '1' ]; then +{ + echo No tests have valgrind errors; + exit 0; +} +else +{ + cat $VALGRIND_DIR/valgrind_failed_tests; + exit 1; +} +fi