blob: 0b4a145d7d8b17a795cba0e06db418b414574697 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001RUN_TESTS= \
2 test-list \
3 test-md4 test-rc4 test-sha1 test-sha256 \
4 test-milenage test-aes \
5 test-crypto_module
6
7ALL=$(RUN_TESTS) test-base64 test-https test-https_server
8
9include ../src/build.rules
10
11ifdef LIBFUZZER
12CC=clang
13CFLAGS = -MMD -O2 -Wall -g
14CFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow
15CFLAGS += -DTEST_LIBFUZZER
16LDFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow
17TEST_FUZZ=y
18endif
19
20ifdef TEST_FUZZ
21CFLAGS += -DCONFIG_NO_RANDOM_POOL
22CFLAGS += -DTEST_FUZZ
23endif
24
25CFLAGS += -DCONFIG_IEEE80211R_AP
26CFLAGS += -DCONFIG_IEEE80211R
27CFLAGS += -DCONFIG_TDLS
28
29# test-crypto_module
30CFLAGS += -DCONFIG_MODULE_TESTS
31CFLAGS += -DCONFIG_DPP
32#CFLAGS += -DCONFIG_DPP2
33#CFLAGS += -DCONFIG_DPP3
34CFLAGS += -DCONFIG_ECC
35CFLAGS += -DCONFIG_HMAC_SHA256_KDF
36CFLAGS += -DCONFIG_HMAC_SHA384_KDF
37CFLAGS += -DCONFIG_MESH
38CFLAGS += -DCONFIG_SHA256
39CFLAGS += -DCONFIG_SHA384
40CFLAGS += -DEAP_PSK
41CFLAGS += -DEAP_FAST
42
43CFLAGS += -I../src
44CFLAGS += -I../src/utils
45
46SLIBS = ../src/utils/libutils.a
47
48DLIBS = ../src/tls/libtls.a \
49 ../src/crypto/libcrypto.a
50
51_OBJS_VAR := LLIBS
52include ../src/objs.mk
53_OBJS_VAR := SLIBS
54include ../src/objs.mk
55_OBJS_VAR := DLIBS
56include ../src/objs.mk
57
58LIBS = $(SLIBS) $(DLIBS)
59LLIBS = -Wl,--start-group $(DLIBS) -Wl,--end-group $(SLIBS)
60
61ifeq ($(CONFIG_TLS),mbedtls)
62CFLAGS += -DCONFIG_TLS_MBEDTLS
63LLIBS += -lmbedtls -lmbedx509 -lmbedcrypto
64else
65ifeq ($(CONFIG_TLS),openssl)
66CFLAGS += -DCONFIG_TLS_OPENSSL
67LLIBS += -lssl -lcrypto
68else
69ifeq ($(CONFIG_TLS),gnutls)
70CFLAGS += -DCONFIG_TLS_GNUTLS
71LLIBS += -lgnutls -lgpg-error -lgcrypt
72else
73ifeq ($(CONFIG_TLS),wolfssl)
74CFLAGS += -DCONFIG_TLS_WOLFSSL
75LLIBS += -lwolfssl -lm
76else
77CFLAGS += -DCONFIG_TLS_INTERNAL
78CFLAGS += -DCONFIG_TLS_INTERNAL_SERVER
79ALL += test-rsa-sig-ver
80ALL += test-x509v3
81clean-config_tls_internal:
82 rm -f test_x509v3_nist.out.*
83 rm -f test_x509v3_nist2.out.*
84endif
85endif
86endif
87endif
88
89# glibc < 2.17 needs -lrt for clock_gettime()
90LLIBS += -lrt
91
92test-aes: $(call BUILDOBJ,test-aes.o) $(LIBS)
93 $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
94
95test-crypto_module: $(call BUILDOBJ,test-crypto_module.o) $(LIBS)
96 $(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
97
98test-base64: $(call BUILDOBJ,test-base64.o) $(LIBS)
99 $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
100
101test-https: $(call BUILDOBJ,test-https.o) $(LIBS)
102 $(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
103
104test-https_server: $(call BUILDOBJ,test-https_server.o) $(LIBS)
105 $(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
106
107test-list: $(call BUILDOBJ,test-list.o) $(LIBS)
108 $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
109
110test-md4: $(call BUILDOBJ,test-md4.o) $(LIBS)
111 $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
112
113test-milenage: $(call BUILDOBJ,test-milenage.o) $(LIBS)
114 $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
115
116test-rc4: $(call BUILDOBJ,test-rc4.o) $(LIBS)
117 $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
118
119test-rsa-sig-ver: $(call BUILDOBJ,test-rsa-sig-ver.o) $(LIBS)
120 $(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
121
122test-sha1: $(call BUILDOBJ,test-sha1.o) $(LIBS)
123 $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
124
125test-sha256: $(call BUILDOBJ,test-sha256.o) $(LIBS)
126 $(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
127
128test-x509v3: $(call BUILDOBJ,test-x509v3.o) $(LIBS)
129 $(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
130
131
132run-tests: $(ALL)
133 @set -ex; for i in $(RUN_TESTS); do ./$$i; done
134 @echo
135 @echo All tests completed successfully.
136
137clean: common-clean clean-config_tls_internal
138 rm -f *~
139
140.PHONY: run-tests clean-config_tls_internal