diff --git a/BUILDING.md b/BUILDING.md index 99adbfd1c..cc0ee0ed9 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -122,6 +122,9 @@ are built by Ninja and can be run from the top-level directory with `go run util/all_tests.go`. The latter have to be run separately by running `go test` from within `ssl/test/runner`. +Both sets of tests may also be run with `ninja -C build run_tests`, but CMake +3.2 or later is required to avoid Ninja's output buffering. + [1]: http://www.cmake.org/download/ [2]: http://strawberryperl.com/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 38dfe450a..d0ccd6b98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,8 +137,27 @@ if (OPENSSL_NO_ASM) set(ARCH "generic") endif() +# Declare a dummy target to build all unit tests. Test targets should inject +# themselves as dependencies next to the target definition. +add_custom_target(all_tests) + add_subdirectory(crypto) add_subdirectory(ssl) add_subdirectory(ssl/test) add_subdirectory(tool) add_subdirectory(decrepit) + +if (NOT ${CMAKE_VERSION} VERSION_LESS "3.2") + # USES_TERMINAL is only available in CMake 3.2 or later. + set(MAYBE_USES_TERMINAL USES_TERMINAL) +endif() + +add_custom_target( + run_tests + COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir + ${CMAKE_BINARY_DIR} + COMMAND cd ssl/test/runner + COMMAND ${GO_EXECUTABLE} test -shim-path $ + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS all_tests bssl_shim + ${MAYBE_USES_TERMINAL}) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 3115279f6..89f4ce5b7 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -210,6 +210,7 @@ add_executable( ) target_link_libraries(constant_time_test crypto) +add_dependencies(all_tests constant_time_test) add_executable( thread_test @@ -220,6 +221,7 @@ add_executable( ) target_link_libraries(thread_test crypto) +add_dependencies(all_tests thread_test) add_executable( refcount_test @@ -228,3 +230,4 @@ add_executable( ) target_link_libraries(refcount_test crypto) +add_dependencies(all_tests refcount_test) diff --git a/crypto/aes/CMakeLists.txt b/crypto/aes/CMakeLists.txt index c82d99abd..0566e3989 100644 --- a/crypto/aes/CMakeLists.txt +++ b/crypto/aes/CMakeLists.txt @@ -69,3 +69,4 @@ add_executable( ) target_link_libraries(aes_test crypto) +add_dependencies(all_tests aes_test) diff --git a/crypto/base64/CMakeLists.txt b/crypto/base64/CMakeLists.txt index f1dba6cbf..15ee6916f 100644 --- a/crypto/base64/CMakeLists.txt +++ b/crypto/base64/CMakeLists.txt @@ -17,3 +17,4 @@ add_executable( ) target_link_libraries(base64_test crypto) +add_dependencies(all_tests base64_test) diff --git a/crypto/bio/CMakeLists.txt b/crypto/bio/CMakeLists.txt index 8de090af8..7859b58de 100644 --- a/crypto/bio/CMakeLists.txt +++ b/crypto/bio/CMakeLists.txt @@ -30,3 +30,4 @@ target_link_libraries(bio_test crypto) if (WIN32) target_link_libraries(bio_test ws2_32) endif() +add_dependencies(all_tests bio_test) diff --git a/crypto/bn/CMakeLists.txt b/crypto/bn/CMakeLists.txt index 232e40aef..b7130d7e1 100644 --- a/crypto/bn/CMakeLists.txt +++ b/crypto/bn/CMakeLists.txt @@ -76,3 +76,4 @@ add_executable( ) target_link_libraries(bn_test crypto) +add_dependencies(all_tests bn_test) diff --git a/crypto/bytestring/CMakeLists.txt b/crypto/bytestring/CMakeLists.txt index 3462aee62..33d3c217e 100644 --- a/crypto/bytestring/CMakeLists.txt +++ b/crypto/bytestring/CMakeLists.txt @@ -19,3 +19,4 @@ add_executable( ) target_link_libraries(bytestring_test crypto) +add_dependencies(all_tests bytestring_test) diff --git a/crypto/cipher/CMakeLists.txt b/crypto/cipher/CMakeLists.txt index 6b4c729da..52b87b66e 100644 --- a/crypto/cipher/CMakeLists.txt +++ b/crypto/cipher/CMakeLists.txt @@ -37,3 +37,4 @@ add_executable( target_link_libraries(cipher_test crypto) target_link_libraries(aead_test crypto) +add_dependencies(all_tests cipher_test aead_test) diff --git a/crypto/cmac/CMakeLists.txt b/crypto/cmac/CMakeLists.txt index bb3abc3b3..a346b248c 100644 --- a/crypto/cmac/CMakeLists.txt +++ b/crypto/cmac/CMakeLists.txt @@ -17,3 +17,4 @@ add_executable( ) target_link_libraries(cmac_test crypto) +add_dependencies(all_tests cmac_test) diff --git a/crypto/dh/CMakeLists.txt b/crypto/dh/CMakeLists.txt index 1a465128a..8ddf03da8 100644 --- a/crypto/dh/CMakeLists.txt +++ b/crypto/dh/CMakeLists.txt @@ -21,3 +21,4 @@ add_executable( ) target_link_libraries(dh_test crypto) +add_dependencies(all_tests dh_test) diff --git a/crypto/digest/CMakeLists.txt b/crypto/digest/CMakeLists.txt index 856e45a50..7a68f6fe0 100644 --- a/crypto/digest/CMakeLists.txt +++ b/crypto/digest/CMakeLists.txt @@ -18,3 +18,4 @@ add_executable( ) target_link_libraries(digest_test crypto) +add_dependencies(all_tests digest_test) diff --git a/crypto/dsa/CMakeLists.txt b/crypto/dsa/CMakeLists.txt index e8b7793ae..654f18cd0 100644 --- a/crypto/dsa/CMakeLists.txt +++ b/crypto/dsa/CMakeLists.txt @@ -19,3 +19,4 @@ add_executable( ) target_link_libraries(dsa_test crypto) +add_dependencies(all_tests dsa_test) diff --git a/crypto/ec/CMakeLists.txt b/crypto/ec/CMakeLists.txt index 2b767590f..9808cd510 100644 --- a/crypto/ec/CMakeLists.txt +++ b/crypto/ec/CMakeLists.txt @@ -35,3 +35,4 @@ add_executable( target_link_libraries(example_mul crypto) target_link_libraries(ec_test crypto) +add_dependencies(all_tests example_mul ec_test) diff --git a/crypto/ecdsa/CMakeLists.txt b/crypto/ecdsa/CMakeLists.txt index e7581be10..0cc672e8b 100644 --- a/crypto/ecdsa/CMakeLists.txt +++ b/crypto/ecdsa/CMakeLists.txt @@ -19,3 +19,4 @@ add_executable( ) target_link_libraries(ecdsa_test crypto) +add_dependencies(all_tests ecdsa_test) diff --git a/crypto/err/CMakeLists.txt b/crypto/err/CMakeLists.txt index 8519e51aa..a095b542c 100644 --- a/crypto/err/CMakeLists.txt +++ b/crypto/err/CMakeLists.txt @@ -47,3 +47,4 @@ add_executable( ) target_link_libraries(err_test crypto) +add_dependencies(all_tests err_test) diff --git a/crypto/evp/CMakeLists.txt b/crypto/evp/CMakeLists.txt index 5d2e918fc..000f07629 100644 --- a/crypto/evp/CMakeLists.txt +++ b/crypto/evp/CMakeLists.txt @@ -47,3 +47,4 @@ add_executable( target_link_libraries(evp_extra_test crypto) target_link_libraries(evp_test crypto) target_link_libraries(pbkdf_test crypto) +add_dependencies(all_tests evp_extra_test evp_test pbkdf_test) diff --git a/crypto/hkdf/CMakeLists.txt b/crypto/hkdf/CMakeLists.txt index 53bf55868..d9db933ea 100644 --- a/crypto/hkdf/CMakeLists.txt +++ b/crypto/hkdf/CMakeLists.txt @@ -17,3 +17,4 @@ add_executable( ) target_link_libraries(hkdf_test crypto) +add_dependencies(all_tests hkdf_test) diff --git a/crypto/hmac/CMakeLists.txt b/crypto/hmac/CMakeLists.txt index 392ce0123..179a53b0c 100644 --- a/crypto/hmac/CMakeLists.txt +++ b/crypto/hmac/CMakeLists.txt @@ -18,3 +18,4 @@ add_executable( ) target_link_libraries(hmac_test crypto) +add_dependencies(all_tests hmac_test) diff --git a/crypto/lhash/CMakeLists.txt b/crypto/lhash/CMakeLists.txt index ce785ebaa..4f4dea7cf 100644 --- a/crypto/lhash/CMakeLists.txt +++ b/crypto/lhash/CMakeLists.txt @@ -17,3 +17,4 @@ add_executable( ) target_link_libraries(lhash_test crypto) +add_dependencies(all_tests lhash_test) diff --git a/crypto/modes/CMakeLists.txt b/crypto/modes/CMakeLists.txt index 6da5207e7..41f71d7e7 100644 --- a/crypto/modes/CMakeLists.txt +++ b/crypto/modes/CMakeLists.txt @@ -63,3 +63,4 @@ add_executable( ) target_link_libraries(gcm_test crypto) +add_dependencies(all_tests gcm_test) diff --git a/crypto/pkcs8/CMakeLists.txt b/crypto/pkcs8/CMakeLists.txt index ce5bce196..955010997 100644 --- a/crypto/pkcs8/CMakeLists.txt +++ b/crypto/pkcs8/CMakeLists.txt @@ -27,3 +27,4 @@ add_executable( target_link_libraries(pkcs8_test crypto) target_link_libraries(pkcs12_test crypto) +add_dependencies(all_tests pkcs8_test pkcs12_test) diff --git a/crypto/poly1305/CMakeLists.txt b/crypto/poly1305/CMakeLists.txt index 674d9f682..1b6a8049f 100644 --- a/crypto/poly1305/CMakeLists.txt +++ b/crypto/poly1305/CMakeLists.txt @@ -28,3 +28,4 @@ add_executable( ) target_link_libraries(poly1305_test crypto) +add_dependencies(all_tests poly1305_test) diff --git a/crypto/rsa/CMakeLists.txt b/crypto/rsa/CMakeLists.txt index bd8ad3b85..969b753ea 100644 --- a/crypto/rsa/CMakeLists.txt +++ b/crypto/rsa/CMakeLists.txt @@ -21,3 +21,4 @@ add_executable( ) target_link_libraries(rsa_test crypto) +add_dependencies(all_tests rsa_test) \ No newline at end of file diff --git a/crypto/x509/CMakeLists.txt b/crypto/x509/CMakeLists.txt index 258c2633b..8ffeaa0dd 100644 --- a/crypto/x509/CMakeLists.txt +++ b/crypto/x509/CMakeLists.txt @@ -65,3 +65,4 @@ add_executable( ) target_link_libraries(pkcs7_test crypto) +add_dependencies(all_tests pkcs7_test) diff --git a/crypto/x509v3/CMakeLists.txt b/crypto/x509v3/CMakeLists.txt index 5cc1b490e..cf2474a4e 100644 --- a/crypto/x509v3/CMakeLists.txt +++ b/crypto/x509v3/CMakeLists.txt @@ -52,6 +52,7 @@ add_executable( ) target_link_libraries(v3name_test crypto) +add_dependencies(all_tests v3name_test) add_executable( tab_test @@ -62,3 +63,4 @@ add_executable( ) target_link_libraries(tab_test crypto) +add_dependencies(all_tests tab_test) diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt index 3c55e9d69..861763925 100644 --- a/ssl/CMakeLists.txt +++ b/ssl/CMakeLists.txt @@ -47,3 +47,4 @@ add_executable( ) target_link_libraries(ssl_test ssl crypto) +add_dependencies(all_tests ssl_test) diff --git a/ssl/pqueue/CMakeLists.txt b/ssl/pqueue/CMakeLists.txt index 53d2a8bf4..3a8b82bc5 100644 --- a/ssl/pqueue/CMakeLists.txt +++ b/ssl/pqueue/CMakeLists.txt @@ -17,3 +17,4 @@ add_executable( ) target_link_libraries(pqueue_test ssl crypto) +add_dependencies(all_tests pqueue_test)