From 52d9768418da3f21fe936f9ba7ae35e2c46f61f3 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 10 Mar 2021 14:36:42 -0500 Subject: [PATCH] TT#14008 move build tests to a wrapper script Since dh_auto_test doesn't execute the test suites through make directly, but instead runs `make -s -n` and then executes the output, the integrated build tests fail since the sub-make doesn't return an error as it should when attempting to build with the wrong .h alternative, resulting in always the first .h alternative being used. Fix this by using a wrapper script instead. Also adjust some other related minor build details. closes #1202 Change-Id: I4b6436295c6b39117bd06df53aa5afc7118ad6a1 --- daemon/Makefile | 5 ----- lib/common.Makefile | 23 ++++++++--------------- t/Makefile | 6 ++++-- utils/build_test_wrapper | 19 +++++++++++++++++++ 4 files changed, 31 insertions(+), 22 deletions(-) create mode 100755 utils/build_test_wrapper diff --git a/daemon/Makefile b/daemon/Makefile index 89860063d..8d99e93a6 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -90,8 +90,3 @@ PODS= rtpengine.pod MANS= $(PODS:.pod=.8) include ../lib/common.Makefile - -ifeq ($(with_transcoding),yes) -codec.c: dtmf_rx_fillin.h -t38.c: spandsp_logging.h -endif diff --git a/lib/common.Makefile b/lib/common.Makefile index 2a2f52816..fa84d9758 100644 --- a/lib/common.Makefile +++ b/lib/common.Makefile @@ -36,23 +36,16 @@ $(DAEMONSRCS) $(HASHSRCS): $(patsubst %,../daemon/%,$(DAEMONSRCS)) $(patsubst %, resample.c: fix_frame_channel_layout.h +ifeq ($(with_transcoding),yes) +codec.c: dtmf_rx_fillin.h +endif + +t38.c: spandsp_logging.h + %.strhash.c: %.c ../utils/const_str_hash - ../utils/const_str_hash < $< > $@ + ../utils/const_str_hash < "$<" > "$@" $(BUILD_TEST_ALTS): ../lib/$(@:.h=-*) - echo "Looking for usable alternative for $@"; \ - rm -f $(@:.h=-test{.c,}); \ - ln -s ../lib/$(@:.h=-test.c); \ - for x in ../lib/$(@:.h=-*.h); do \ - echo "Trying build with $$x"; \ - rm -f "$@"; \ - echo '/******** GENERATED FILE ********/' > "$@"; \ - cat "$$x" >> "$@"; \ - $(MAKE) $(@:.h=-test) && break; \ - echo "Failed build with $$x"; \ - rm -f "$@"; \ - done; \ - rm -f $(@:.h=-test{.c,}); \ - test -f "$@" + ../utils/build_test_wrapper "$@" .PHONY: all debug clean install diff --git a/t/Makefile b/t/Makefile index 544635991..c7732e3ab 100644 --- a/t/Makefile +++ b/t/Makefile @@ -172,5 +172,7 @@ test-const_str_hash.strhash: test-const_str_hash.strhash.o $(COMMONOBJS) tests-preload.so: tests-preload.c $(CC) -g -D_GNU_SOURCE -std=c99 -o $@ -Wall -shared -fPIC $< -ldl -codec.c: dtmf_rx_fillin.h -t38.c: spandsp_logging.h +spandsp_send_fax_pcm.c: spandsp_logging.h +spandsp_send_fax_t38.c: spandsp_logging.h +spandsp_recv_fax_t38.c: spandsp_logging.h +spandsp_recv_fax_pcm.c: spandsp_logging.h diff --git a/utils/build_test_wrapper b/utils/build_test_wrapper new file mode 100755 index 000000000..6bbaace72 --- /dev/null +++ b/utils/build_test_wrapper @@ -0,0 +1,19 @@ +#!/bin/sh +TARGET=$1 +ROOT=$(echo "$TARGET" | sed 's/\.h$//') +if test "x$MAKE" = x; then + MAKE=make +fi +echo "Looking for usable alternative for $TARGET" +rm -f "$ROOT"-test "$ROOT"-test.c +ln -s ../lib/"$ROOT"-test.c +for x in ../lib/"$ROOT"*.h; do + echo "Trying build with $x" + rm -f "$TARGET" + (echo '/******** GENERATED FILE ********/'; cat "$x") > "$TARGET" + $MAKE "$ROOT"-test && break + echo "Failed build with $x" + rm -f "$TARGET" +done +rm -f "$ROOT"-test "$ROOT"-test.c +test -f "$TARGET"