Add a run_tests target to run all tests.

It's very annoying having to remember the right incant every time I want
to switch around between my build, build-release, build-asan, etc.,
output directories.

Unfortunately, this target is pretty unfriendly without CMake 3.2+ (and
Ninja 1.5+). This combination gives a USES_TERMINAL flag to
add_custom_target which uses Ninja's "console" pool, otherwise the
output buffering gets in the way. Ubuntu LTS is still on an older CMake,
so do a version check in the meantime.

CMake also has its own test mechanism (CTest), but this doesn't use it.
It seems to prefer knowing what all the tests are and then tries to do
its own output management and parallelizing and such. We already have
our own runners. all_tests.go could actually be converted tidily, but
generate_build_files.py also needs to read it, and runner.go has very
specific needs.

Naming the target ninja -C build test would be nice, but CTest squats
that name and CMake grumps when you use a reserved name, so I've gone
with run_tests.

Change-Id: Ibd20ebd50febe1b4e91bb19921f3bbbd9fbcf66c
Reviewed-on: https://boringssl-review.googlesource.com/6270
Reviewed-by: Adam Langley <alangley@gmail.com>
This commit is contained in:
David Benjamin 2015-10-14 21:34:40 -04:00 committed by Adam Langley
parent b9c26014de
commit 301afaf223
28 changed files with 51 additions and 0 deletions

View File

@ -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/

View File

@ -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 $<TARGET_FILE:bssl_shim>
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS all_tests bssl_shim
${MAYBE_USES_TERMINAL})

View File

@ -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)

View File

@ -69,3 +69,4 @@ add_executable(
)
target_link_libraries(aes_test crypto)
add_dependencies(all_tests aes_test)

View File

@ -17,3 +17,4 @@ add_executable(
)
target_link_libraries(base64_test crypto)
add_dependencies(all_tests base64_test)

View File

@ -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)

View File

@ -76,3 +76,4 @@ add_executable(
)
target_link_libraries(bn_test crypto)
add_dependencies(all_tests bn_test)

View File

@ -19,3 +19,4 @@ add_executable(
)
target_link_libraries(bytestring_test crypto)
add_dependencies(all_tests bytestring_test)

View File

@ -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)

View File

@ -17,3 +17,4 @@ add_executable(
)
target_link_libraries(cmac_test crypto)
add_dependencies(all_tests cmac_test)

View File

@ -21,3 +21,4 @@ add_executable(
)
target_link_libraries(dh_test crypto)
add_dependencies(all_tests dh_test)

View File

@ -18,3 +18,4 @@ add_executable(
)
target_link_libraries(digest_test crypto)
add_dependencies(all_tests digest_test)

View File

@ -19,3 +19,4 @@ add_executable(
)
target_link_libraries(dsa_test crypto)
add_dependencies(all_tests dsa_test)

View File

@ -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)

View File

@ -19,3 +19,4 @@ add_executable(
)
target_link_libraries(ecdsa_test crypto)
add_dependencies(all_tests ecdsa_test)

View File

@ -47,3 +47,4 @@ add_executable(
)
target_link_libraries(err_test crypto)
add_dependencies(all_tests err_test)

View File

@ -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)

View File

@ -17,3 +17,4 @@ add_executable(
)
target_link_libraries(hkdf_test crypto)
add_dependencies(all_tests hkdf_test)

View File

@ -18,3 +18,4 @@ add_executable(
)
target_link_libraries(hmac_test crypto)
add_dependencies(all_tests hmac_test)

View File

@ -17,3 +17,4 @@ add_executable(
)
target_link_libraries(lhash_test crypto)
add_dependencies(all_tests lhash_test)

View File

@ -63,3 +63,4 @@ add_executable(
)
target_link_libraries(gcm_test crypto)
add_dependencies(all_tests gcm_test)

View File

@ -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)

View File

@ -28,3 +28,4 @@ add_executable(
)
target_link_libraries(poly1305_test crypto)
add_dependencies(all_tests poly1305_test)

View File

@ -21,3 +21,4 @@ add_executable(
)
target_link_libraries(rsa_test crypto)
add_dependencies(all_tests rsa_test)

View File

@ -65,3 +65,4 @@ add_executable(
)
target_link_libraries(pkcs7_test crypto)
add_dependencies(all_tests pkcs7_test)

View File

@ -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)

View File

@ -47,3 +47,4 @@ add_executable(
)
target_link_libraries(ssl_test ssl crypto)
add_dependencies(all_tests ssl_test)

View File

@ -17,3 +17,4 @@ add_executable(
)
target_link_libraries(pqueue_test ssl crypto)
add_dependencies(all_tests pqueue_test)