From 3e746c51b3adcf97e4d11be30bfd91c8aaf2c2ba Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 18 Aug 2018 23:40:11 +0200 Subject: Fix and run tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 68e5b97..591d62a 100644 --- a/Makefile +++ b/Makefile @@ -54,17 +54,48 @@ OBJ =\ vweprintf.o\ libsimple.o -all: libsimple.a +TESTS =\ + asprintf.test\ + isutf8.test\ + memdup.test\ + memends.test\ + memmem.test\ + memrchr.test\ + memrmem.test\ + memstarts.test\ + rawmemchr.test\ + rawmemrchr.test\ + strcaseends.test\ + strcasestr.test\ + strends.test\ + strndup.test\ + strrcasestr.test\ + strrstr.test\ + strstarts.test\ + vasprintf.test + +all: libsimple.a $(TESTS) $(OBJ): $(@:.o=.c) libsimple.h +$(TESTS): $(@:=.o) libsimple.a +$(TESTS:=.o): $(@:.test.o=.c) libsimple.h test.h libsimple.a: $(OBJ) $(AR) rc $@ $? $(AR) -s $@ +.test.o.test: + $(CC) -o $@ $< libsimple.a $(LDFLAGS) + +.c.test.o: + $(CC) -c -o $@ $< $(CFLAGS) -DTEST + +check: $(TESTS) + @set -e; for t in $(TESTS); do printf '%s\n' "./$$t"; "./$$t"; done + clean: - -rm -rf -- *.o *.su *.a *.so *.so.* *.gch *.gcda *.gcno *.gcov *.lo + -rm -rf -- *.o *.su *.a *.so *.so.* *.gch *.gcda *.gcno *.gcov *.lo *.test .SUFFIXES: -.SUFFIXES: .o .c +.SUFFIXES: .test .test.o .o .c -.PHONY: all clean +.PHONY: all check clean -- cgit v1.2.3-70-g09d2