Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 1 | |
| 2 | # To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 3 | # To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 4 | |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 5 | CFLAGS ?= -g3 #-O2 |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 6 | WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wno-unused-function -Wno-unused-value |
Alon Bar-Lev | ada4105 | 2015-02-18 17:47:52 +0200 | [diff] [blame] | 7 | LDFLAGS ?= |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 8 | |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 9 | LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64 |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 10 | LOCAL_LDFLAGS = -L../library \ |
Manuel Pégourié-Gonnard | 21e1ac2 | 2015-06-25 08:45:12 +0200 | [diff] [blame] | 11 | -lmbedtls$(SHARED_SUFFIX) \ |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 12 | -lmbedx509$(SHARED_SUFFIX) \ |
Manuel Pégourié-Gonnard | 21e1ac2 | 2015-06-25 08:45:12 +0200 | [diff] [blame] | 13 | -lmbedcrypto$(SHARED_SUFFIX) |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 14 | |
Nicholas Wilson | 61fa436 | 2018-06-25 12:10:00 +0100 | [diff] [blame] | 15 | # 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. |
| 18 | LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L |
| 19 | |
Paul Bakker | 674e0b0 | 2014-03-26 13:26:52 +0100 | [diff] [blame] | 20 | ifndef SHARED |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 21 | DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a |
Paul Bakker | 674e0b0 | 2014-03-26 13:26:52 +0100 | [diff] [blame] | 22 | else |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 23 | DEP=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT) |
Paul Bakker | 674e0b0 | 2014-03-26 13:26:52 +0100 | [diff] [blame] | 24 | endif |
| 25 | |
Paul Bakker | c7ffd36 | 2012-04-05 12:08:29 +0000 | [diff] [blame] | 26 | ifdef DEBUG |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 27 | LOCAL_CFLAGS += -g3 |
Paul Bakker | c7ffd36 | 2012-04-05 12:08:29 +0000 | [diff] [blame] | 28 | endif |
| 29 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 30 | # if we're running on Windows, build for Windows |
Paul Bakker | cd5b529 | 2012-05-10 20:49:10 +0000 | [diff] [blame] | 31 | ifdef WINDOWS |
Alon Bar-Lev | 18ba0cc | 2015-02-14 01:04:58 +0200 | [diff] [blame] | 32 | WINDOWS_BUILD=1 |
| 33 | endif |
| 34 | |
| 35 | ifdef WINDOWS_BUILD |
| 36 | DLEXT=dll |
| 37 | EXEXT=.exe |
Alon Bar-Lev | ada4105 | 2015-02-18 17:47:52 +0200 | [diff] [blame] | 38 | LOCAL_LDFLAGS += -lws2_32 |
Alon Bar-Lev | 18ba0cc | 2015-02-14 01:04:58 +0200 | [diff] [blame] | 39 | ifdef SHARED |
| 40 | SHARED_SUFFIX=.$(DLEXT) |
| 41 | endif |
Manuel Pégourié-Gonnard | 8d4a613 | 2015-06-24 12:16:20 +0200 | [diff] [blame] | 42 | else |
Andres Amaya Garcia | 420f0cc | 2018-03-27 19:17:21 +0100 | [diff] [blame] | 43 | DLEXT ?= so |
Manuel Pégourié-Gonnard | 8d4a613 | 2015-06-24 12:16:20 +0200 | [diff] [blame] | 44 | EXEXT= |
| 45 | SHARED_SUFFIX= |
Paul Bakker | cd5b529 | 2012-05-10 20:49:10 +0000 | [diff] [blame] | 46 | endif |
| 47 | |
Paul Bakker | 2770fbd | 2012-07-03 13:30:23 +0000 | [diff] [blame] | 48 | # Zlib shared library extensions: |
| 49 | ifdef ZLIB |
Alon Bar-Lev | ada4105 | 2015-02-18 17:47:52 +0200 | [diff] [blame] | 50 | LOCAL_LDFLAGS += -lz |
Paul Bakker | 2770fbd | 2012-07-03 13:30:23 +0000 | [diff] [blame] | 51 | endif |
| 52 | |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 53 | APPS = 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 | |
| 102 | BINARIES := $(addsuffix $(EXEXT),$(APPS)) |
| 103 | |
| 104 | # Look up for associated function files |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 105 | func.test_suite_aes.ecb := test_suite_aes |
| 106 | func.test_suite_aes.cbc := test_suite_aes |
| 107 | func.test_suite_aes.cfb := test_suite_aes |
| 108 | func.test_suite_aes.ofb := test_suite_aes |
| 109 | func.test_suite_aes.xts := test_suite_aes |
| 110 | func.test_suite_aes.rest := test_suite_aes |
| 111 | func.test_suite_arc4 := test_suite_arc4 |
| 112 | func.test_suite_aria := test_suite_aria |
| 113 | func.test_suite_asn1write := test_suite_asn1write |
| 114 | func.test_suite_base64 := test_suite_base64 |
| 115 | func.test_suite_blowfish := test_suite_blowfish |
| 116 | func.test_suite_camellia := test_suite_camellia |
| 117 | func.test_suite_ccm := test_suite_ccm |
| 118 | func.test_suite_chacha20 := test_suite_chacha20 |
| 119 | func.test_suite_chachapoly := test_suite_chachapoly |
| 120 | func.test_suite_cmac := test_suite_cmac |
| 121 | func.test_suite_cipher.chachapoly := test_suite_cipher |
| 122 | func.test_suite_cipher.aes := test_suite_cipher |
| 123 | func.test_suite_cipher.arc4 := test_suite_cipher |
| 124 | func.test_suite_cipher.ccm := test_suite_cipher |
| 125 | func.test_suite_cipher.chacha20 := test_suite_cipher |
| 126 | func.test_suite_cipher.gcm := test_suite_cipher |
| 127 | func.test_suite_cipher.blowfish := test_suite_cipher |
| 128 | func.test_suite_cipher.camellia := test_suite_cipher |
| 129 | func.test_suite_cipher.des := test_suite_cipher |
| 130 | func.test_suite_cipher.null := test_suite_cipher |
| 131 | func.test_suite_cipher.padding := test_suite_cipher |
| 132 | func.test_suite_ctr_drbg := test_suite_ctr_drbg |
| 133 | func.test_suite_debug := test_suite_debug |
| 134 | func.test_suite_des := test_suite_des |
| 135 | func.test_suite_dhm := test_suite_dhm |
| 136 | func.test_suite_ecdh := test_suite_ecdh |
| 137 | func.test_suite_ecdsa := test_suite_ecdsa |
| 138 | func.test_suite_ecjpake := test_suite_ecjpake |
| 139 | func.test_suite_ecp := test_suite_ecp |
| 140 | func.test_suite_error := test_suite_error |
| 141 | func.test_suite_entropy := test_suite_entropy |
| 142 | func.test_suite_gcm.aes128_de := test_suite_gcm |
| 143 | func.test_suite_gcm.aes192_de := test_suite_gcm |
| 144 | func.test_suite_gcm.aes256_de := test_suite_gcm |
| 145 | func.test_suite_gcm.aes128_en := test_suite_gcm |
| 146 | func.test_suite_gcm.aes192_en := test_suite_gcm |
| 147 | func.test_suite_gcm.aes256_en := test_suite_gcm |
| 148 | func.test_suite_gcm.camellia := test_suite_gcm |
| 149 | func.test_suite_hkdf := test_suite_hkdf |
| 150 | func.test_suite_hmac_drbg.misc := test_suite_hmac_drbg |
| 151 | func.test_suite_hmac_drbg.no_reseed := test_suite_hmac_drbg |
| 152 | func.test_suite_hmac_drbg.nopr := test_suite_hmac_drbg |
| 153 | func.test_suite_hmac_drbg.pr := test_suite_hmac_drbg |
| 154 | func.test_suite_md := test_suite_md |
| 155 | func.test_suite_mdx := test_suite_mdx |
| 156 | func.test_suite_memory_buffer_alloc := test_suite_memory_buffer_alloc |
| 157 | func.test_suite_mpi := test_suite_mpi |
| 158 | func.test_suite_nist_kw := test_suite_nist_kw |
| 159 | func.test_suite_pem := test_suite_pem |
| 160 | func.test_suite_pkcs1_v15 := test_suite_pkcs1_v15 |
| 161 | func.test_suite_pkcs1_v21 := test_suite_pkcs1_v21 |
| 162 | func.test_suite_pkcs5 := test_suite_pkcs5 |
| 163 | func.test_suite_pkparse := test_suite_pkparse |
| 164 | func.test_suite_pkwrite := test_suite_pkwrite |
| 165 | func.test_suite_pk := test_suite_pk |
| 166 | func.test_suite_rsa := test_suite_rsa |
| 167 | func.test_suite_shax := test_suite_shax |
| 168 | func.test_suite_ssl := test_suite_ssl |
| 169 | func.test_suite_timing := test_suite_timing |
| 170 | func.test_suite_x509parse := test_suite_x509parse |
| 171 | func.test_suite_x509write := test_suite_x509write |
| 172 | func.test_suite_xtea := test_suite_xtea |
| 173 | func.test_suite_version := test_suite_version |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 174 | |
| 175 | .SILENT: |
| 176 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 177 | .PHONY: all check test clean |
| 178 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 179 | $(DEP): |
Manuel Pégourié-Gonnard | fc36708 | 2015-06-26 16:50:24 +0200 | [diff] [blame] | 180 | $(MAKE) -C ../library |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 181 | |
Manuel Pégourié-Gonnard | 6cacde2 | 2015-07-08 16:02:43 +0200 | [diff] [blame] | 182 | # invoke perl explicitly for the sake of mingw32-make |
| 183 | |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 184 | C_FILES := $(addsuffix .c,$(APPS)) |
| 185 | |
| 186 | .SECONDEXPANSION: |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 187 | $(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é-Gonnard | 78ec2b0 | 2015-07-08 22:12:06 +0100 | [diff] [blame] | 188 | echo " Gen $@" |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 189 | # 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 Bakker | 286bf3c | 2013-04-08 18:09:51 +0200 | [diff] [blame] | 197 | |
Paul Bakker | 286bf3c | 2013-04-08 18:09:51 +0200 | [diff] [blame] | 198 | |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 199 | $(BINARIES): %$(EXEXT): %.c $(DEP) |
Manuel Pégourié-Gonnard | 78ec2b0 | 2015-07-08 22:12:06 +0100 | [diff] [blame] | 200 | echo " CC $<" |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 201 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ |
Paul Bakker | 286bf3c | 2013-04-08 18:09:51 +0200 | [diff] [blame] | 202 | |
Paul Bakker | 286bf3c | 2013-04-08 18:09:51 +0200 | [diff] [blame] | 203 | |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 204 | all: $(BINARIES) |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 205 | |
Markku-Juhani O. Saarinen | 8df81e0 | 2017-12-01 14:26:40 +0000 | [diff] [blame] | 206 | |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 207 | clean: |
Paul Bakker | 62f88dc | 2012-05-10 21:26:28 +0000 | [diff] [blame] | 208 | ifndef WINDOWS |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 209 | rm -rf $(APPS) *.c *.data TESTS |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 210 | else |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 211 | del /Q /F *.c *.exe *.data |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 212 | rmdir /Q /S TESTS |
Paul Bakker | 62f88dc | 2012-05-10 21:26:28 +0000 | [diff] [blame] | 213 | endif |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 214 | |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 215 | check: $(BINARIES) |
Manuel Pégourié-Gonnard | 8511384 | 2015-07-08 21:20:03 +0100 | [diff] [blame] | 216 | perl scripts/run-test-suites.pl |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 217 | |
| 218 | test: check |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 219 | |
| 220 | # Create separate targets for generating mbed-os tests. |
| 221 | MBED_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 Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 231 | $(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 Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 233 | python scripts/gen_mbed_code.py -f suites/$(func.$*).function \ |
| 234 | -d suites/$*.data \ |
| 235 | -t suites/mbed_test.function \ |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 236 | -p suites/embedded_test.function \ |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 237 | -s suites \ |
| 238 | --help-file suites/helpers.function \ |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 239 | -o ./TESTS/mbedtls/$* |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 240 | |
| 241 | gen-mbed-test: $(MBED_APPS) |
| 242 | |