Make valgrind optional

Some platforms don't have valgrind support, and sometimes you simply might
not want to use valgrind.  But at present, dtc, or more specifically its
testsuite, won't compile without valgrind because we use the valgrind
client interface in some places to improve our testing and suppress false
positives.

This adds some Makefile detection to correctly handle the case where
valgrind is not available.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2018-09-10 16:46:59 +10:00
parent fd06c54d47
commit b94c056b13
4 changed files with 25 additions and 6 deletions

View File

@ -25,11 +25,8 @@ matrix:
- make - make
- make check && make checkm - make check && make checkm
# Check it builds properly without the python bits # Check it builds properly without optional packages:
- addons: # python, valgrind
apt: - script:
packages:
- valgrind
script:
- make - make
- make check - make check

View File

@ -39,6 +39,13 @@ INCLUDEDIR = $(PREFIX)/include
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
sed -e 's/\(cygwin\|msys\).*/\1/') sed -e 's/\(cygwin\|msys\).*/\1/')
NO_VALGRIND := $(shell $(PKG_CONFIG) --exists valgrind; echo $$?)
ifeq ($(NO_VALGRIND),1)
CFLAGS += -DNO_VALGRIND
else
CFLAGS += $(shell $(PKG_CONFIG) --cflags valgrind)
endif
ifeq ($(HOSTOS),darwin) ifeq ($(HOSTOS),darwin)
SHAREDLIB_EXT = dylib SHAREDLIB_EXT = dylib
SHAREDLIB_CFLAGS = -fPIC SHAREDLIB_CFLAGS = -fPIC

View File

@ -83,8 +83,13 @@ tests_clean:
check: tests ${TESTS_BIN} $(TESTS_PYLIBFDT) check: tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
cd $(TESTS_PREFIX); ./run_tests.sh cd $(TESTS_PREFIX); ./run_tests.sh
ifeq ($(NO_VALGRIND),1)
checkm:
@echo "make checkm requires valgrind, but NO_VALGRIND=1"
else
checkm: tests ${TESTS_BIN} $(TESTS_PYLIBFDT) checkm: tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
cd $(TESTS_PREFIX); ./run_tests.sh -m 2>&1 | tee vglog.$$$$ cd $(TESTS_PREFIX); ./run_tests.sh -m 2>&1 | tee vglog.$$$$
endif
checkv: tests ${TESTS_BIN} $(TESTS_PYLIBFDT) checkv: tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
cd $(TESTS_PREFIX); ./run_tests.sh -v cd $(TESTS_PREFIX); ./run_tests.sh -v

View File

@ -30,7 +30,17 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#if NO_VALGRIND
static inline void VALGRIND_MAKE_MEM_UNDEFINED(void *p, size_t len)
{
}
static inline void VALGRIND_MAKE_MEM_DEFINED(void *p, size_t len)
{
}
#else
#include <valgrind/memcheck.h> #include <valgrind/memcheck.h>
#endif
#include <libfdt.h> #include <libfdt.h>