From d5ecd8fe69115c8587e16a2110bbb92790050b52 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 30 Jun 2020 11:11:54 -0400 Subject: add some simple tests --- Makefile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0dd5261..e8a413f 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,20 @@ .POSIX: +BINDIR=bin LIBDIR=lib OBJDIR=obj SRCDIR=src INCDIR=include +TESTDIR=test CFLAGS=-I$(INCDIR) -Wall -Wextra -Wpedantic -g OBJECTS=$(OBJDIR)/mapalloc.o +TESTS=$(BINDIR)/overflow $(BINDIR)/underflow $(BINDIR)/zero all: $(LIBDIR)/libmapalloc.a $(LIBDIR)/libmapalloc.so +tests: $(TESTS) + $(OBJDIR)/mapalloc.o: $(SRCDIR)/mapalloc.c $(INCDIR)/mapalloc.h @mkdir -p $(@D) $(CC) -c -o $@ $(CFLAGS) $(SRCDIR)/$(*F).c @@ -22,5 +27,13 @@ $(LIBDIR)/libmapalloc.so: $(OBJECTS) @mkdir -p $(@D) $(CC) -o $@ -shared $(OBJECTS) +$(BINDIR)/overflow: $(TESTDIR)/overflow.c $(LIBDIR)/libmapalloc.a +$(BINDIR)/underflow: $(TESTDIR)/underflow.c $(LIBDIR)/libmapalloc.a +$(BINDIR)/zero: $(TESTDIR)/zero.c $(LIBDIR)/libmapalloc.a + +$(TESTS): + @mkdir -p $(@D) + $(CC) -o $@ $(CFLAGS) $(TESTDIR)/$(@F).c -L$(LIBDIR) -lmapalloc + clean: - $(RM) -rf $(LIBDIR) $(OBJDIR) + $(RM) -rf $(LIBDIR) $(OBJDIR) $(BINDIR) -- cgit v1.2.1