From 3730644c350a6327185fbd4ef5a4aaedf7a30d21 Mon Sep 17 00:00:00 2001 From: Chrissie Caulfield Date: Tue, 27 Mar 2018 13:11:20 +0100 Subject: [PATCH] test: Fix 'make distcheck' (#303) Miscellaneous fixes and cleanups to get 'make distcheck' to work on most platforms. Signed-off-by: Christine Caulfield --- Makefile.am | 3 +++ lib/Makefile.am | 2 ++ tests/Makefile.am | 3 ++- tests/check_ipc.c | 7 +++++-- tests/functional/GNUmakefile | 2 +- tests/resources.test | 5 ++++- tests/start.test | 1 + 7 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1c9675f96..6ced4c185 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,6 +37,9 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure depcomp \ ACLOCAL_AMFLAGS = -I m4 +# For test suite +export SOCKETDIR + dist_doc_DATA = COPYING INSTALL README.markdown SUBDIRS = include lib docs tools tests examples diff --git a/lib/Makefile.am b/lib/Makefile.am index b035f0b0d..0e3d2ecac 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -137,6 +137,8 @@ install-exec-hook: qblog_script.ld sed -i -- "s/libqb.so./$${so_ver}/" \ "$(DESTDIR)$(libdir)/libqb.so-t" "$(DESTDIR)$(pkgconfigexecdir)/libqb.pc" mv -f "$(DESTDIR)$(libdir)/libqb.so-t" "$(DESTDIR)$(libdir)/libqb.so" + rm -f "$(DESTDIR)$(pkgconfigexecdir)/libqb.pc--" + rm -f "$(DESTDIR)$(libdir)/libqb.so-t--" endif if HAVE_SPLINT diff --git a/tests/Makefile.am b/tests/Makefile.am index 1198634bc..5bc4bbb1b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -80,8 +80,9 @@ check: check-headers .PHONY: check-headers check-headers: $(auto_c_files:.c=.o) -distclean-compile: +distclean-local: rm -rf auto_*.c + rm -rf .deps if HAVE_DICT_WORDS if HAVE_SLOW_TESTS diff --git a/tests/check_ipc.c b/tests/check_ipc.c index 7bcb11f9f..f8af2c5ef 100644 --- a/tests/check_ipc.c +++ b/tests/check_ipc.c @@ -23,6 +23,7 @@ #include "os_base.h" #include +#include #include #include "check_common.h" @@ -132,7 +133,6 @@ set_ipc_name(const char *prefix) if (f) { fgets(process_name, sizeof(process_name), f); fclose(f); - fprintf(stderr, "CC: using stored SHM name %s\n", process_name); snprintf(ipc_name, sizeof(ipc_name), "%s%s", prefix, process_name); } else { /* This is the old code, use only as a fallback */ @@ -145,7 +145,6 @@ set_ipc_name(const char *prefix) snprintf(ipc_name, sizeof(ipc_name), "%s%s%lX%.4x", prefix, t_sec, (unsigned long)getpid(), (unsigned) ((long) time(NULL) % (0x10000))); - fprintf(stderr, "CC: using calculated SHM name %s\n", ipc_name); } } @@ -1436,11 +1435,15 @@ END_TEST START_TEST(test_ipcc_truncate_when_unlink_fails_shm) { char sock_file[PATH_MAX]; + struct sockaddr_un socka; + qb_enter(); ipc_type = QB_IPC_SHM; set_ipc_name(__func__); sprintf(sock_file, "%s/%s", SOCKETDIR, ipc_name); + sock_file[sizeof(socka.sun_path)] = '\0'; + /* If there's an old socket left from a previous run this test will fail unexpectedly, so try to remove it first */ unlink(sock_file); diff --git a/tests/functional/GNUmakefile b/tests/functional/GNUmakefile index f75d543e4..658ac3902 100644 --- a/tests/functional/GNUmakefile +++ b/tests/functional/GNUmakefile @@ -10,7 +10,7 @@ distclean maintainer-clean: # includes, which are swiped when processing one subdir and then # missing, as a hard error, for the other) @$(MAKE) -C log_external $@ - @mkdir .deps + @mkdir -p .deps @touch .deps/log_client.Po .deps/log_interlib.Plo .deps/log_interlib_client.Po @$(MAKE) -C log_internal $@ @$(MAKE) -f Makefile $@ SUBDIRS= diff --git a/tests/resources.test b/tests/resources.test index 40468d3ff..0fc7f6ecf 100755 --- a/tests/resources.test +++ b/tests/resources.test @@ -2,7 +2,7 @@ RETURN=0 IPC_NAME=`cat ipc-test-name 2>/dev/null` -for d in /dev/shm /var/run; do +for d in /dev/shm /var/run $SOCKETDIR; do leftovers=$(find $d -name qb-test*${IPC_NAME}* -size +0c 2>/dev/null | wc -l) if [ "${leftovers}" -gt 0 ]; then echo @@ -30,4 +30,7 @@ if [ $? -eq 0 ]; then RETURN=1 fi +# Keep it tidy - distcheck checks we have not left a mess +rm -f ipc-test-name +rm -f crash_test_dummy.core exit $RETURN diff --git a/tests/start.test b/tests/start.test index 09358699b..91c0223f1 100755 --- a/tests/start.test +++ b/tests/start.test @@ -8,3 +8,4 @@ # NAME="$$-`date +%N`" echo -n "$NAME" > ipc-test-name +mkdir -p $SOCKETDIR