@@ -2,75 +2,106 @@ IDIR = .
2
2
CC = cc
3
3
4
4
ifdef MODERN_CC
5
- EXTRA_C_FLAGS = -g -O03 -std=c99 -pedantic -Wall
5
+ EXTRA_C_FLAGS = -g -O03 -std=c99 -pedantic -Wall -Wno-unused-function
6
6
endif
7
7
8
8
ifdef CC_32_BIT
9
- EXTRA_C_FLAGS = -m32 -g -O03 -std=c99 -pedantic -Wall
9
+ EXTRA_C_FLAGS = -m32 -g -O03 -std=c99 -pedantic -Wall -Wno-unused-function
10
10
endif
11
11
12
12
ifdef ADD_SAN
13
13
CC = clang
14
- EXTRA_C_FLAGS = -std=c99 -Wall -pedantic -g -O00 -fsanitize=address -fno-omit-frame-pointer
15
- USE_GC_STRING = -use_gc
14
+ EXTRA_C_FLAGS = -std=c99 -Wall -pedantic -g -O00 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-function
16
15
endif
17
16
18
17
ifdef MEM_SAN
19
18
CC = clang
20
- EXTRA_C_FLAGS = -std=c99 -Wall -pedantic -g -O00 -fsanitize=memory -fno-omit-frame-pointer
19
+ EXTRA_C_FLAGS = -std=c99 -Wall -pedantic -g -O00 -fsanitize=memory -fno-omit-frame-pointer -Wno-unused-function
21
20
endif
22
21
23
22
ifdef UB_SAN
24
23
CC = clang
25
- EXTRA_C_FLAGS = -std=c99 -Wall -pedantic -g -O00 -fsanitize=undefined -fno-omit-frame-pointer
24
+ EXTRA_C_FLAGS = -std=c99 -Wall -pedantic -g -O00 -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-function
26
25
endif
27
26
28
- CFLAGS = -g -O01 -I$(IDIR ) $(EXTRA_C_FLAGS )
27
+ CFLAGS = -g -O00 -I$(IDIR ) $(EXTRA_C_FLAGS )
29
28
30
29
ODIR = .
31
30
LDIR =
32
31
33
- DEPS = dynarr.h test_framework.h
32
+ _DEPS = dynarr.h test_framework.h hashbag.h lru.h list .h
34
33
DEPS = $(patsubst % ,$(IDIR ) /% ,$(_DEPS ) )
35
34
36
- _OBJ = test .o
35
+ _OBJ = test_dynarr .o
37
36
OBJ = $(patsubst % ,$(ODIR ) /% ,$(_OBJ ) )
38
37
C_FILES = $(patsubst % .o,% .c,$(_OBJ ) )
39
38
39
+ _OBJ2 = test_hashbag.o
40
+ OBJ2 = $(patsubst % ,$(ODIR ) /% ,$(_OBJ2 ) )
41
+ C_FILES2 = $(patsubst % .o,% .c,$(_OBJ2 ) )
42
+
43
+ _OBJ3 = test_lru.o
44
+ OBJ3 = $(patsubst % ,$(ODIR ) /% ,$(_OBJ3 ) )
45
+ C_FILES3 = $(patsubst % .o,% .c,$(_OBJ3 ) )
46
+
47
+ ALL_CFILES = $(C_FILES ) $(C_FILES2 ) $(C_FILES3 )
48
+
49
+ main : test_dynarr.bin test_hashbag.bin test_lru.bin
50
+ echo OK
51
+
40
52
$(ODIR ) /% .o : % .c $(DEPS )
41
53
$(CC ) -c -o $@ $< $(CFLAGS )
42
54
43
- test .bin : $(OBJ )
55
+ test_dynarr .bin : $(OBJ )
44
56
$(CC ) -o $@ $^ $(CFLAGS )
45
57
58
+ test_hashbag.bin : $(OBJ2 )
59
+ $(CC ) -o $@ $^ $(CFLAGS )
60
+
61
+ test_lru.bin : $(OBJ3 )
62
+ $(CC ) -o $@ $^ $(CFLAGS )
46
63
47
64
.PHONY : clean test run_test_continusly CMakeLists.txt cmake_compile clang_format test_add_san test_ub_san test_mem_san test_sanitizers test_modern_cc test_valgrind test_macro_expanded.bin
48
65
49
- test_macro_expanded.bin :
50
- gcc -E -C -P test.c > tmp_tmp_test.c
66
+ test_macro_expanded_gen :
67
+ gcc -E -C -P $( TESTPROG ) > tmp_tmp_test.c
51
68
clang-format tmp_tmp_test.c > tmp_test.c
52
69
rm tmp_tmp_test.c
53
- gcc -g -O01 tmp_test.c
70
+ gcc -Wall -Wno-unused-function - g -O01 tmp_test.c
54
71
valgrind --leak-check=full ./a.out
55
72
56
- test : test.bin
57
- ./test.bin ; \
73
+ test_macro_expanded_dynarr :
74
+ TESTPROG=test_dynarr.c make test_macro_expanded_gen
75
+
76
+ test_macro_expanded_hashbag :
77
+ TESTPROG=test_hashbag.c make test_macro_expanded_gen
78
+
79
+ test_macro_expanded_lru :
80
+ TESTPROG=test_lru.c make test_macro_expanded_gen
81
+
82
+ test : test_dynarr.bin test_hashbag.bin test_lru.bin
83
+ ./test_dynarr.bin && ./test_hashbag.bin && ./test_lru.bin; \
58
84
RESULT=$$? && \
59
85
(exit $$ RESULT) && \
60
86
printf " \n\n\033[0;32mALL TESTS PASSED!\033[0m\n\n\n" || \
61
87
printf " \n\n\033[0;31mTEST FAILED!\033[0m\n\n\n" && \
62
88
exit $$ RESULT
63
89
64
- test_valgrind :
90
+ test_valgrind_gen :
65
91
make clean && \
66
92
make EXTRA_C_FLAGS=" -g -O01" && \
67
- valgrind --undef-value-errors=no ./test.bin ; \
93
+ valgrind --undef-value-errors=no --leak-check=full $( BIN ) ; \
68
94
RESULT=$$? && \
69
95
(exit $$ RESULT) && \
70
96
printf " \n\n\033[0;32mALL TESTS PASSED!\033[0m\n\n\n" || \
71
97
printf " \n\n\033[0;31mTEST FAILED!\033[0m\n\n\n" && \
72
98
exit $$ RESULT
73
99
100
+ test_valgrind :
101
+ BIN=./test_dynarr.bin make test_valgrind_gen
102
+ BIN=./test_hashbag.bin make test_valgrind_gen
103
+ BIN=./test_lru.bin make test_valgrind_gen
104
+
74
105
test_add_san :
75
106
make clean && \
76
107
make ADD_SAN=1 test
@@ -100,18 +131,24 @@ test_32_bit:
100
131
test_all :
101
132
make test_valgrind && \
102
133
make test_sanitizers && \
103
- make test_modern_cc && \
104
- make test_32_bit
134
+ make test_modern_cc
135
+ # make test_32_bit
105
136
106
137
run_test_continusly :
107
138
inotifywait -e close_write,moved_to,create -m ./* .c ./* .h | while read -r directory events filename; do gtags ; make test ; done
108
139
109
- CMakeLists.txt : $(C_FILES )
140
+ CMakeLists.txt : $(C_FILES ) $( C_FILES2 ) $( C_FILES3 )
110
141
echo " cmake_minimum_required (VERSION 2.6)" > CMakeLists.txt
111
- echo " project (SIMPLE_C_GC )" >> CMakeLists.txt
112
- echo " add_executable(cmake .out" >> CMakeLists.txt
142
+ echo " project (DS )" >> CMakeLists.txt
143
+ echo " add_executable(dynarr .out" >> CMakeLists.txt
113
144
echo $(C_FILES ) >> CMakeLists.txt
114
145
echo " )" >> CMakeLists.txt
146
+ echo " add_executable(hashbag.out" >> CMakeLists.txt
147
+ echo $(C_FILES2 ) >> CMakeLists.txt
148
+ echo " )" >> CMakeLists.txt
149
+ echo " add_executable(lru.out" >> CMakeLists.txt
150
+ echo $(C_FILES3> CMakeLists.txt
151
+ echo " )" >> CMakeLists.txt
115
152
116
153
117
154
cmake_compile : CMakeLists.txt
@@ -125,4 +162,4 @@ clang_format:
125
162
clang-format -style=" {BasedOnStyle: LLVM}" -i * .c * .h
126
163
127
164
clean :
128
- rm -f $(ODIR ) /* .o * ~ core $(IDIR ) /* ~ test .bin CMakeLists.txt
165
+ rm -f $(ODIR ) /* .o * ~ core $(IDIR ) /* ~ test_dynarr .bin CMakeLists.txt
0 commit comments