| 1 | set(libs
|
|---|
| 2 | mbedtls
|
|---|
| 3 | )
|
|---|
| 4 |
|
|---|
| 5 | if(USE_PKCS11_HELPER_LIBRARY)
|
|---|
| 6 | set(libs ${libs} pkcs11-helper)
|
|---|
| 7 | endif(USE_PKCS11_HELPER_LIBRARY)
|
|---|
| 8 |
|
|---|
| 9 | if(ENABLE_ZLIB_SUPPORT)
|
|---|
| 10 | set(libs ${libs} ${ZLIB_LIBRARIES})
|
|---|
| 11 | endif(ENABLE_ZLIB_SUPPORT)
|
|---|
| 12 |
|
|---|
| 13 | function(add_test_suite suite_name)
|
|---|
| 14 | if(ARGV1)
|
|---|
| 15 | set(data_name ${ARGV1})
|
|---|
| 16 | else()
|
|---|
| 17 | set(data_name ${suite_name})
|
|---|
| 18 | endif()
|
|---|
| 19 |
|
|---|
| 20 | add_custom_command(
|
|---|
| 21 | OUTPUT test_suite_${data_name}.c
|
|---|
| 22 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.pl ${CMAKE_CURRENT_SOURCE_DIR}/suites test_suite_${suite_name} test_suite_${data_name}
|
|---|
| 23 | 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
|
|---|
| 24 | )
|
|---|
| 25 |
|
|---|
| 26 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|---|
| 27 | 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})
|
|---|
| 30 | endfunction(add_test_suite)
|
|---|
| 31 |
|
|---|
| 32 | if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
|---|
| 33 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
|---|
| 34 | endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
|---|
| 35 |
|
|---|
| 36 | if(MSVC)
|
|---|
| 37 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w") # no warnings here
|
|---|
| 38 | endif(MSVC)
|
|---|
| 39 |
|
|---|
| 40 | add_test_suite(aes aes.ecb)
|
|---|
| 41 | add_test_suite(aes aes.cbc)
|
|---|
| 42 | add_test_suite(aes aes.cfb)
|
|---|
| 43 | add_test_suite(aes aes.rest)
|
|---|
| 44 | add_test_suite(arc4)
|
|---|
| 45 | add_test_suite(asn1write)
|
|---|
| 46 | add_test_suite(base64)
|
|---|
| 47 | add_test_suite(blowfish)
|
|---|
| 48 | add_test_suite(camellia)
|
|---|
| 49 | add_test_suite(ccm)
|
|---|
| 50 | add_test_suite(cipher cipher.aes)
|
|---|
| 51 | add_test_suite(cipher cipher.arc4)
|
|---|
| 52 | add_test_suite(cipher cipher.blowfish)
|
|---|
| 53 | add_test_suite(cipher cipher.camellia)
|
|---|
| 54 | add_test_suite(cipher cipher.ccm)
|
|---|
| 55 | add_test_suite(cipher cipher.des)
|
|---|
| 56 | add_test_suite(cipher cipher.gcm)
|
|---|
| 57 | add_test_suite(cipher cipher.null)
|
|---|
| 58 | add_test_suite(cipher cipher.padding)
|
|---|
| 59 | add_test_suite(ctr_drbg)
|
|---|
| 60 | add_test_suite(debug)
|
|---|
| 61 | add_test_suite(des)
|
|---|
| 62 | add_test_suite(dhm)
|
|---|
| 63 | add_test_suite(ecdh)
|
|---|
| 64 | add_test_suite(ecdsa)
|
|---|
| 65 | add_test_suite(ecjpake)
|
|---|
| 66 | add_test_suite(ecp)
|
|---|
| 67 | add_test_suite(entropy)
|
|---|
| 68 | add_test_suite(error)
|
|---|
| 69 | add_test_suite(gcm gcm.aes128_en)
|
|---|
| 70 | add_test_suite(gcm gcm.aes192_en)
|
|---|
| 71 | add_test_suite(gcm gcm.aes256_en)
|
|---|
| 72 | add_test_suite(gcm gcm.aes128_de)
|
|---|
| 73 | add_test_suite(gcm gcm.aes192_de)
|
|---|
| 74 | add_test_suite(gcm gcm.aes256_de)
|
|---|
| 75 | add_test_suite(gcm gcm.camellia)
|
|---|
| 76 | add_test_suite(hmac_drbg hmac_drbg.misc)
|
|---|
| 77 | add_test_suite(hmac_drbg hmac_drbg.no_reseed)
|
|---|
| 78 | add_test_suite(hmac_drbg hmac_drbg.nopr)
|
|---|
| 79 | add_test_suite(hmac_drbg hmac_drbg.pr)
|
|---|
| 80 | add_test_suite(md)
|
|---|
| 81 | add_test_suite(mdx)
|
|---|
| 82 | add_test_suite(memory_buffer_alloc)
|
|---|
| 83 | add_test_suite(mpi)
|
|---|
| 84 | add_test_suite(pem)
|
|---|
| 85 | add_test_suite(pkcs1_v21)
|
|---|
| 86 | add_test_suite(pkcs5)
|
|---|
| 87 | add_test_suite(pk)
|
|---|
| 88 | add_test_suite(pkparse)
|
|---|
| 89 | add_test_suite(pkwrite)
|
|---|
| 90 | add_test_suite(shax)
|
|---|
| 91 | add_test_suite(ssl)
|
|---|
| 92 | add_test_suite(rsa)
|
|---|
| 93 | add_test_suite(version)
|
|---|
| 94 | add_test_suite(xtea)
|
|---|
| 95 | add_test_suite(x509parse)
|
|---|
| 96 | add_test_suite(x509write)
|
|---|
| 97 |
|
|---|
| 98 | # Make data_files available in an out-of-source build
|
|---|
| 99 | if (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 |
|
|---|
| 104 | if (NOT EXISTS ${link})
|
|---|
| 105 | if (CMAKE_HOST_UNIX)
|
|---|
| 106 | set(command ln -s ${target} ${link})
|
|---|
| 107 | else()
|
|---|
| 108 | set(command cmd.exe /c mklink /d ${link} ${target})
|
|---|
| 109 | endif()
|
|---|
| 110 |
|
|---|
| 111 | execute_process(COMMAND ${command}
|
|---|
| 112 | RESULT_VARIABLE result
|
|---|
| 113 | ERROR_VARIABLE output)
|
|---|
| 114 |
|
|---|
| 115 | if (NOT ${result} EQUAL 0)
|
|---|
| 116 | message(FATAL_ERROR "Could not create symbolic link for: ${target} --> ${output}")
|
|---|
| 117 | endif()
|
|---|
| 118 | endif()
|
|---|
| 119 | endif()
|
|---|
| 120 |
|
|---|