From fcbb0cdb3cc092c1b28ae4237b86435514d6c4bf Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Wed, 2 Jun 2021 15:31:41 +0200 Subject: test improvements --- Makefile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index dd64148..567fb2e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,9 @@ LDFLAGS = -lm BUILDDIR = build SOURCEDIR = src OBJECTDIR = obj + TESTDIR = tests +TESTFLAGS = $(CFLAGS) -D_TEST OUTPUT = dnsd @@ -24,9 +26,9 @@ debug: CFLAGS += -g -D _DEBUG debug: build; test: LDFLAGS += -lcheck -test: clean dir $(TOBJS) $(TSUBS) +test: dir $(TOBJS) $(TSUBS) @echo [LD] $(TOBJS) $(TSUBS) - @$(CC) $(CFLAGS) -I $(SOURCEDIR) -o $(TESTDIR)/run $(TOBJS) $(TSUBS) $(LDFLAGS) + @$(CC) $(TESTFLAGS) -o $(TESTDIR)/run $(TOBJS) $(TSUBS) $(LDFLAGS) @$(TESTDIR)/run dir: @@ -39,7 +41,7 @@ $(OBJECTDIR)/%.o: $(SOURCEDIR)/%.c $(TESTDIR)/%.o: $(TESTDIR)/%.c @echo [TEST] $< - @$(CC) $(CFLAGS) -I $(SOURCEDIR) -c $< -o $@ + @$(CC) $(TESTFLAGS) -c $< -o $@ #sudo setcap 'cap_net_bind_service=+ep' /path/to/prog #to allow port access @@ -57,4 +59,11 @@ clean: all: clean build devsetup: - @echo "$(CFLAGS)" | tr ' ' '\n' > compile_flags.txt + @echo "[" > compile_commands.json + @for file in $(SRCS); do \ + echo "{\"directory\":\"$(PWD)\",\"command\":\"$(shell which $(CC)) $(CFLAGS) -c $$file\",\"file\":\"$(PWD)/$$file\"}," >> compile_commands.json;\ + done + @for file in $(TESTS); do \ + echo "{\"directory\":\"$(PWD)\",\"command\":\"$(shell which $(CC)) $(TESTFLAGS) -c $$file\",\"file\":\"$(PWD)/$$file\"}," >> compile_commands.json;\ + done + @echo "]" >> compile_commands.json -- cgit v1.2.3