blob: f0da1cf241a512f1cd5680d45d806899f9053c64 [file] [log] [blame]
Paul Bakker0049c2f2009-07-11 19:15:43 +00001
2# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
Paul Bakker43b7e352011-01-18 15:27:19 +00003# To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS
Paul Bakker0049c2f2009-07-11 19:15:43 +00004
Mohammad Azim Khanfff49042017-03-28 01:48:31 +01005CFLAGS ?= -g3 #-O2
Alon Bar-Levf7a9f302015-02-18 17:55:05 +02006WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wno-unused-function -Wno-unused-value
Alon Bar-Levada41052015-02-18 17:47:52 +02007LDFLAGS ?=
Paul Bakker0049c2f2009-07-11 19:15:43 +00008
Alon Bar-Levf7a9f302015-02-18 17:55:05 +02009LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
Mohammad Azim Khan94aefaf2017-03-23 12:32:54 +000010LOCAL_LDFLAGS = -L../library \
Manuel Pégourié-Gonnard21e1ac22015-06-25 08:45:12 +020011 -lmbedtls$(SHARED_SUFFIX) \
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020012 -lmbedx509$(SHARED_SUFFIX) \
Manuel Pégourié-Gonnard21e1ac22015-06-25 08:45:12 +020013 -lmbedcrypto$(SHARED_SUFFIX)
Paul Bakker0049c2f2009-07-11 19:15:43 +000014
Nicholas Wilson61fa4362018-06-25 12:10:00 +010015# Enable definition of various functions used throughout the testsuite
16# (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless
17# on non-POSIX platforms.
18LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L
19
Paul Bakker674e0b02014-03-26 13:26:52 +010020ifndef SHARED
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020021DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
Paul Bakker674e0b02014-03-26 13:26:52 +010022else
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020023DEP=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT)
Paul Bakker674e0b02014-03-26 13:26:52 +010024endif
25
Paul Bakkerc7ffd362012-04-05 12:08:29 +000026ifdef DEBUG
Alon Bar-Levf7a9f302015-02-18 17:55:05 +020027LOCAL_CFLAGS += -g3
Paul Bakkerc7ffd362012-04-05 12:08:29 +000028endif
29
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020030# if we're running on Windows, build for Windows
Paul Bakkercd5b5292012-05-10 20:49:10 +000031ifdef WINDOWS
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020032WINDOWS_BUILD=1
33endif
34
35ifdef WINDOWS_BUILD
36DLEXT=dll
37EXEXT=.exe
Alon Bar-Levada41052015-02-18 17:47:52 +020038LOCAL_LDFLAGS += -lws2_32
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020039ifdef SHARED
40SHARED_SUFFIX=.$(DLEXT)
41endif
Manuel Pégourié-Gonnard8d4a6132015-06-24 12:16:20 +020042else
Andres Amaya Garcia420f0cc2018-03-27 19:17:21 +010043DLEXT ?= so
Manuel Pégourié-Gonnard8d4a6132015-06-24 12:16:20 +020044EXEXT=
45SHARED_SUFFIX=
Paul Bakkercd5b5292012-05-10 20:49:10 +000046endif
47
Paul Bakker2770fbd2012-07-03 13:30:23 +000048# Zlib shared library extensions:
49ifdef ZLIB
Alon Bar-Levada41052015-02-18 17:47:52 +020050LOCAL_LDFLAGS += -lz
Paul Bakker2770fbd2012-07-03 13:30:23 +000051endif
52
Mohammad Azim Khan94aefaf2017-03-23 12:32:54 +000053APPS = test_suite_aes.ecb test_suite_aes.cbc \
54 test_suite_aes.cfb test_suite_aes.ofb \
55 test_suite_aes.xts \
56 test_suite_aes.rest test_suite_arc4 \
57 test_suite_aria test_suite_asn1write \
58 test_suite_base64 test_suite_blowfish \
59 test_suite_camellia test_suite_ccm \
60 test_suite_chacha20 test_suite_chachapoly \
61 test_suite_cmac \
62 test_suite_cipher.chachapoly \
63 test_suite_cipher.aes \
64 test_suite_cipher.arc4 test_suite_cipher.ccm \
65 test_suite_cipher.chacha20 \
66 test_suite_cipher.gcm \
67 test_suite_cipher.blowfish \
68 test_suite_cipher.camellia \
69 test_suite_cipher.des test_suite_cipher.null \
70 test_suite_cipher.padding \
71 test_suite_ctr_drbg test_suite_debug \
72 test_suite_des test_suite_dhm \
73 test_suite_ecdh test_suite_ecdsa \
74 test_suite_ecjpake test_suite_ecp \
75 test_suite_error test_suite_entropy \
76 test_suite_gcm.aes128_de \
77 test_suite_gcm.aes192_de \
78 test_suite_gcm.aes256_de \
79 test_suite_gcm.aes128_en \
80 test_suite_gcm.aes192_en \
81 test_suite_gcm.aes256_en \
82 test_suite_gcm.camellia \
83 test_suite_hkdf \
84 test_suite_hmac_drbg.misc \
85 test_suite_hmac_drbg.no_reseed \
86 test_suite_hmac_drbg.nopr \
87 test_suite_hmac_drbg.pr \
88 test_suite_md test_suite_mdx \
89 test_suite_memory_buffer_alloc \
90 test_suite_mpi \
91 test_suite_nist_kw \
92 test_suite_pem test_suite_pkcs1_v15 \
93 test_suite_pkcs1_v21 test_suite_pkcs5 \
94 test_suite_pkparse test_suite_pkwrite \
95 test_suite_pk \
96 test_suite_poly1305 \
97 test_suite_rsa test_suite_shax \
98 test_suite_ssl test_suite_timing \
99 test_suite_x509parse test_suite_x509write \
100 test_suite_xtea test_suite_version
101
102BINARIES := $(addsuffix $(EXEXT),$(APPS))
103
104# Look up for associated function files
Mohammad Azim Khan1f29be72017-03-20 22:21:22 +0000105func.test_suite_aes.ecb := test_suite_aes
106func.test_suite_aes.cbc := test_suite_aes
107func.test_suite_aes.cfb := test_suite_aes
108func.test_suite_aes.ofb := test_suite_aes
109func.test_suite_aes.xts := test_suite_aes
110func.test_suite_aes.rest := test_suite_aes
111func.test_suite_arc4 := test_suite_arc4
112func.test_suite_aria := test_suite_aria
113func.test_suite_asn1write := test_suite_asn1write
114func.test_suite_base64 := test_suite_base64
115func.test_suite_blowfish := test_suite_blowfish
116func.test_suite_camellia := test_suite_camellia
117func.test_suite_ccm := test_suite_ccm
118func.test_suite_chacha20 := test_suite_chacha20
119func.test_suite_chachapoly := test_suite_chachapoly
120func.test_suite_cmac := test_suite_cmac
121func.test_suite_cipher.chachapoly := test_suite_cipher
122func.test_suite_cipher.aes := test_suite_cipher
123func.test_suite_cipher.arc4 := test_suite_cipher
124func.test_suite_cipher.ccm := test_suite_cipher
125func.test_suite_cipher.chacha20 := test_suite_cipher
126func.test_suite_cipher.gcm := test_suite_cipher
127func.test_suite_cipher.blowfish := test_suite_cipher
128func.test_suite_cipher.camellia := test_suite_cipher
129func.test_suite_cipher.des := test_suite_cipher
130func.test_suite_cipher.null := test_suite_cipher
131func.test_suite_cipher.padding := test_suite_cipher
132func.test_suite_ctr_drbg := test_suite_ctr_drbg
133func.test_suite_debug := test_suite_debug
134func.test_suite_des := test_suite_des
135func.test_suite_dhm := test_suite_dhm
136func.test_suite_ecdh := test_suite_ecdh
137func.test_suite_ecdsa := test_suite_ecdsa
138func.test_suite_ecjpake := test_suite_ecjpake
139func.test_suite_ecp := test_suite_ecp
140func.test_suite_error := test_suite_error
141func.test_suite_entropy := test_suite_entropy
142func.test_suite_gcm.aes128_de := test_suite_gcm
143func.test_suite_gcm.aes192_de := test_suite_gcm
144func.test_suite_gcm.aes256_de := test_suite_gcm
145func.test_suite_gcm.aes128_en := test_suite_gcm
146func.test_suite_gcm.aes192_en := test_suite_gcm
147func.test_suite_gcm.aes256_en := test_suite_gcm
148func.test_suite_gcm.camellia := test_suite_gcm
149func.test_suite_hkdf := test_suite_hkdf
150func.test_suite_hmac_drbg.misc := test_suite_hmac_drbg
151func.test_suite_hmac_drbg.no_reseed := test_suite_hmac_drbg
152func.test_suite_hmac_drbg.nopr := test_suite_hmac_drbg
153func.test_suite_hmac_drbg.pr := test_suite_hmac_drbg
154func.test_suite_md := test_suite_md
155func.test_suite_mdx := test_suite_mdx
156func.test_suite_memory_buffer_alloc := test_suite_memory_buffer_alloc
157func.test_suite_mpi := test_suite_mpi
158func.test_suite_nist_kw := test_suite_nist_kw
159func.test_suite_pem := test_suite_pem
160func.test_suite_pkcs1_v15 := test_suite_pkcs1_v15
161func.test_suite_pkcs1_v21 := test_suite_pkcs1_v21
162func.test_suite_pkcs5 := test_suite_pkcs5
163func.test_suite_pkparse := test_suite_pkparse
164func.test_suite_pkwrite := test_suite_pkwrite
165func.test_suite_pk := test_suite_pk
166func.test_suite_rsa := test_suite_rsa
167func.test_suite_shax := test_suite_shax
168func.test_suite_ssl := test_suite_ssl
169func.test_suite_timing := test_suite_timing
170func.test_suite_x509parse := test_suite_x509parse
171func.test_suite_x509write := test_suite_x509write
172func.test_suite_xtea := test_suite_xtea
173func.test_suite_version := test_suite_version
Paul Bakker0049c2f2009-07-11 19:15:43 +0000174
175.SILENT:
176
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200177.PHONY: all check test clean
178
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200179$(DEP):
Manuel Pégourié-Gonnardfc367082015-06-26 16:50:24 +0200180 $(MAKE) -C ../library
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200181
Manuel Pégourié-Gonnard6cacde22015-07-08 16:02:43 +0200182# invoke perl explicitly for the sake of mingw32-make
183
Mohammad Azim Khan94aefaf2017-03-23 12:32:54 +0000184C_FILES := $(addsuffix .c,$(APPS))
185
186.SECONDEXPANSION:
Mohammad Azim Khanfff49042017-03-28 01:48:31 +0100187$(C_FILES): %.c: suites/$$(func.$$*).function suites/%.data scripts/gen_mbed_code.py suites/helpers.function suites/mbed_test.function suites/desktop_test.function
Manuel Pégourié-Gonnard78ec2b02015-07-08 22:12:06 +0100188 echo " Gen $@"
Mohammad Azim Khanfff49042017-03-28 01:48:31 +0100189# perl scripts/generate_code.pl suites $(func.$*) $*
190 python scripts/gen_mbed_code.py -f suites/$(func.$*).function \
191 -d suites/$*.data \
192 -t suites/mbed_test.function \
193 -p suites/desktop_test.function \
194 -s suites \
195 --help-file suites/helpers.function \
196 -o .
Paul Bakker286bf3c2013-04-08 18:09:51 +0200197
Paul Bakker286bf3c2013-04-08 18:09:51 +0200198
Mohammad Azim Khan94aefaf2017-03-23 12:32:54 +0000199$(BINARIES): %$(EXEXT): %.c $(DEP)
Manuel Pégourié-Gonnard78ec2b02015-07-08 22:12:06 +0100200 echo " CC $<"
Alon Bar-Levf7a9f302015-02-18 17:55:05 +0200201 $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
Paul Bakker286bf3c2013-04-08 18:09:51 +0200202
Paul Bakker286bf3c2013-04-08 18:09:51 +0200203
Mohammad Azim Khan94aefaf2017-03-23 12:32:54 +0000204all: $(BINARIES)
Paul Bakker3ac1b2d2010-06-18 22:47:29 +0000205
Markku-Juhani O. Saarinen8df81e02017-12-01 14:26:40 +0000206
Paul Bakker0049c2f2009-07-11 19:15:43 +0000207clean:
Paul Bakker62f88dc2012-05-10 21:26:28 +0000208ifndef WINDOWS
Mohammad Azim Khanfff49042017-03-28 01:48:31 +0100209 rm -rf $(APPS) *.c *.data TESTS
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200210else
Mohammad Azim Khanfff49042017-03-28 01:48:31 +0100211 del /Q /F *.c *.exe *.data
Mohammad Azim Khan1f29be72017-03-20 22:21:22 +0000212 rmdir /Q /S TESTS
Paul Bakker62f88dc2012-05-10 21:26:28 +0000213endif
Paul Bakker0049c2f2009-07-11 19:15:43 +0000214
Mohammad Azim Khan94aefaf2017-03-23 12:32:54 +0000215check: $(BINARIES)
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +0100216 perl scripts/run-test-suites.pl
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200217
218test: check
Mohammad Azim Khan1f29be72017-03-20 22:21:22 +0000219
220# Create separate targets for generating mbed-os tests.
221MBED_APPS := $(addprefix mbed_,$(APPS))
222
223# FIXME: description needs change
224# Each test suite name is stripped off of prefix test_suite_. mbed-os test dir
225# structure requires format TESTS/<testgroup>[/<sub testgroups..>]/<test case>
226# Test app names are split on "." and end part is used as the test dir name.
227# Prevous parts are used as the test group dirs. For tests without "." same
228# name is used as the test group dir.
229
230.SECONDEXPANSION:
Mohammad Azim Khanfff49042017-03-28 01:48:31 +0100231$(MBED_APPS): mbed_%: suites/$$(func.$$*).function suites/%.data scripts/gen_mbed_code.py suites/helpers.function suites/mbed_test.function suites/embedded_test.function
232 echo " Gen ./TESTS/mbedtls/$*/$*.c"
Mohammad Azim Khan1f29be72017-03-20 22:21:22 +0000233 python scripts/gen_mbed_code.py -f suites/$(func.$*).function \
234 -d suites/$*.data \
235 -t suites/mbed_test.function \
Mohammad Azim Khanfff49042017-03-28 01:48:31 +0100236 -p suites/embedded_test.function \
Mohammad Azim Khan1f29be72017-03-20 22:21:22 +0000237 -s suites \
238 --help-file suites/helpers.function \
Mohammad Azim Khanfff49042017-03-28 01:48:31 +0100239 -o ./TESTS/mbedtls/$*
Mohammad Azim Khan1f29be72017-03-20 22:21:22 +0000240
241gen-mbed-test: $(MBED_APPS)
242