commit 5a910155ad5dccced72eb8a502a66d91c21145ec
parent 9a55e1cb69882352cdf3224e913489d638e57e85
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 11 Jan 2023 11:55:27 +0900
add Makefile for test
Diffstat:
6 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/ex9/Makefile b/ex9/Makefile
@@ -4,11 +4,17 @@ LIBS=-L/usr/X11R6/lib -lX11 -lXext -lm
IN=*.c
OUT=main
-main: $(IN)
+TD=test
+TIN=$(TD)/*.c
+
+prog: $(IN)
$(CC) $(INCS) $(CFLAGS) -o $(OUT) $(IN) $(LIBS)
-run: main
+run: prog
./$(OUT)
+test: prog $(TIN)
+ make -C $(TD) test
+
clean:
rm -f $(OUT)
diff --git a/ex9/test/.gitignore b/ex9/test/.gitignore
@@ -0,0 +1,2 @@
+test
+test.core
diff --git a/ex9/test/Makefile b/ex9/test/Makefile
@@ -0,0 +1,10 @@
+CC=cc
+IN=*.c ../!(main|object).c
+OUT=test
+INCS=-I/usr/X11R6/include
+CFLAGS=-Wall -W -Wextra -Wpointer-arith -Wbad-function-cast -std=c11
+LIBS=-L/usr/X11R6/lib -lX11 -lXext -lm
+
+test: *.c
+ $(CC) $(INCS) $(CFLAGS) -o $(OUT) $(IN) $(LIBS)
+ ./$(OUT)
diff --git a/ex9/test/list_t.c b/ex9/test/list_t.c
@@ -3,6 +3,7 @@
#include <assert.h>
#include "../list.h"
+#include "test.h"
struct Item {
int id;
@@ -176,12 +177,3 @@ test_lswap(void)
lfreei(p, (void (*))(void *)&ifree);
}
-
-int
-main(void)
-{
- test_laddfront();
- test_lswap();
-
- return 0;
-}
diff --git a/ex9/test/test.c b/ex9/test/test.c
@@ -0,0 +1,10 @@
+#include "test.h"
+
+int
+main(void)
+{
+ test_laddfront();
+ test_lswap();
+
+ return 0;
+}
diff --git a/ex9/test/test.h b/ex9/test/test.h
@@ -0,0 +1,2 @@
+void test_laddfront(void);
+void test_lswap(void);