From 17f079a156bddf9ad7736293b942166cf4075bc0 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Fri, 25 Jul 2014 13:25:43 -0500 Subject: [PATCH] Add valgrind tests --- .gitignore | 1 + .travis.yml | 1 + Makefile.in | 15 +++++++++++++-- TODO.md | 2 +- configure.ac | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f41c0967..0c4c34f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.swp /.fig /.tests-pass +/.tests-pass-valgrind /Makefile /autom4te.cache /bin diff --git a/.travis.yml b/.travis.yml index ae9b2ee0..9df4ab81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ install: - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.4" CC="clang-3.4"; fi - wget "https://googlemock.googlecode.com/files/gmock-1.7.0.zip" - unzip gmock-1.7.0.zip + - sudo apt-get install valgrind script: - autoconf - ./configure --with-gmock=gmock-1.7.0 diff --git a/Makefile.in b/Makefile.in index f69b9b2b..6261306c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,6 +4,7 @@ AR=ar ARFLAGS=cru CXX=@CXX@ CXXFLAGS=@CXXFLAGS@ +VALGRIND=@VALGRIND@ LDFLAGS=@LDFLAGS@ # hack for drw gcc on ubuntu GCC_MULTIARCH := $(shell gcc -print-multiarch 2>/dev/null) @@ -21,7 +22,7 @@ VERSION_STRING:=SeaSocks/$(or $(VERSION),unversioned) ($(shell git describe --al CXXFLAGS += -fPIC -Wall -Werror '-DSEASOCKS_VERSION_STRING="$(VERSION_STRING)"' -I$(C_SRC) -.PHONY: all clean run test spotless header-checks +.PHONY: all clean run test spotless header-checks valgrind-test OBJ_DIR=obj BIN_DIR=bin @@ -33,7 +34,7 @@ APPS_CPP_SRCS=$(shell find $(APPS_SRC) -name '*.cpp') TARGETS=$(patsubst $(APPS_SRC)/%.cpp,$(BIN_DIR)/%,$(APPS_CPP_SRCS)) apps: $(TARGETS) -all: apps $(BIN_DIR)/libseasocks.so $(BIN_DIR)/libseasocks.a test header-checks +all: apps $(BIN_DIR)/libseasocks.so $(BIN_DIR)/libseasocks.a test header-checks valgrind-test debug: echo $($(DEBUG_VAR)) @@ -119,11 +120,21 @@ $(BIN_DIR)/tests: $(TEST_OBJS) $(BIN_DIR)/libseasocks.a \ test: .tests-pass +ifneq ("@VALGRIND@", "") +valgrind-test: .tests-pass + $(VALGRIND) --leak-check=full --error-exitcode=2 -- $(BIN_DIR)/tests +else +valgrind-test: + @echo "Not running valgrind-test as no valgrind binary found during configure" +endif + else test: @echo "Not running tests as no gmock/gtest specified during configure" @echo "To configure, specify with --with-gmock=PATH_TO_GMOCK" +test-valgrind: test + endif clean: diff --git a/TODO.md b/TODO.md index 8bed4032..b56a7a62 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ General list of things todo * git grep 'TODO' and fix * include what you use: lots of headers rely on ambient includes -* add more tests and have a run-under-valgrind target at least +* add more tests * move more things over to the Request/Response way of doing things * Double check it's ok to remove hixie, and do so. Currently no way of testing it anyway (with reference to http://en.wikipedia.org/wiki/WebSocket#Browser_support it's been dead diff --git a/configure.ac b/configure.ac index 6389e683..7c6e51b8 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,7 @@ AC_DEFUN([AX_CXX_CHECK_UNORDERED_MAP_EMPLACE], [ AC_SUBST(HAVE_UNORDERED_MAP_EMPLACE) ]) AX_CXX_CHECK_UNORDERED_MAP_EMPLACE +AC_PATH_PROG(VALGRIND, valgrind) dnl Basic headers and features AC_HEADER_STDBOOL