From 405001be722457680428ba6ec7f3b1b5a6fab47a Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 1 Jul 2020 22:42:37 -0500 Subject: [PATCH] tests: Introduce libafstest_common Currently, a few tests use the code in tests/common/ by linking individual object files in there in addition to the test code (e.g. linking ../common/config.o along with superuser-t.o). This convention makes it very obnoxious to move code around in tests/common/, since any users need to update their link lines. It also makes it difficult for code in tests/common/ to make use of functions in other tests/common/ files. To fix this, just build all of the objects in tests/common/ into a convenience library, called libafstest_common, and link the relevant tests against that. Link a few requisite libraries (roken, rfc3961) in libafstest_common, so each individual test doesn't need to link against them. Also link the TAP library itself in libafstest_common, so tests don't have to explicitly link against it separately. To do this, convert it into a libtool library, libafstest_tap.la. Change-Id: I9c031c164efee20201336edcbfaff429e1d231b7 Reviewed-on: https://gerrit.openafs.org/14318 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/config/Makefile.config.in | 13 ++++++++----- tests/auth/Makefile.in | 30 ++++++++++++------------------ tests/cmd/Makefile.in | 3 +-- tests/common/Makefile.in | 15 +++++++++++++-- tests/opr/Makefile.in | 19 ++++++++++--------- tests/rx/Makefile.in | 2 +- tests/tap/Makefile.in | 22 +++++++++++----------- tests/util/Makefile.in | 22 ++++++++++++---------- tests/volser/Makefile.in | 9 +++------ 9 files changed, 71 insertions(+), 64 deletions(-) diff --git a/src/config/Makefile.config.in b/src/config/Makefile.config.in index 3c908e71fb..bdf0515a3a 100644 --- a/src/config/Makefile.config.in +++ b/src/config/Makefile.config.in @@ -251,18 +251,21 @@ LT_current=0 LT_revision=0 LT_age=0 -# Basic rule to link a shared library. -LT_LDLIB_shlib_common=$(LIBTOOL) --quiet --mode=link --tag=CC \ +# Basic rule to link a shared library. Only use LT_LDLIB_shlib_internal +# directly when creating an internal-only library that is not intended for +# public use (and so does not need an export symbol list). All other libraries +# should be using one of the other LT_LDLIB_shlib* rules. +LT_LDLIB_shlib_internal=$(LIBTOOL) --quiet --mode=link --tag=CC \ $(LD_WRAPPER) $(MT_CC) -rpath $(libdir) \ $(PTH_LDFLAGS) $(PTH_CFLAGS) $(LDFLAGS_$(@)) \ -o $@ \ -version-info $(LT_current):$(LT_revision):$(LT_age) -LT_LDLIB_shlib=$(LT_LDLIB_shlib_common) -export-symbols $(srcdir)/$@.sym +LT_LDLIB_shlib=$(LT_LDLIB_shlib_internal) -export-symbols $(srcdir)/$@.sym -LT_LDLIB_shlib_only=$(LT_LDLIB_shlib_common) -shared -export-symbols $(srcdir)/$@.sym +LT_LDLIB_shlib_only=$(LT_LDLIB_shlib_internal) -shared -export-symbols $(srcdir)/$@.sym -LT_LDLIB_shlib_missing=$(LT_LDLIB_shlib_common) -shared -export-symbols-regex \ +LT_LDLIB_shlib_missing=$(LT_LDLIB_shlib_internal) -shared -export-symbols-regex \ "($$(sed -e 's/^/^/' -e 's/$$/$$|/' -e '$$ s/|$$//' $(srcdir)/$@.sym | \ tr -d '\n'))" diff --git a/tests/auth/Makefile.in b/tests/auth/Makefile.in index 8fbe678748..ffa7f670cb 100644 --- a/tests/auth/Makefile.in +++ b/tests/auth/Makefile.in @@ -10,31 +10,25 @@ MODULE_CFLAGS=-I$(TOP_OBJDIR) -I$(srcdir)/../common/ all check test tests: $(BINS) -MODULE_LIBS = ../tap/libtap.a \ +MODULE_LIBS = $(abs_top_builddir)/tests/common/libafstest_common.la \ $(abs_top_builddir)/src/auth/liboafs_auth.la \ - $(LIB_rfc3961) $(LIB_roken) \ $(XLIBS) -authcon-t: authcon-t.o ../common/config.o ../common/network.o - $(LT_LDRULE_static) authcon-t.o ../common/config.o ../common/network.o \ +authcon-t: authcon-t.o + $(LT_LDRULE_static) authcon-t.o $(MODULE_LIBS) + +superuser-t: superuser-t.o test.cs.o test.ss.o test.xdr.o + $(LT_LDRULE_static) superuser-t.o test.cs.o test.ss.o test.xdr.o \ $(MODULE_LIBS) -superuser-t: superuser-t.o ../common/config.o ../common/rxkad.o \ - test.cs.o test.ss.o test.xdr.o ../common/network.o \ - ../common/misc.o - $(LT_LDRULE_static) superuser-t.o ../common/config.o \ - ../common/rxkad.o ../common/servers.o \ - test.cs.o test.ss.o test.xdr.o ../common/network.o \ - ../common/misc.o $(MODULE_LIBS) +keys-t: keys-t.o + $(LT_LDRULE_static) keys-t.o $(MODULE_LIBS) -keys-t: keys-t.o ../common/config.o ../common/network.o - $(LT_LDRULE_static) keys-t.o ../common/config.o ../common/network.o $(MODULE_LIBS) +realms-t: realms-t.o + $(LT_LDRULE_static) realms-t.o $(MODULE_LIBS) -realms-t: realms-t.o ../common/config.o ../common/network.o - $(LT_LDRULE_static) realms-t.o ../common/config.o ../common/network.o $(MODULE_LIBS) - -writekeyfile: writekeyfile.o ../common/config.o - $(LT_LDRULE_static) writekeyfile.o ../common/config.o $(MODULE_LIBS) +writekeyfile: writekeyfile.o + $(LT_LDRULE_static) writekeyfile.o $(MODULE_LIBS) test.cs.c: test.xg $(RXGEN) -A -x -C -o $@ $(srcdir)/test.xg diff --git a/tests/cmd/Makefile.in b/tests/cmd/Makefile.in index a67e5d333a..a6752c1e48 100644 --- a/tests/cmd/Makefile.in +++ b/tests/cmd/Makefile.in @@ -7,10 +7,9 @@ include @TOP_OBJDIR@/src/config/Makefile.pthread MODULE_CFLAGS = -I$(TOP_OBJDIR) -LIBS = ../tap/libtap.a \ +LIBS = $(abs_top_builddir)/tests/common/libafstest_common.la \ $(abs_top_builddir)/src/cmd/liboafs_cmd.la \ $(abs_top_builddir)/src/comerr/liboafs_comerr.la \ - $(abs_top_builddir)/src/opr/liboafs_opr.la \ $(abs_top_builddir)/src/opr/liboafs_opr.la BINS = command-t diff --git a/tests/common/Makefile.in b/tests/common/Makefile.in index 3bc6096972..5866977985 100644 --- a/tests/common/Makefile.in +++ b/tests/common/Makefile.in @@ -1,12 +1,23 @@ srcdir=@srcdir@ -abs_top_builddir=@abs_top_builddir@ include @TOP_OBJDIR@/src/config/Makefile.config include @TOP_OBJDIR@/src/config/Makefile.pthread +include @TOP_OBJDIR@/src/config/Makefile.libtool MODULE_CFLAGS=-I$(TOP_OBJDIR) -all check test tests: config.o servers.o ubik.o rxkad.o network.o +LT_objs = config.lo misc.lo network.lo rxkad.lo servers.lo ubik.lo +LT_libs = $(LIB_rfc3961) $(LIB_roken) +LT_deps = $(top_builddir)/tests/tap/libafstest_tap.la \ + $(top_builddir)/src/util/liboafs_util.la + +all check test tests: libafstest_common.la + +# This library is just used internally for our tests, so use +# LT_LDLIB_shlib_internal so we don't need to manage a .sym export list. +libafstest_common.la: $(LT_objs) $(LT_deps) + $(LT_LDLIB_shlib_internal) $(LT_objs) $(LT_deps) $(LT_libs) clean: + $(LT_CLEAN) rm -f *.o diff --git a/tests/opr/Makefile.in b/tests/opr/Makefile.in index 2cf1203329..6fecf335d9 100644 --- a/tests/opr/Makefile.in +++ b/tests/opr/Makefile.in @@ -5,36 +5,37 @@ include @TOP_OBJDIR@/src/config/Makefile.pthread MODULE_CFLAGS = -I$(TOP_OBJDIR) -LIBS=../tap/libtap.a $(abs_top_builddir)/src/opr/liboafs_opr.la +LIBS= $(abs_top_builddir)/tests/common/libafstest_common.la \ + $(abs_top_builddir)/src/opr/liboafs_opr.la BINS = cache-t dict-t fmt-t jhash-t queues-t rbtree-t softsig-helper time-t \ uuid-t all check test tests: $(BINS) -cache-t: cache-t.o +cache-t: cache-t.o $(LIBS) $(LT_LDRULE_static) cache-t.o $(LIBS) $(XLIBS) -dict-t: dict-t.o +dict-t: dict-t.o $(LIBS) $(LT_LDRULE_static) dict-t.o $(LIBS) $(XLIBS) fmt-t: fmt-t.o $(LT_LDRULE_static) fmt-t.o $(LIBS) $(XLIBS) -queues-t: queues-t.o - $(LT_LDRULE_static) queues-t.o ../tap/libtap.a $(XLIBS) +queues-t: queues-t.o $(LIBS) + $(LT_LDRULE_static) queues-t.o $(LIBS) $(XLIBS) rbtree-t: rbtree-t.o $(LIBS) - $(LT_LDRULE_static) rbtree-t.o ../tap/libtap.a $(LIBS) $(XLIBS) + $(LT_LDRULE_static) rbtree-t.o $(LIBS) $(XLIBS) jhash-t: jhash-t.o - $(LT_LDRULE_static) jhash-t.o ../tap/libtap.a $(XLIBS) + $(LT_LDRULE_static) jhash-t.o $(LIBS) $(XLIBS) time-t: time-t.o - $(LT_LDRULE_static) time-t.o ../tap/libtap.a $(XLIBS) + $(LT_LDRULE_static) time-t.o $(LIBS) $(XLIBS) uuid-t: uuid-t.o - $(LT_LDRULE_static) uuid-t.o ../tap/libtap.a $(LIBS) $(XLIBS) + $(LT_LDRULE_static) uuid-t.o $(LIBS) $(XLIBS) softsig-helper: softsig-helper.o $(LIBS) $(LT_LDRULE_static) softsig-helper.o $(LIBS) $(XLIBS) diff --git a/tests/rx/Makefile.in b/tests/rx/Makefile.in index a408c04dd6..88c3f9e761 100644 --- a/tests/rx/Makefile.in +++ b/tests/rx/Makefile.in @@ -7,7 +7,7 @@ include @TOP_OBJDIR@/src/config/Makefile.pthread MODULE_CFLAGS = -I$(TOP_OBJDIR) -LIBS = ../tap/libtap.a \ +LIBS = $(abs_top_builddir)/tests/common/libafstest_common.la \ $(abs_top_builddir)/src/rx/liboafs_rx.la BINS = event-t diff --git a/tests/tap/Makefile.in b/tests/tap/Makefile.in index 2f5f7455c6..5ddf41b570 100644 --- a/tests/tap/Makefile.in +++ b/tests/tap/Makefile.in @@ -5,12 +5,13 @@ tapdir=$(srcdir)/../../src/external/c-tap-harness/tests/tap include @TOP_OBJDIR@/src/config/Makefile.config include @TOP_OBJDIR@/src/config/Makefile.pthread -objects = basic.o +LT_objs = basic.lo -all check test tests: libtap.a basic.h macros.h libtap.sh +all check test tests: libafstest_tap.la basic.h macros.h libtap.sh -basic.o: $(tapdir)/basic.c $(tapdir)/basic.h - $(CC) $(AFS_CFLAGS) @CFLAGS_NOERROR@ -I$(tapdir)/../.. -c $(tapdir)/basic.c +CFLAGS_basic.lo = @CFLAGS_NOERROR@ -I$(tapdir)/../.. +basic.lo: $(tapdir)/basic.c $(tapdir)/basic.h + $(LT_CCRULE) $(tapdir)/basic.c basic.h: $(tapdir)/basic.h cp $(tapdir)/basic.h basic.h @@ -21,12 +22,11 @@ macros.h: $(tapdir)/macros.h libtap.sh: $(tapdir)/libtap.sh cp $(tapdir)/libtap.sh libtap.sh -libtap.a: $(objects) - $(RM) -f libtap.a - $(AR) crv libtap.a $(objects) - $(RANLIB) libtap.a - -install: +# Use LT_LDLIB_shlib_internal, since this is an internal-only library (just +# used for the tests), so we don't need a symbol export list. +libafstest_tap.la: $(LT_objs) + $(LT_LDLIB_shlib_internal) $(LT_objs) clean distclean: - $(RM) -f *.o *.a core basic.h macros.h libtap.sh + $(LT_CLEAN) + $(RM) -f *.o basic.h macros.h libtap.sh diff --git a/tests/util/Makefile.in b/tests/util/Makefile.in index 2eed5843ae..271783b3a4 100644 --- a/tests/util/Makefile.in +++ b/tests/util/Makefile.in @@ -3,28 +3,30 @@ srcdir=@srcdir@ abs_top_builddir=@abs_top_builddir@ include @TOP_OBJDIR@/src/config/Makefile.config -include @TOP_OBJDIR@/src/config/Makefile.lwp +include @TOP_OBJDIR@/src/config/Makefile.pthread +include @TOP_OBJDIR@/src/config/Makefile.libtool MODULE_CFLAGS = -I$(TOP_OBJDIR) -LIBS = ../tap/libtap.a \ - $(abs_top_builddir)/lib/util.a \ - $(abs_top_builddir)/lib/libopr.a +LIBS = $(abs_top_builddir)/tests/common/libafstest_common.la \ + $(abs_top_builddir)/src/util/liboafs_util.la \ + $(abs_top_builddir)/src/opr/liboafs_opr.la BINS = ktime-t exec-alt-t volutil-t all check test tests: $(BINS) -ktime-t: ktime-t.o $(LIBS) - $(AFS_LDRULE) ktime-t.o $(LIBS) $(XLIBS) +ktime-t: ktime-t.lo $(LIBS) + $(LT_LDRULE_static) ktime-t.lo $(LIBS) $(XLIBS) -exec-alt-t: exec-alt-t.o $(LIBS) - $(AFS_LDRULE) exec-alt-t.o $(LIBS) $(XLIBS) +exec-alt-t: exec-alt-t.lo $(LIBS) + $(LT_LDRULE_static) exec-alt-t.lo $(LIBS) $(XLIBS) -volutil-t: volutil-t.o $(LIBS) - $(AFS_LDRULE) volutil-t.o $(LIBS) $(LIB_roken) $(XLIBS) +volutil-t: volutil-t.lo $(LIBS) + $(LT_LDRULE_static) volutil-t.lo $(LIBS) $(XLIBS) install: clean distclean: + $(LT_CLEAN) $(RM) -f $(BINS) *.o core diff --git a/tests/volser/Makefile.in b/tests/volser/Makefile.in index 05e6926fbe..063003f253 100644 --- a/tests/volser/Makefile.in +++ b/tests/volser/Makefile.in @@ -10,15 +10,12 @@ MODULE_CFLAGS=-I$(TOP_OBJDIR) -I$(srcdir)/../common/ all check test tests: $(BINS) -MODULE_LIBS = ../tap/libtap.a \ +MODULE_LIBS = $(abs_top_builddir)/tests/common/libafstest_common.la \ $(abs_top_builddir)/src/vlserver/liboafs_vldb.la \ $(XLIBS) -vos-t: vos-t.o ../common/config.o ../common/servers.o ../common/ubik.o \ - ../common/network.o ../common/misc.o - $(LT_LDRULE_static) vos-t.o ../common/config.o ../common/servers.o \ - ../common/ubik.o ../common/network.o ../common/misc.o \ - $(MODULE_LIBS) +vos-t: vos-t.o + $(LT_LDRULE_static) vos-t.o $(MODULE_LIBS) clean: $(LT_CLEAN)