1ALL=test-base64 test-md4 test-milenage \
2	test-rsa-sig-ver \
3	test-sha1 \
4	test-https test-https_server \
5	test-sha256 test-aes test-x509v3 test-list test-rc4
6
7include ../src/build.rules
8
9ifdef LIBFUZZER
10CC=clang
11CFLAGS = -MMD -O2 -Wall -g
12CFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow
13CFLAGS += -DTEST_LIBFUZZER
14LDFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow
15TEST_FUZZ=y
16endif
17
18ifdef TEST_FUZZ
19CFLAGS += -DCONFIG_NO_RANDOM_POOL
20CFLAGS += -DTEST_FUZZ
21endif
22
23CFLAGS += -DCONFIG_IEEE80211R_AP
24CFLAGS += -DCONFIG_IEEE80211R
25CFLAGS += -DCONFIG_TDLS
26
27CFLAGS += -I../src
28CFLAGS += -I../src/utils
29
30SLIBS = ../src/utils/libutils.a
31
32DLIBS = ../src/crypto/libcrypto.a \
33	../src/tls/libtls.a
34
35_OBJS_VAR := LLIBS
36include ../src/objs.mk
37_OBJS_VAR := SLIBS
38include ../src/objs.mk
39_OBJS_VAR := DLIBS
40include ../src/objs.mk
41
42LIBS = $(SLIBS) $(DLIBS)
43LLIBS = -Wl,--start-group $(DLIBS) -Wl,--end-group $(SLIBS)
44
45# glibc < 2.17 needs -lrt for clock_gettime()
46LLIBS += -lrt
47
48test-aes: $(call BUILDOBJ,test-aes.o) $(LIBS)
49	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
50
51test-base64: $(call BUILDOBJ,test-base64.o) $(LIBS)
52	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
53
54test-https: $(call BUILDOBJ,test-https.o) $(LIBS)
55	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
56
57test-https_server: $(call BUILDOBJ,test-https_server.o) $(LIBS)
58	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
59
60test-list: $(call BUILDOBJ,test-list.o) $(LIBS)
61	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
62
63test-md4: $(call BUILDOBJ,test-md4.o) $(LIBS)
64	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
65
66test-milenage: $(call BUILDOBJ,test-milenage.o) $(LIBS)
67	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
68
69test-rc4: $(call BUILDOBJ,test-rc4.o) $(LIBS)
70	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
71
72test-rsa-sig-ver: $(call BUILDOBJ,test-rsa-sig-ver.o) $(LIBS)
73	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
74
75test-sha1: $(call BUILDOBJ,test-sha1.o) $(LIBS)
76	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
77
78test-sha256: $(call BUILDOBJ,test-sha256.o) $(LIBS)
79	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
80
81test-x509v3: $(call BUILDOBJ,test-x509v3.o) $(LIBS)
82	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
83
84
85run-tests: $(ALL)
86	./test-aes
87	./test-list
88	./test-md4
89	./test-milenage
90	./test-rsa-sig-ver
91	./test-sha1
92	./test-sha256
93	@echo
94	@echo All tests completed successfully.
95
96clean: common-clean
97	rm -f *~
98	rm -f test_x509v3_nist.out.*
99	rm -f test_x509v3_nist2.out.*
100