aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Makefile
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-22 12:31:46 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-22 12:42:48 +0100
commit29b8c1556bf456596c6c067d413b65b51e17724e (patch)
treeb225381d762af049e9174cdf1459db1f91c9589a /tests/Makefile
downloadmalloc-29b8c1556bf456596c6c067d413b65b51e17724e.tar.gz
malloc-29b8c1556bf456596c6c067d413b65b51e17724e.zip
Initial scaffold: Makefile, stub malloc/free/realloc, test harness
Build system produces libft_malloc_$HOSTTYPE.so shared library with Libft (NOMALLOC=1) as dependency. Stub functions print their name and return NULL. Test runner compares system malloc vs LD_PRELOAD output using write(2) to avoid stdio interference.
Diffstat (limited to 'tests/Makefile')
-rw-r--r--tests/Makefile40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..04d7c1f
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,40 @@
+CC = cc
+CFLAGS = -Wall -Wextra -Werror $(EXTRA)
+
+SRCDIR = src
+OBJDIR = obj
+BINDIR = bin
+
+NAME = $(BINDIR)/test
+
+SRCS = main.c
+
+OBJS = $(SRCS:%.c=$(OBJDIR)/%.o)
+
+MALLOC_LIB = ../lib/libft_malloc.so
+
+$(NAME): $(OBJS) | $(BINDIR)
+ $(CC) $(CFLAGS) -o $@ $(OBJS)
+
+all: $(NAME)
+
+$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
+ $(CC) $(CFLAGS) -c $< -o $@
+
+$(OBJDIR):
+ mkdir -p $(OBJDIR)
+
+$(BINDIR):
+ mkdir -p $(BINDIR)
+
+test: $(NAME)
+ @echo "=== system malloc ==="
+ @$(NAME)
+ @echo ""
+ @echo "=== ft_malloc ==="
+ @LD_PRELOAD=$(MALLOC_LIB) $(NAME)
+
+clean:
+ rm -rf $(OBJDIR) $(BINDIR)
+
+.PHONY: all test clean