/source/polarssl/tests/Makefile

https://bitbucket.org/nqminh/filagree · Makefile · 341 lines · 262 code · 75 blank · 4 comment · 5 complexity · b05355998dbb0d54a0f0f37701c39c27 MD5 · raw file

  1. # To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
  2. # To compile on MinGW: add "-lws2_32" to LDFLAGS or define WINDOWS in your env
  3. # To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS
  4. CFLAGS += -I../include -D_FILE_OFFSET_BITS=64 -Wall -W -Wdeclaration-after-statement \
  5. -Wno-unused-function -Wno-unused-value
  6. OFLAGS = -O2
  7. LDFLAGS += -L../library -lpolarssl $(SYS_LDFLAGS)
  8. ifdef DEBUG
  9. CFLAGS += -g3
  10. endif
  11. ifdef WINDOWS
  12. LDFLAGS += -lws2_32
  13. endif
  14. # Zlib shared library extensions:
  15. ifdef ZLIB
  16. LDFLAGS += -lz
  17. endif
  18. APPS = test_suite_aes.ecb test_suite_aes.cbc \
  19. test_suite_aes.cfb test_suite_aes.rest \
  20. test_suite_arc4 \
  21. test_suite_base64 test_suite_blowfish \
  22. test_suite_camellia test_suite_cipher.aes \
  23. test_suite_cipher.arc4 test_suite_cipher.gcm \
  24. test_suite_cipher.blowfish \
  25. test_suite_cipher.camellia \
  26. test_suite_cipher.des test_suite_cipher.null \
  27. test_suite_cipher.padding \
  28. test_suite_ctr_drbg test_suite_debug \
  29. test_suite_des test_suite_dhm \
  30. test_suite_ecdh test_suite_ecdsa \
  31. test_suite_ecp \
  32. test_suite_error \
  33. test_suite_gcm.decrypt_128 \
  34. test_suite_gcm.decrypt_192 \
  35. test_suite_gcm.decrypt_256 \
  36. test_suite_gcm.encrypt_128 \
  37. test_suite_gcm.encrypt_192 \
  38. test_suite_gcm.encrypt_256 \
  39. test_suite_hmac_shax \
  40. test_suite_md test_suite_mdx \
  41. test_suite_mpi test_suite_pbkdf2 \
  42. test_suite_pkcs1_v21 test_suite_pkcs5 \
  43. test_suite_pkparse test_suite_pkwrite \
  44. test_suite_rsa test_suite_shax \
  45. test_suite_x509parse test_suite_x509write \
  46. test_suite_xtea test_suite_version
  47. .SILENT:
  48. all: $(APPS)
  49. test_suite_aes.ecb.c : suites/test_suite_aes.function suites/test_suite_aes.ecb.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  50. echo " Generate $@"
  51. scripts/generate_code.pl suites test_suite_aes test_suite_aes.ecb
  52. test_suite_aes.cbc.c : suites/test_suite_aes.function suites/test_suite_aes.cbc.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  53. echo " Generate $@"
  54. scripts/generate_code.pl suites test_suite_aes test_suite_aes.cbc
  55. test_suite_aes.cfb.c : suites/test_suite_aes.function suites/test_suite_aes.cfb.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  56. echo " Generate $@"
  57. scripts/generate_code.pl suites test_suite_aes test_suite_aes.cfb
  58. test_suite_aes.rest.c : suites/test_suite_aes.function suites/test_suite_aes.rest.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  59. echo " Generate $@"
  60. scripts/generate_code.pl suites test_suite_aes test_suite_aes.rest
  61. test_suite_cipher.aes.c : suites/test_suite_cipher.function suites/test_suite_cipher.aes.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  62. echo " Generate $@"
  63. scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
  64. test_suite_cipher.arc4.c : suites/test_suite_cipher.function suites/test_suite_cipher.arc4.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  65. echo " Generate $@"
  66. scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.arc4
  67. test_suite_cipher.gcm.c : suites/test_suite_cipher.function suites/test_suite_cipher.gcm.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  68. echo " Generate $@"
  69. scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.gcm
  70. test_suite_cipher.blowfish.c : suites/test_suite_cipher.function suites/test_suite_cipher.blowfish.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  71. echo " Generate $@"
  72. scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.blowfish
  73. test_suite_cipher.camellia.c : suites/test_suite_cipher.function suites/test_suite_cipher.camellia.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  74. echo " Generate $@"
  75. scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.camellia
  76. test_suite_cipher.des.c : suites/test_suite_cipher.function suites/test_suite_cipher.des.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  77. echo " Generate $@"
  78. scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.des
  79. test_suite_cipher.null.c : suites/test_suite_cipher.function suites/test_suite_cipher.null.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  80. echo " Generate $@"
  81. scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.null
  82. test_suite_cipher.padding.c : suites/test_suite_cipher.function suites/test_suite_cipher.padding.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  83. echo " Generate $@"
  84. scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.padding
  85. test_suite_gcm.decrypt_128.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_128.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  86. echo " Generate $@"
  87. scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_128
  88. test_suite_gcm.decrypt_192.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_192.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  89. echo " Generate $@"
  90. scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_192
  91. test_suite_gcm.decrypt_256.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_256.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  92. echo " Generate $@"
  93. scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_256
  94. test_suite_gcm.encrypt_128.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_128.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  95. echo " Generate $@"
  96. scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_128
  97. test_suite_gcm.encrypt_192.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_192.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  98. echo " Generate $@"
  99. scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_192
  100. test_suite_gcm.encrypt_256.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_256.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  101. echo " Generate $@"
  102. scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_256
  103. %.c : suites/%.function suites/%.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
  104. echo " Generate $@"
  105. scripts/generate_code.pl suites $* $*
  106. test_suite_aes.ecb: test_suite_aes.ecb.c ../library/libpolarssl.a
  107. echo " CC $@.c"
  108. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  109. test_suite_aes.cbc: test_suite_aes.cbc.c ../library/libpolarssl.a
  110. echo " CC $@.c"
  111. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  112. test_suite_aes.cfb: test_suite_aes.cfb.c ../library/libpolarssl.a
  113. echo " CC $@.c"
  114. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  115. test_suite_aes.rest: test_suite_aes.rest.c ../library/libpolarssl.a
  116. echo " CC $@.c"
  117. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  118. test_suite_arc4: test_suite_arc4.c ../library/libpolarssl.a
  119. echo " CC $@.c"
  120. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  121. test_suite_base64: test_suite_base64.c ../library/libpolarssl.a
  122. echo " CC $@.c"
  123. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  124. test_suite_blowfish: test_suite_blowfish.c ../library/libpolarssl.a
  125. echo " CC $@.c"
  126. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  127. test_suite_camellia: test_suite_camellia.c ../library/libpolarssl.a
  128. echo " CC $@.c"
  129. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  130. test_suite_cipher.aes: test_suite_cipher.aes.c ../library/libpolarssl.a
  131. echo " CC $@.c"
  132. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  133. test_suite_cipher.arc4: test_suite_cipher.arc4.c ../library/libpolarssl.a
  134. echo " CC $@.c"
  135. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  136. test_suite_cipher.gcm: test_suite_cipher.gcm.c ../library/libpolarssl.a
  137. echo " CC $@.c"
  138. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  139. test_suite_cipher.blowfish: test_suite_cipher.blowfish.c ../library/libpolarssl.a
  140. echo " CC $@.c"
  141. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  142. test_suite_cipher.camellia: test_suite_cipher.camellia.c ../library/libpolarssl.a
  143. echo " CC $@.c"
  144. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  145. test_suite_cipher.des: test_suite_cipher.des.c ../library/libpolarssl.a
  146. echo " CC $@.c"
  147. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  148. test_suite_cipher.null: test_suite_cipher.null.c ../library/libpolarssl.a
  149. echo " CC $@.c"
  150. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  151. test_suite_cipher.padding: test_suite_cipher.padding.c ../library/libpolarssl.a
  152. echo " CC $@.c"
  153. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  154. test_suite_ctr_drbg: test_suite_ctr_drbg.c ../library/libpolarssl.a
  155. echo " CC $@.c"
  156. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  157. test_suite_des: test_suite_des.c ../library/libpolarssl.a
  158. echo " CC $@.c"
  159. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  160. test_suite_dhm: test_suite_dhm.c ../library/libpolarssl.a
  161. echo " CC $@.c"
  162. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  163. test_suite_ecdh: test_suite_ecdh.c ../library/libpolarssl.a
  164. echo " CC $@.c"
  165. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  166. test_suite_ecdsa: test_suite_ecdsa.c ../library/libpolarssl.a
  167. echo " CC $@.c"
  168. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  169. test_suite_ecp: test_suite_ecp.c ../library/libpolarssl.a
  170. echo " CC $@.c"
  171. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  172. test_suite_error: test_suite_error.c ../library/libpolarssl.a
  173. echo " CC $@.c"
  174. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  175. test_suite_gcm.decrypt_128: test_suite_gcm.decrypt_128.c ../library/libpolarssl.a
  176. echo " CC $@.c"
  177. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  178. test_suite_gcm.decrypt_192: test_suite_gcm.decrypt_192.c ../library/libpolarssl.a
  179. echo " CC $@.c"
  180. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  181. test_suite_gcm.decrypt_256: test_suite_gcm.decrypt_256.c ../library/libpolarssl.a
  182. echo " CC $@.c"
  183. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  184. test_suite_gcm.encrypt_128: test_suite_gcm.encrypt_128.c ../library/libpolarssl.a
  185. echo " CC $@.c"
  186. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  187. test_suite_gcm.encrypt_192: test_suite_gcm.encrypt_192.c ../library/libpolarssl.a
  188. echo " CC $@.c"
  189. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  190. test_suite_gcm.encrypt_256: test_suite_gcm.encrypt_256.c ../library/libpolarssl.a
  191. echo " CC $@.c"
  192. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  193. test_suite_hmac_shax: test_suite_hmac_shax.c ../library/libpolarssl.a
  194. echo " CC $@.c"
  195. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  196. test_suite_md: test_suite_md.c ../library/libpolarssl.a
  197. echo " CC $@.c"
  198. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  199. test_suite_mdx: test_suite_mdx.c ../library/libpolarssl.a
  200. echo " CC $@.c"
  201. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  202. test_suite_mpi: test_suite_mpi.c ../library/libpolarssl.a
  203. echo " CC $@.c"
  204. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  205. test_suite_pbkdf2: test_suite_pbkdf2.c ../library/libpolarssl.a
  206. echo " CC $@.c"
  207. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  208. test_suite_pkcs1_v21: test_suite_pkcs1_v21.c ../library/libpolarssl.a
  209. echo " CC $@.c"
  210. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  211. test_suite_pkcs5: test_suite_pkcs5.c ../library/libpolarssl.a
  212. echo " CC $@.c"
  213. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  214. test_suite_pkparse: test_suite_pkparse.c ../library/libpolarssl.a
  215. echo " CC $@.c"
  216. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  217. test_suite_pkwrite: test_suite_pkwrite.c ../library/libpolarssl.a
  218. echo " CC $@.c"
  219. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  220. test_suite_rsa: test_suite_rsa.c ../library/libpolarssl.a
  221. echo " CC $@.c"
  222. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  223. test_suite_shax: test_suite_shax.c ../library/libpolarssl.a
  224. echo " CC $@.c"
  225. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  226. test_suite_x509parse: test_suite_x509parse.c ../library/libpolarssl.a
  227. echo " CC $@.c"
  228. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  229. test_suite_x509write: test_suite_x509write.c ../library/libpolarssl.a
  230. echo " CC $@.c"
  231. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  232. test_suite_xtea: test_suite_xtea.c ../library/libpolarssl.a
  233. echo " CC $@.c"
  234. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  235. test_suite_debug: test_suite_debug.c ../library/libpolarssl.a
  236. echo " CC $@.c"
  237. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  238. test_suite_version: test_suite_version.c ../library/libpolarssl.a
  239. echo " CC $@.c"
  240. $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
  241. clean:
  242. ifndef WINDOWS
  243. rm -f $(APPS) *.c
  244. endif
  245. ifdef WINDOWS
  246. del /Q /F *.c *.exe
  247. endif
  248. check: $(APPS)
  249. ifndef WINDOWS
  250. echo "Running checks (Success if all tests PASSED)"
  251. RETURN=0; \
  252. for i in $(APPS); \
  253. do \
  254. echo " - $${i}"; \
  255. RESULT=`./$${i} | grep -v 'PASS$$' | grep -v -- '----' | grep -v '^$$'`; \
  256. FAILED=`echo $$RESULT |grep FAILED`; \
  257. echo " $$RESULT"; \
  258. if [ "$$FAILED" != "" ]; \
  259. then \
  260. echo "**** Failed ***************"; \
  261. RETURN=1; \
  262. fi; \
  263. echo ""; \
  264. done; \
  265. if [ "$$RETURN" -eq 1 ]; then exit 1; fi
  266. endif