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	test-bss
7
8include ../src/build.rules
9
10ifdef LIBFUZZER
11CC=clang
12CFLAGS = -MMD -O2 -Wall -g
13CFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow
14CFLAGS += -DTEST_LIBFUZZER
15LDFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow
16TEST_FUZZ=y
17endif
18
19ifdef TEST_FUZZ
20CFLAGS += -DCONFIG_NO_RANDOM_POOL
21CFLAGS += -DTEST_FUZZ
22endif
23
24CFLAGS += -DCONFIG_IEEE80211R_AP
25CFLAGS += -DCONFIG_IEEE80211R
26CFLAGS += -DCONFIG_TDLS
27
28CFLAGS += -I../src
29CFLAGS += -I../src/utils
30
31SLIBS = ../src/utils/libutils.a
32
33DLIBS = ../src/crypto/libcrypto.a \
34	../src/tls/libtls.a
35
36_OBJS_VAR := LLIBS
37include ../src/objs.mk
38_OBJS_VAR := SLIBS
39include ../src/objs.mk
40_OBJS_VAR := DLIBS
41include ../src/objs.mk
42
43LIBS = $(SLIBS) $(DLIBS)
44LLIBS = -Wl,--start-group $(DLIBS) -Wl,--end-group $(SLIBS)
45
46# glibc < 2.17 needs -lrt for clock_gettime()
47LLIBS += -lrt
48
49test-aes: $(call BUILDOBJ,test-aes.o) $(LIBS)
50	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
51
52test-base64: $(call BUILDOBJ,test-base64.o) $(LIBS)
53	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
54
55test-https: $(call BUILDOBJ,test-https.o) $(LIBS)
56	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
57
58test-https_server: $(call BUILDOBJ,test-https_server.o) $(LIBS)
59	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
60
61test-list: $(call BUILDOBJ,test-list.o) $(LIBS)
62	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
63
64test-md4: $(call BUILDOBJ,test-md4.o) $(LIBS)
65	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
66
67test-milenage: $(call BUILDOBJ,test-milenage.o) $(LIBS)
68	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
69
70test-rc4: $(call BUILDOBJ,test-rc4.o) $(LIBS)
71	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
72
73test-rsa-sig-ver: $(call BUILDOBJ,test-rsa-sig-ver.o) $(LIBS)
74	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
75
76test-sha1: $(call BUILDOBJ,test-sha1.o) $(LIBS)
77	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
78
79test-sha256: $(call BUILDOBJ,test-sha256.o) $(LIBS)
80	$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
81
82test-x509v3: $(call BUILDOBJ,test-x509v3.o) $(LIBS)
83	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
84
85
86# We could cut this down more by enabling fewer options (above)
87ELIBS += $(SRC)/crypto/libcrypto.a
88ELIBS += $(SRC)/tls/libtls.a
89
90WPAS_SRC=../wpa_supplicant
91SRC=../src
92WPA_LIBS = $(SRC)/common/libcommon.a
93
94CFLAGS += -I$(SRC) -I$(SRC)/utils -I$(WPAS_SRC)
95
96CFLAGS += -DCONFIG_DRIVER_NONE
97CFLAGS += -DIEEE8021X_EAPOL
98
99WPA_OBJS = $(WPAS_SRC)/bssid_ignore.o
100WPA_OBJS += $(WPAS_SRC)/bss.o
101WPA_OBJS += $(WPAS_SRC)/config.o
102WPA_OBJS += $(WPAS_SRC)/config_file.o
103WPA_OBJS += $(WPAS_SRC)/eap_register.o
104WPA_OBJS += $(WPAS_SRC)/events.o
105WPA_OBJS += $(WPAS_SRC)/notify.o
106WPA_OBJS += $(WPAS_SRC)/offchannel.o
107WPA_OBJS += $(WPAS_SRC)/op_classes.o
108WPA_OBJS += $(WPAS_SRC)/robust_av.o
109WPA_OBJS += $(WPAS_SRC)/rrm.o
110WPA_OBJS += $(WPAS_SRC)/scan.o
111WPA_OBJS += $(WPAS_SRC)/wmm_ac.o
112WPA_OBJS += $(WPAS_SRC)/wpa_supplicant.o
113WPA_OBJS += $(WPAS_SRC)/wpas_glue.o
114WPA_OBJS += $(SRC)/rsn_supp/wpa.o
115WPA_OBJS += $(SRC)/rsn_supp/wpa_ft.o
116WPA_OBJS += $(SRC)/rsn_supp/wpa_ie.o
117WPA_OBJS += $(SRC)/rsn_supp/tdls.o
118WPA_OBJS += $(SRC)/rsn_supp/preauth.o
119WPA_OBJS += $(SRC)/rsn_supp/pmksa_cache.o
120WPA_OBJS += $(SRC)/eapol_supp/eapol_supp_sm.o
121WPA_OBJS += $(SRC)/eap_common/eap_common.o
122WPA_OBJS += $(SRC)/eap_peer/eap.o
123WPA_OBJS += $(SRC)/eap_peer/eap_methods.o
124WPA_OBJS += $(SRC)/drivers/driver_common.o
125WPA_OBJS += $(SRC)/drivers/driver_none.o
126WPA_OBJS += $(SRC)/drivers/drivers.o
127WPA_OBJS += $(SRC)/l2_packet/l2_packet_none.o
128
129_OBJS_VAR := WPA_OBJS
130include ../src/objs.mk
131
132_OBJS_VAR := WPA_LIBS
133include ../src/objs.mk
134
135_OBJS_VAR := ELIBS
136include ../src/objs.mk
137
138LIBS=$(SLIBS) $(DLIBS) $(WPA_LIBS) $(ELIBS)
139
140test-bss: $(call BUILDOBJ,test-bss.o) $(WPA_OBJS) $(LIBS)
141	$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS) $(WPA_CFLAGS) $(WPA_OBJS) $(LIBS)
142
143run-tests: $(ALL)
144	./test-aes
145	./test-list
146	./test-md4
147	./test-milenage
148	./test-rsa-sig-ver
149	./test-sha1
150	./test-sha256
151	./test-bss
152	@echo
153	@echo All tests completed successfully.
154
155clean: common-clean
156	rm -f *~
157	rm -f test_x509v3_nist.out.*
158	rm -f test_x509v3_nist2.out.*
159