From bab41fc510f738832f0f9c50a83bfd13e0da5d29 Mon Sep 17 00:00:00 2001 From: Peter Colberg Date: Thu, 12 Nov 2015 14:56:08 -0500 Subject: [PATCH] Test shared library Add make check target that builds and runs the tests. --- .travis.sh | 3 +-- Makefile | 15 ++++++++++++++- test/Makefile | 9 ++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.travis.sh b/.travis.sh index 9c03ba4..ed014c7 100755 --- a/.travis.sh +++ b/.travis.sh @@ -21,5 +21,4 @@ arm32) ;; esac -$LOADER ./test/test-double -$LOADER ./test/test-float +$LOADER make check diff --git a/Makefile b/Makefile index 111af1c..b26d4f4 100644 --- a/Makefile +++ b/Makefile @@ -24,10 +24,17 @@ OBJS = $(patsubst %.f,%.f.o,\ $(patsubst %.S,%.S.o,\ $(patsubst %.c,%.c.o,$(filter-out $(addprefix src/,$(DUPLICATE_SRCS)),$(SRCS))))) +.PHONY: all check test clean distclean install + all: libopenlibm.a libopenlibm.$(SHLIB_EXT) - $(MAKE) -C test + +check test: test/test-double test/test-float + test/test-double + test/test-float + libopenlibm.a: $(OBJS) $(AR) -rcs libopenlibm.a $(OBJS) + libopenlibm.$(SHLIB_EXT): $(OBJS) ifeq ($(OS),WINNT) $(CC) -shared $(OBJS) $(LDFLAGS) $(LDFLAGS_add) -Wl,$(SONAME_FLAG),libopenlibm.$(SHLIB_EXT) -o libopenlibm.$(SHLIB_EXT) @@ -37,6 +44,12 @@ else @-ln -sf libopenlibm.$(SHLIB_EXT).$(SOMAJOR).$(SOMINOR) libopenlibm.$(SHLIB_EXT) endif +test/test-double: libopenlibm.$(SHLIB_EXT) + $(MAKE) -C test test-double + +test/test-float: libopenlibm.$(SHLIB_EXT) + $(MAKE) -C test test-float + clean: @for dir in $(SUBDIRS) .; do \ rm -fr $$dir/*.o $$dir/*.a $$dir/*.$(SHLIB_EXT)*; \ diff --git a/test/Makefile b/test/Makefile index eb8b8c0..2592ad5 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,15 +1,18 @@ OPENLIBM_HOME=$(abspath ..) include ../Make.inc +# Set rpath of tests to builddir for loading shared library +OPENLIBM_LIB = -L.. -lopenlibm -Wl,-rpath=$(OPENLIBM_HOME) + all: test-double test-float # test-double-system test-float-system bench: bench-syslibm bench-openlibm test-double: test-double.c libm-test.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -g $@.c -D__BSD_VISIBLE -I ../include -I../src $(OPENLIBM_LIB) -o $@ test-float: test-float.c libm-test.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -g $@.c -D__BSD_VISIBLE -I ../include -I../src $(OPENLIBM_LIB) -o $@ test-double-system: test-double.c libm-test.c $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -g $< -DSYS_MATH_H -lm -o $@ @@ -18,7 +21,7 @@ test-float-system: test-float.c libm-test.c $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -g $< -DSYS_MATH_H -lm -o $@ bench-openlibm: libm-bench.cpp - $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -O2 $< ../libopenlibm.a -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -O2 $< $(OPENLIBM_LIB) -o $@ bench-syslibm: libm-bench.cpp $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add_TARGET_$(ARCH)) $(LDFLAGS) -O2 $< -lm -o $@