Browse Source

Moved C tests

Yann Weber 4 years ago
parent
commit
53e0d2cead
3 changed files with 31 additions and 13 deletions
  1. 7
    13
      Makefile
  2. 24
    0
      tests/Makefile
  3. 0
    0
      tests/test_rpn.c

+ 7
- 13
Makefile View File

@@ -51,13 +51,6 @@ rpn_ifs.o: rpn_ifs.c rpn_ifs.h rpn_if.o
51 51
 rpn_lib.o: rpn_lib.asm rpn_lib.h
52 52
 	$(NASM) $(NASMCFLAGS) -o $@ $<
53 53
 
54
-# Dirty & quick tests
55
-test: test.o rpn_lib.o rpn_jit.o rpn_parse.o
56
-	$(CC) $(CFLAGS) -o $@ $^
57
-
58
-test.o: test.c
59
-	$(CC) $(CFLAGS) -c -o $@ $<
60
-
61 54
 # Doxygen documentation
62 55
 doc: doc/.doxygen.stamp
63 56
 
@@ -84,14 +77,15 @@ benchmark: pyrpn.so
84 77
 unittest: pyrpn.so
85 78
 	PYTHONPATH=`pwd` $(PYTHON) -m unittest
86 79
 
87
-runtest: test
88
-	./test
80
+runtest:
81
+	make -C tests
89 82
 
90 83
 clean:
91
-	-rm -fv *.o pyrpn.so test
92
-	-rm -fRv doc/.doxygen.stamp doc/* Doxyfile
84
+	-rm -fv *.o pyrpn.so test;\
85
+	-rm -fRv doc/.doxygen.stamp doc/* Doxyfile;\
86
+	make -C tests clean
93 87
 
94 88
 distclean: clean
95
-	-rm -vf .deps
96
-	-rm -Rvf tests/__pycache__
89
+	-rm -vf .deps;\
90
+	-rm -Rvf tests/__pycache__;
97 91
 

+ 24
- 0
tests/Makefile View File

@@ -0,0 +1,24 @@
1
+CC=gcc
2
+LD=ld
3
+SOURCES=$(wildcard test_*.c)
4
+OBJS=$(patsubst %.c,%.o, $(SOURCES))
5
+BINARIES=$(patsubst %.o, %, $(OBJS))
6
+
7
+all: checks
8
+
9
+checks: $(BINARIES)
10
+	for test_bin in $(BINARIES); do echo "Running $${test_bin}.c"; ./$$test_bin && echo "OK" || echo "fail"; done
11
+
12
+../%.o:
13
+	make -C ..
14
+
15
+%.o: %.c
16
+	$(CC) -I.. $(CFLAGS) -c -o $@ $<
17
+
18
+test_%: test_%.o ../rpn_lib.o ../rpn_jit.o ../rpn_parse.o
19
+	$(CC) -I..  $(CFLAGS) -o $@ $^
20
+	
21
+.PHONY: clean
22
+
23
+clean:
24
+	-rm -v $(BINARIES) $(OBJS)

test.c → tests/test_rpn.c View File


Loading…
Cancel
Save