From 9999faf9daceb3fef5df8e3a3a046c46804ade2d Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 12 Feb 2019 13:24:54 +0000 Subject: [PATCH] Add rewritten build test script and remove some build warnings. --- ChangeLog.txt | 1 + buildtest.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ client/Makefile | 4 ++-- config.mk | 4 ++++ src/bridge.c | 1 - src/conf.c | 2 +- src/loop.c | 2 +- 7 files changed, 68 insertions(+), 5 deletions(-) create mode 100755 buildtest.py diff --git a/ChangeLog.txt b/ChangeLog.txt index dcd4a965..3409196b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -15,6 +15,7 @@ Library: Build: - Don't require C99 compiler. +- Add rewritten build test script and remove some build warnings. 1.5.6 - 20190206 diff --git a/buildtest.py b/buildtest.py new file mode 100755 index 00000000..b0772cbc --- /dev/null +++ b/buildtest.py @@ -0,0 +1,59 @@ +#!/usr/bin/python3 + +build_variants = [ + 'WITH_ADNS', + 'WITH_BRIDGE', + 'WITH_DOCS', + 'WITH_EC', + 'WITH_EPOLL', + 'WITH_MEMORY_TRACKING', + 'WITH_PERSISTENCE', + 'WITH_SHARED_LIBRARIES', + 'WITH_SOCKS', + 'WITH_SRV', + 'WITH_STATIC_LIBRARIES', + 'WITH_STRIP', + 'WITH_SYSTEMD', + 'WITH_SYS_TREE', + 'WITH_THREADING', + 'WITH_TLS', + 'WITH_TLS_PSK', + 'WITH_WEBSOCKETS', + 'WITH_WRAP', +] + +special_variants = [ + 'WITH_BUNDLED_DEPS', + 'WITH_COVERAGE', +] + + +import random +import subprocess + +def run_test(msg, opts): + subprocess.run(["make", "clean"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + print("%s: %s" % (msg, str(opts))) + args = ["make", "-j"] + opts + proc = subprocess.run(args, stdout=subprocess.DEVNULL) + if proc.returncode != 0: + raise RuntimeError("BUILD FAILED: %s" % (' '.join(args))) + +def simple_tests(): + for bv in build_variants: + for enabled in ["yes", "no"]: + opts = "%s=%s" % (bv, enabled) + run_test("SIMPLE BUILD", [opts]) + +def random_tests(count=10): + for i in range(1, count): + opts = [] + for bv in build_variants: + opts.append("%s=%s" % (bv, random.choice(["yes", "no"]))) + + run_test("RANDOM BUILD", opts) + + +if __name__ == "__main__": + simple_tests() + random_tests(100) diff --git a/client/Makefile b/client/Makefile index 824d703c..684be26d 100644 --- a/client/Makefile +++ b/client/Makefile @@ -21,10 +21,10 @@ static : static_pub static_sub # libmosquitto only. static_pub : pub_client.o client_shared.o ../lib/libmosquitto.a - ${CROSS_COMPILE}${CC} $^ -o mosquitto_pub ${CLIENT_LDFLAGS} -lssl -lcrypto -lpthread + ${CROSS_COMPILE}${CC} $^ -o mosquitto_pub ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS} static_sub : sub_client.o sub_client_output.o client_shared.o ../lib/libmosquitto.a - ${CROSS_COMPILE}${CC} $^ -o mosquitto_sub ${CLIENT_LDFLAGS} -lssl -lcrypto -lpthread + ${CROSS_COMPILE}${CC} $^ -o mosquitto_sub ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS} mosquitto_pub : pub_client.o client_shared.o ${CROSS_COMPILE}${CC} $^ -o $@ ${CLIENT_LDFLAGS} diff --git a/config.mk b/config.mk index 98210587..6881613a 100644 --- a/config.mk +++ b/config.mk @@ -129,6 +129,7 @@ else CFLAGS?=-Wall -ggdb -O2 endif +STATIC_LIB_DEPS:= LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib LIB_CXXFLAGS:=$(CFLAGS) ${CPPFLAGS} -I. -I.. -I../lib LIB_LDFLAGS:=${LDFLAGS} @@ -192,6 +193,7 @@ ifeq ($(WITH_TLS),yes) LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_TLS PASSWD_LIBS:=-lcrypto CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_TLS + STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lssl -lcrypto ifeq ($(WITH_TLS_PSK),yes) BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_TLS_PSK @@ -204,6 +206,7 @@ ifeq ($(WITH_THREADING),yes) LIB_LIBS:=$(LIB_LIBS) -lpthread LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_THREADING CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_THREADING + STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lpthread endif ifeq ($(WITH_SOCKS),yes) @@ -249,6 +252,7 @@ ifeq ($(WITH_SRV),yes) LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_SRV LIB_LIBS:=$(LIB_LIBS) -lcares CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_SRV + STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lcares endif ifeq ($(UNAME),SunOS) diff --git a/src/bridge.c b/src/bridge.c index d9611f0d..1a6303ed 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -112,7 +112,6 @@ int bridge__new(struct mosquitto_db *db, struct mosquitto__bridge *bridge) int bridge__connect_step1(struct mosquitto_db *db, struct mosquitto *context) { int rc; - int i; char *notification_topic; int notification_topic_len; uint8_t notification_payload; diff --git a/src/conf.c b/src/conf.c index aea01f0d..953f442f 100644 --- a/src/conf.c +++ b/src/conf.c @@ -727,12 +727,12 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct char *tmp_char; struct mosquitto__bridge *cur_bridge = NULL; struct mosquitto__bridge_topic *cur_topic; + int len; #endif struct mosquitto__auth_plugin_config *cur_auth_plugin_config = NULL; time_t expiration_mult; char *key; - int len; struct mosquitto__listener *cur_listener = &config->default_listener; int i; int lineno_ext; diff --git a/src/loop.c b/src/loop.c index 7535b6d0..ebf7dcd4 100644 --- a/src/loop.c +++ b/src/loop.c @@ -756,7 +756,7 @@ static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pol if(!getsockopt(context->sock, SOL_SOCKET, SO_ERROR, (char *)&err, &len)){ if(err == 0){ context->state = mosq_cs_new; -#ifdef WITH_ADNS +#if defined(WITH_ADNS) && defined(WITH_BRIDGE) if(context->bridge){ bridge__connect_step3(db, context); continue;