tests: Introduce libafstest_common 18/14318/6
authorAndrew Deason <adeason@sinenomine.net>
Thu, 2 Jul 2020 03:42:37 +0000 (22:42 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 8 Aug 2021 00:38:05 +0000 (20:38 -0400)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/config/Makefile.config.in
tests/auth/Makefile.in
tests/cmd/Makefile.in
tests/common/Makefile.in
tests/opr/Makefile.in
tests/rx/Makefile.in
tests/tap/Makefile.in
tests/util/Makefile.in
tests/volser/Makefile.in

index 3c908e7..bdf0515 100644 (file)
@@ -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'))"
 
index 8fbe678..ffa7f67 100644 (file)
@@ -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 \
-               $(MODULE_LIBS)
+authcon-t: authcon-t.o
+       $(LT_LDRULE_static) authcon-t.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)
+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)
 
-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)
+keys-t: keys-t.o
+       $(LT_LDRULE_static) keys-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)
+realms-t: realms-t.o
+       $(LT_LDRULE_static) realms-t.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
index a67e5d3..a6752c1 100644 (file)
@@ -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
index 3bc6096..5866977 100644 (file)
@@ -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
index 2cf1203..6fecf33 100644 (file)
@@ -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)
index a408c04..88c3f9e 100644 (file)
@@ -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
index 2f5f745..5ddf41b 100644 (file)
@@ -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
index 2eed584..271783b 100644 (file)
@@ -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
index 05e6926..063003f 100644 (file)
@@ -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)