summaryrefslogtreecommitdiff
path: root/tests/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Makefile')
-rw-r--r--tests/Makefile142
1 files changed, 142 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..b71c004
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,142 @@
1MACHINE := $(shell uname -m)
2CFLAGS ?= -std=gnu99
3CFLAGS += -I../include/ -D_FORTIFY_SOURCE=3 -static -O2 -Wall -Wextra -Werror -Werror=pointer-arith
4CFLAGS += -Wno-format -Wno-array-bounds -Wno-shift-count-negative -Wno-unused-variable -Wno-unused-parameter
5
6RUNTIME_TARGETS= \
7 test_FD_CLR_SETSIZE \
8 test_FD_CLR_negative \
9 test_FD_SET_SETSIZE \
10 test_FD_SET_negative \
11 test_bcopy_dynamic_read \
12 test_bcopy_dynamic_write \
13 test_bcopy_static_read \
14 test_bcopy_static_write \
15 test_bzero_dynamic_write \
16 test_bzero_static_write \
17 test_compile \
18 test_confstr_dynamic \
19 test_fgets_dynamic \
20 test_fgets_static \
21 test_fgetws_dynamic \
22 test_fgetws_static \
23 test_fread_int_overflow \
24 test_fread_overwrite_dynamic \
25 test_fread_overwrite_static \
26 test_fwrite_int_overflow \
27 test_fwrite_overwrite_dynamic \
28 test_fwrite_overwrite_static \
29 test_getcwd_dynamic \
30 test_getcwd_static \
31 test_getdomainname_dynamic \
32 test_getdomainname_static \
33 test_getgroups_dynamic \
34 test_getgroups_static \
35 test_gethostname_dynamic \
36 test_gethostname_static \
37 test_getlogin_r_dynamic \
38 test_getlogin_r_static \
39 test_memcpy_dynamic_read \
40 test_memcpy_dynamic_write \
41 test_memcpy_static_read \
42 test_memmove_dynamic_read \
43 test_memmove_dynamic_write \
44 test_memmove_static_read \
45 test_memmove_static_write \
46 test_mempcpy_dynamic_read \
47 test_mempcpy_dynamic_write \
48 test_mempcpy_static_read \
49 test_mempcpy_static_write \
50 test_memset_dynamic_write \
51 test_memset_static_write \
52 test_poll_dynamic \
53 test_poll_static \
54 test_ppoll_dynamic \
55 test_ppoll_static \
56 test_read_dynamic \
57 test_read_static \
58 test_readlink_dynamic \
59 test_readlink_static \
60 test_recv_dynamic \
61 test_recv_static \
62 test_recvfrom_dynamic \
63 test_recvfrom_static \
64 test_send_dynamic \
65 test_send_static \
66 test_sendto_dynamic \
67 test_sendto_static \
68 test_sprintf \
69 test_sprintf_62 \
70 test_stpcpy_dynamic_write \
71 test_stpcpy_static_write \
72 test_stpncpy_dynamic_write \
73 test_stpncpy_static_write \
74 test_strcat_static_write \
75 test_strcpy_dynamic_write \
76 test_strcpy_static_write \
77 test_strlcat_dynamic_write \
78 test_strlcat_static_write \
79 test_strlcpy_dynamic_write \
80 test_strlcpy_static_write \
81 test_strncat_dynamic_write \
82 test_strncat_static_write \
83 test_strncpy_dynamic_write \
84 test_strncpy_static_write \
85 test_swab_dynamic_read \
86 test_swab_dynamic_write \
87 test_swab_static_read \
88 test_ttyname_r_dynamic \
89 test_ttyname_r_static \
90 test_vsnprintf_dynamic \
91 test_vsnprintf_static \
92 test_vsprintf \
93 test_wcscat_static_write \
94 test_wcscpy_static_write \
95 test_wcsncat_static_write \
96 test_wcsncpy_static_write \
97 test_wmemcpy_dynamic_write \
98 test_wmemcpy_static_write \
99 test_wmemmove_dynamic_write \
100 test_wmemmove_static_write \
101 test_wmemset_dynamic \
102 test_wmemset_static \
103 test_write_dynamic \
104 test_write_static \
105
106gcc: CC=../$(MACHINE)-linux-musl-native/bin/gcc
107gcc: CFLAGS += -Wno-stringop-overread -Wno-stringop-overflow -ffreestanding
108gcc: $(RUNTIME_TARGETS)
109
110clang: CC=clang
111clang: CFLAGS+=-I/usr/include/$(MACHINE)-linux-musl
112clang: CFLAGS+=-I../$(MACHINE)-linux-musl-native/include/
113clang: CFLAGS+=-I$(MACHINE)-linux-musl-native/include/
114clang: CFLAGS+=-nostdinc
115clang: CXX=clang++
116clang: CXXFLAGS+=-I/usr/include/$(MACHINE)-linux-musl
117clang: CXXFLAGS+=-I../$(MACHINE)-linux-musl-native/include/
118clang: CXXFLAGS+=-I$(MACHINE)-linux-musl-native/include/
119clang: CXXFLAGS+=-nostdinc
120clang: $(RUNTIME_TARGETS) cpp
121
122all: gcc
123
124
125$(RUNTIME_TARGETS): %: %.c
126 $(CC) $(CFLAGS) -o $@ $<
127
128cpp: test_compile.cc
129 $(CXX) $(CXXFLAGS) test_compile.cc -o ./test_compile_cc
130 timeout 1s ./test_compile_cc 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \
131
132run: $(RUNTIME_TARGETS)
133 $(foreach EXE, $(RUNTIME_TARGETS), \
134 timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \
135 )
136
137clean:
138 $(foreach EXE, $(RUNTIME_TARGETS), \
139 rm -f ./$(EXE) \
140 )
141 rm -f ./test_compile_cc
142