blob: 1cca81830e1ebb6868cdb7de84b6d56e184d688f [file] [log] [blame]
Paul Bakkerb06819b2011-01-18 16:18:38 +00001set(libs
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +02002 mbedtls
Paul Bakkerb06819b2011-01-18 16:18:38 +00003)
4
5if(USE_PKCS11_HELPER_LIBRARY)
6 set(libs ${libs} pkcs11-helper)
7endif(USE_PKCS11_HELPER_LIBRARY)
8
Paul Bakker92eeea42012-07-03 15:10:33 +00009if(ENABLE_ZLIB_SUPPORT)
10 set(libs ${libs} ${ZLIB_LIBRARIES})
11endif(ENABLE_ZLIB_SUPPORT)
12
Paul Bakker73043762011-07-13 15:03:10 +000013function(add_test_suite suite_name)
14 if(ARGV1)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020015 set(data_name ${ARGV1})
Paul Bakker73043762011-07-13 15:03:10 +000016 else()
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020017 set(data_name ${suite_name})
Paul Bakker46c17942011-07-13 14:54:54 +000018 endif()
19
Paul Bakker367dae42009-06-28 21:50:27 +000020 add_custom_command(
Paul Bakker73043762011-07-13 15:03:10 +000021 OUTPUT test_suite_${data_name}.c
Paul Bakker46c17942011-07-13 14:54:54 +000022 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.pl ${CMAKE_CURRENT_SOURCE_DIR}/suites test_suite_${suite_name} test_suite_${data_name}
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +000023 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.pl mbedtls suites/helpers.function suites/main_test.function suites/test_suite_${suite_name}.function suites/test_suite_${data_name}.data
Paul Bakker4c14a252010-06-18 22:54:05 +000024 )
Paul Bakker19343182013-08-16 13:31:10 +020025
Paul Bakker4c14a252010-06-18 22:54:05 +000026 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
Paul Bakker73043762011-07-13 15:03:10 +000027 add_executable(test_suite_${data_name} test_suite_${data_name}.c)
28 target_link_libraries(test_suite_${data_name} ${libs})
29 add_test(${data_name}-suite test_suite_${data_name})
Paul Bakker367dae42009-06-28 21:50:27 +000030endfunction(add_test_suite)
31
Manuel Pégourié-Gonnard7e2d68c2015-07-01 13:41:35 +020032if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
33 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
34endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
Paul Bakker367dae42009-06-28 21:50:27 +000035
Manuel Pégourié-Gonnard30830532015-07-01 17:06:28 +020036if(MSVC)
37 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w") # no warnings here
38endif(MSVC)
39
Paul Bakker286bf3c2013-04-08 18:09:51 +020040add_test_suite(aes aes.ecb)
41add_test_suite(aes aes.cbc)
42add_test_suite(aes aes.cfb)
43add_test_suite(aes aes.rest)
Paul Bakker367dae42009-06-28 21:50:27 +000044add_test_suite(arc4)
Manuel Pégourié-Gonnard36178ff2014-05-29 14:26:03 +020045add_test_suite(asn1write)
Paul Bakker9d781402011-05-09 16:17:09 +000046add_test_suite(base64)
Paul Bakkera9379c02012-07-04 11:02:11 +000047add_test_suite(blowfish)
Paul Bakker9d781402011-05-09 16:17:09 +000048add_test_suite(camellia)
Manuel Pégourié-Gonnarda6916fa2014-05-02 15:17:29 +020049add_test_suite(ccm)
Paul Bakker46c17942011-07-13 14:54:54 +000050add_test_suite(cipher cipher.aes)
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +020051add_test_suite(cipher cipher.arc4)
Paul Bakker6132d0a2012-07-04 17:10:40 +000052add_test_suite(cipher cipher.blowfish)
Paul Bakker46c17942011-07-13 14:54:54 +000053add_test_suite(cipher cipher.camellia)
Manuel Pégourié-Gonnard542eac52014-05-15 16:03:07 +020054add_test_suite(cipher cipher.ccm)
Paul Bakker46c17942011-07-13 14:54:54 +000055add_test_suite(cipher cipher.des)
Manuel Pégourié-Gonnard07f8fa52013-08-30 18:34:08 +020056add_test_suite(cipher cipher.gcm)
Paul Bakkerfab5c822012-02-06 16:45:10 +000057add_test_suite(cipher cipher.null)
Manuel Pégourié-Gonnardd5fdcaf2013-07-24 18:05:00 +020058add_test_suite(cipher cipher.padding)
Paul Bakker0e04d0e2011-11-27 14:46:59 +000059add_test_suite(ctr_drbg)
Paul Bakker9d781402011-05-09 16:17:09 +000060add_test_suite(debug)
61add_test_suite(des)
62add_test_suite(dhm)
Manuel Pégourié-Gonnard61ce13b2013-01-26 16:20:32 +010063add_test_suite(ecdh)
Manuel Pégourié-Gonnardd1c71502013-01-26 19:09:07 +010064add_test_suite(ecdsa)
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +020065add_test_suite(ecjpake)
66add_test_suite(ecp)
Manuel Pégourié-Gonnard2c25eb02014-05-30 10:38:18 +020067add_test_suite(entropy)
Paul Bakker9d781402011-05-09 16:17:09 +000068add_test_suite(error)
Manuel Pégourié-Gonnard94dd5b42013-10-24 11:57:47 +020069add_test_suite(gcm gcm.aes128_en)
70add_test_suite(gcm gcm.aes192_en)
71add_test_suite(gcm gcm.aes256_en)
72add_test_suite(gcm gcm.aes128_de)
73add_test_suite(gcm gcm.aes192_de)
74add_test_suite(gcm gcm.aes256_de)
Manuel Pégourié-Gonnard13e0d442013-10-24 12:59:00 +020075add_test_suite(gcm gcm.camellia)
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +010076add_test_suite(hmac_drbg hmac_drbg.misc)
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +010077add_test_suite(hmac_drbg hmac_drbg.no_reseed)
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +010078add_test_suite(hmac_drbg hmac_drbg.nopr)
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +010079add_test_suite(hmac_drbg hmac_drbg.pr)
Paul Bakker17373852011-01-06 14:20:01 +000080add_test_suite(md)
Paul Bakker9d781402011-05-09 16:17:09 +000081add_test_suite(mdx)
Manuel Pégourié-Gonnard765bb312014-11-27 11:55:27 +010082add_test_suite(memory_buffer_alloc)
Paul Bakker9d781402011-05-09 16:17:09 +000083add_test_suite(mpi)
Paul Bakker16300582014-04-11 13:28:43 +020084add_test_suite(pem)
Paul Bakker9dcc3222011-03-08 14:16:06 +000085add_test_suite(pkcs1_v21)
Paul Bakkerb0c19a42013-06-24 19:26:38 +020086add_test_suite(pkcs5)
Manuel Pégourié-Gonnardb0a467f2013-09-21 12:31:05 +020087add_test_suite(pk)
Paul Bakker1a7550a2013-09-15 13:01:22 +020088add_test_suite(pkparse)
Paul Bakkerc7bb02b2013-09-15 14:54:56 +020089add_test_suite(pkwrite)
Paul Bakker9d781402011-05-09 16:17:09 +000090add_test_suite(shax)
Manuel Pégourié-Gonnard4956fd72014-09-24 11:13:44 +020091add_test_suite(ssl)
Paul Bakker9d781402011-05-09 16:17:09 +000092add_test_suite(rsa)
93add_test_suite(version)
94add_test_suite(xtea)
95add_test_suite(x509parse)
Paul Bakker6d620502012-02-16 14:09:13 +000096add_test_suite(x509write)
Paul Bakkercd6d69a2014-02-06 15:43:21 +010097
98# Make data_files available in an out-of-source build
99if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
100 # Get OS dependent path to use in `execute_process`
101 file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/data_files" link)
102 file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/data_files" target)
103
Paul Bakker3d52ab72014-03-07 10:33:55 +0100104 if (NOT EXISTS ${link})
Andre Heineckef7ced922014-05-21 10:25:51 +0000105 if (CMAKE_HOST_UNIX)
Paul Bakker3d52ab72014-03-07 10:33:55 +0100106 set(command ln -s ${target} ${link})
107 else()
Manuel Pégourié-Gonnard89eb1972015-07-08 21:39:43 +0100108 set(command cmd.exe /c mklink /d ${link} ${target})
Paul Bakker3d52ab72014-03-07 10:33:55 +0100109 endif()
Paul Bakkercd6d69a2014-02-06 15:43:21 +0100110
Paul Bakker3d52ab72014-03-07 10:33:55 +0100111 execute_process(COMMAND ${command}
112 RESULT_VARIABLE result
113 ERROR_VARIABLE output)
Paul Bakkercd6d69a2014-02-06 15:43:21 +0100114
Paul Bakker3d52ab72014-03-07 10:33:55 +0100115 if (NOT ${result} EQUAL 0)
116 message(FATAL_ERROR "Could not create symbolic link for: ${target} --> ${output}")
117 endif()
Paul Bakkercd6d69a2014-02-06 15:43:21 +0100118 endif()
119endif()
120