From e087947c84ee6b7d86abe9585ee51efee7595a26 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Sat, 16 May 2015 13:46:48 -0700 Subject: Enabled asserts() and verbosity for most Travis builds. Also added a separate ndebug build for testing that -DNDEBUG builds still work. Also disabled reference debugging by default, since it requires either a global lock or -DUPB_THREAD_UNSAFE. --- .travis.yml | 1 + Makefile | 4 ++-- travis.sh | 22 ++++++++++++++++++++-- upb/pb/decoder.c | 2 +- upb/refcounted.h | 6 +++--- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 105bf1c..ae5c620 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,6 @@ env: - UPB_TRAVIS_BUILD=core32 - UPB_TRAVIS_BUILD=withprotobuf - UPB_TRAVIS_BUILD=lua + - UPB_TRAVIS_BUILD=ndebug - UPB_TRAVIS_BUILD=coverage - UPB_TRAVIS_BUILD=genfiles diff --git a/Makefile b/Makefile index d3ccfc0..b3f3d55 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ all: lib tests tools/upbc lua python testall: test pythontest # Set this to have user-specific flags (especially things like -O0 and -g). -USER_CPPFLAGS= +USER_CPPFLAGS?= # Build with "make WITH_JIT=yes" (or anything besides "no") to enable the JIT. WITH_JIT=no @@ -72,7 +72,7 @@ ifneq ($(UPB_FAIL_WARNINGS), no) endif # Build with "make Q=" to see all commands that are being executed. -Q=@ +Q?=@ # Function to expand a wildcard pattern recursively. rwildcard=$(strip $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d))) diff --git a/travis.sh b/travis.sh index a09ed2e..c1028f7 100755 --- a/travis.sh +++ b/travis.sh @@ -74,6 +74,18 @@ genfiles_script() { git diff --exit-code } +# Tests the ndebug build. +ndebug_install() { + sudo apt-get update -qq + sudo apt-get install lua5.2 liblua5.2-dev protobuf-compiler libprotobuf-dev +} +ndebug_script() { + # Override of USER_CPPFLAGS removes -UNDEBUG. + export USER_CPPFLAGS="`pkg-config lua5.2 --cflags` -g -fomit-frame-pointer" + make -j12 tests googlepbtests testlua WITH_JIT=yes + make test +} + # A run that executes with coverage support and uploads to coveralls.io coverage_install() { sudo apt-get update -qq @@ -81,8 +93,8 @@ coverage_install() { sudo pip install cpp-coveralls } coverage_script() { - make -j12 tests googlepbtests testlua WITH_JIT=yes \ - USER_CPPFLAGS="--coverage -O0 `pkg-config lua5.2 --cflags`" + export USER_CPPFLAGS="--coverage -O0 `pkg-config lua5.2 --cflags`" + make -j12 tests googlepbtests testlua WITH_JIT=yes make test } coverage_after_success() { @@ -99,6 +111,12 @@ if [ "$CC" != "gcc" ] && [ "$UPB_TRAVIS_BUILD" == "coverage" ]; then exit fi +# Enable asserts and ref debugging (though some configurations override this). +export USER_CPPFLAGS="-UNDEBUG -DUPB_DEBUG_REFS -DUPB_THREAD_UNSAFE -g" + +# Enable verbose build. +export Q= + set -e set -x diff --git a/upb/pb/decoder.c b/upb/pb/decoder.c index c37953a..0c3955a 100644 --- a/upb/pb/decoder.c +++ b/upb/pb/decoder.c @@ -874,7 +874,7 @@ bool upb_pbdecoder_end(void *closure, const void *handler_data) { assert(getop(*d->pc) == OP_TAG1 || getop(*d->pc) == OP_TAG2 || getop(*d->pc) == OP_TAGN || - getop(*d->pc == OP_DISPATCH)); + getop(*d->pc) == OP_DISPATCH); d->pc = p; } upb_pbdecoder_decode(closure, handler_data, &dummy, 0, NULL); diff --git a/upb/refcounted.h b/upb/refcounted.h index 3de4a12..fe77077 100644 --- a/upb/refcounted.h +++ b/upb/refcounted.h @@ -28,9 +28,9 @@ // // Enabling this requires the application to define upb_lock()/upb_unlock() // functions that acquire/release a global mutex (or #define UPB_THREAD_UNSAFE). -#ifndef NDEBUG -#define UPB_DEBUG_REFS -#endif +// For this reason we don't enable it by default, even in debug builds. + +// #define UPB_DEBUG_REFS #ifdef __cplusplus namespace upb { class RefCounted; } -- cgit v1.2.3