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 <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Andrew Deason 2020-07-01 22:42:37 -05:00 committed by Benjamin Kaduk
parent 3ccf8eaeb0
commit 405001be72
9 changed files with 71 additions and 64 deletions

View 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'))"

View 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 \
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

View 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

View 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

View 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)

View 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

View 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

View 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

View 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)