Skip to content

Commit 197b571

Browse files
davidbenBoringssl LUCI CQ
authored and
Boringssl LUCI CQ
committed
Use sources.cmake for test binaries
CMake and the generate builds now broadly share a source of truth for the test files. Update-Note: In the standalone CMake build, build/crypto/crypto_test is now build/crypto_test, etc. For now, the build still copies the outputs to the subdirectories (it's cheap and avoids some workflow turbulence), but I'm thinking we keep that for six months or so and then remove it. Bug: 542 Change-Id: I8f97e1fcedea1375d48567dfd2da01a6e66ec4e8 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61286 Commit-Queue: David Benjamin <[email protected]> Reviewed-by: Bob Beck <[email protected]>
1 parent 8e8f87e commit 197b571

File tree

9 files changed

+154
-143
lines changed

9 files changed

+154
-143
lines changed

CMakeLists.txt

+27
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,26 @@ add_subdirectory(util/fipstools)
520520
add_subdirectory(util/fipstools/acvp/modulewrapper)
521521
add_subdirectory(decrepit)
522522

523+
# urandom_test is a separate binary because it needs to be able to observe the
524+
# PRNG initialisation, which means that it can't have other tests running before
525+
# it does.
526+
add_executable(urandom_test ${URANDOM_TEST_SOURCES})
527+
target_link_libraries(urandom_test test_support_lib boringssl_gtest crypto)
528+
add_dependencies(all_tests urandom_test)
529+
530+
add_executable(crypto_test ${CRYPTO_TEST_SOURCES} $<TARGET_OBJECTS:crypto_test_data>)
531+
target_link_libraries(crypto_test test_support_lib boringssl_gtest_main crypto)
532+
add_dependencies(all_tests crypto_test)
533+
534+
add_executable(ssl_test ${SSL_TEST_SOURCES})
535+
target_link_libraries(ssl_test test_support_lib boringssl_gtest_main ssl crypto)
536+
add_dependencies(all_tests ssl_test)
537+
538+
add_executable(decrepit_test ${DECREPIT_TEST_SOURCES})
539+
target_link_libraries(decrepit_test test_support_lib boringssl_gtest_main
540+
decrepit crypto)
541+
add_dependencies(all_tests decrepit_test)
542+
523543
if(APPLE)
524544
set(PKI_CXX_FLAGS "-fno-aligned-new")
525545
endif()
@@ -541,6 +561,13 @@ set_target_properties(
541561
CXX_STANDARD_REQUIRED YES
542562
COMPILE_FLAGS "${PKI_CXX_FLAGS}")
543563

564+
# Historically, targets were built in subdirectories. For compatibility with
565+
# existing tools, we, for now, copy the targets into the subdirectories. This
566+
# will be removed sometime in 2024.
567+
copy_post_build(crypto crypto_test urandom_test)
568+
copy_post_build(ssl ssl_test)
569+
copy_post_build(decrepit decrepit_test)
570+
544571
if(FUZZ)
545572
if(LIBFUZZER_FROM_DEPS)
546573
file(GLOB LIBFUZZER_SOURCES "util/bot/libFuzzer/*.cpp")

cmake/paths.cmake

+12
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ function(binary_dir_relative_path cur_bin_dir_relative outvar)
99
string(SUBSTRING "${CMAKE_CURRENT_BINARY_DIR}/${cur_bin_dir_relative}" ${root_dir_length} -1 result)
1010
set(${outvar} ${result} PARENT_SCOPE)
1111
endfunction()
12+
13+
# copy_post_build causes targets in ${ARGN} to be copied to
14+
# ${CMAKE_CURRENT_BINARY_DIR}/${dir} after being built.
15+
function(copy_post_build dir)
16+
foreach(target ${ARGN})
17+
add_custom_command(
18+
TARGET ${target}
19+
POST_BUILD
20+
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/${dir}"
21+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${target}> "${CMAKE_CURRENT_BINARY_DIR}/${dir}")
22+
endforeach()
23+
endfunction()

crypto/CMakeLists.txt

-85
Original file line numberDiff line numberDiff line change
@@ -345,88 +345,3 @@ endif()
345345
if(USE_CUSTOM_LIBCXX)
346346
target_link_libraries(crypto libcxx)
347347
endif()
348-
349-
# urandom_test is a separate binary because it needs to be able to observe the
350-
# PRNG initialisation, which means that it can't have other tests running before
351-
# it does.
352-
add_executable(
353-
urandom_test
354-
355-
fipsmodule/rand/urandom_test.cc
356-
)
357-
target_link_libraries(urandom_test test_support_lib boringssl_gtest crypto)
358-
add_dependencies(all_tests urandom_test)
359-
360-
add_executable(
361-
crypto_test
362-
363-
abi_self_test.cc
364-
asn1/asn1_test.cc
365-
base64/base64_test.cc
366-
bio/bio_test.cc
367-
blake2/blake2_test.cc
368-
buf/buf_test.cc
369-
bytestring/bytestring_test.cc
370-
chacha/chacha_test.cc
371-
cipher_extra/aead_test.cc
372-
cipher_extra/cipher_test.cc
373-
compiler_test.cc
374-
conf/conf_test.cc
375-
constant_time_test.cc
376-
cpu_arm_linux_test.cc
377-
crypto_test.cc
378-
curve25519/ed25519_test.cc
379-
curve25519/spake25519_test.cc
380-
curve25519/x25519_test.cc
381-
ecdh_extra/ecdh_test.cc
382-
dh_extra/dh_test.cc
383-
digest_extra/digest_test.cc
384-
dsa/dsa_test.cc
385-
err/err_test.cc
386-
evp/evp_extra_test.cc
387-
evp/evp_test.cc
388-
evp/pbkdf_test.cc
389-
evp/scrypt_test.cc
390-
fipsmodule/aes/aes_test.cc
391-
fipsmodule/bn/bn_test.cc
392-
fipsmodule/cmac/cmac_test.cc
393-
fipsmodule/ec/ec_test.cc
394-
fipsmodule/ec/p256-nistz_test.cc
395-
fipsmodule/ecdsa/ecdsa_test.cc
396-
fipsmodule/hkdf/hkdf_test.cc
397-
fipsmodule/md5/md5_test.cc
398-
fipsmodule/modes/gcm_test.cc
399-
fipsmodule/rand/ctrdrbg_test.cc
400-
fipsmodule/rand/fork_detect_test.cc
401-
fipsmodule/service_indicator/service_indicator_test.cc
402-
fipsmodule/sha/sha_test.cc
403-
hpke/hpke_test.cc
404-
hmac_extra/hmac_test.cc
405-
hrss/hrss_test.cc
406-
impl_dispatch_test.cc
407-
kyber/kyber_test.cc
408-
lhash/lhash_test.cc
409-
obj/obj_test.cc
410-
pem/pem_test.cc
411-
pkcs7/pkcs7_test.cc
412-
pkcs8/pkcs8_test.cc
413-
pkcs8/pkcs12_test.cc
414-
poly1305/poly1305_test.cc
415-
pool/pool_test.cc
416-
rand_extra/rand_test.cc
417-
refcount_test.cc
418-
rsa_extra/rsa_test.cc
419-
self_test.cc
420-
stack/stack_test.cc
421-
siphash/siphash_test.cc
422-
test/file_test_gtest.cc
423-
thread_test.cc
424-
trust_token/trust_token_test.cc
425-
x509/x509_test.cc
426-
x509/x509_time_test.cc
427-
x509v3/tab_test.cc
428-
429-
$<TARGET_OBJECTS:crypto_test_data>
430-
)
431-
target_link_libraries(crypto_test test_support_lib boringssl_gtest_main crypto)
432-
add_dependencies(all_tests crypto_test)

crypto/test/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_library(
55

66
abi_test.cc
77
file_test.cc
8+
file_test_gtest.cc
89
test_util.cc
910
wycheproof_util.cc
1011
)

decrepit/CMakeLists.txt

-14
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,3 @@ add_library(
2020
xts/xts.c
2121
)
2222
target_link_libraries(decrepit crypto ssl)
23-
24-
add_executable(
25-
decrepit_test
26-
27-
blowfish/blowfish_test.cc
28-
cast/cast_test.cc
29-
cfb/cfb_test.cc
30-
evp/evp_test.cc
31-
ripemd/ripemd_test.cc
32-
xts/xts_test.cc
33-
)
34-
target_link_libraries(decrepit_test test_support_lib boringssl_gtest_main
35-
decrepit crypto)
36-
add_dependencies(all_tests decrepit_test)

sources.cmake

+94
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,75 @@
33
#
44
# TODO(davidben): Move the other source lists into this file.
55

6+
set(
7+
CRYPTO_TEST_SOURCES
8+
9+
crypto/abi_self_test.cc
10+
crypto/asn1/asn1_test.cc
11+
crypto/base64/base64_test.cc
12+
crypto/bio/bio_test.cc
13+
crypto/blake2/blake2_test.cc
14+
crypto/buf/buf_test.cc
15+
crypto/bytestring/bytestring_test.cc
16+
crypto/chacha/chacha_test.cc
17+
crypto/cipher_extra/aead_test.cc
18+
crypto/cipher_extra/cipher_test.cc
19+
crypto/compiler_test.cc
20+
crypto/conf/conf_test.cc
21+
crypto/constant_time_test.cc
22+
crypto/cpu_arm_linux_test.cc
23+
crypto/crypto_test.cc
24+
crypto/curve25519/ed25519_test.cc
25+
crypto/curve25519/spake25519_test.cc
26+
crypto/curve25519/x25519_test.cc
27+
crypto/ecdh_extra/ecdh_test.cc
28+
crypto/dh_extra/dh_test.cc
29+
crypto/digest_extra/digest_test.cc
30+
crypto/dsa/dsa_test.cc
31+
crypto/err/err_test.cc
32+
crypto/evp/evp_extra_test.cc
33+
crypto/evp/evp_test.cc
34+
crypto/evp/pbkdf_test.cc
35+
crypto/evp/scrypt_test.cc
36+
crypto/fipsmodule/aes/aes_test.cc
37+
crypto/fipsmodule/bn/bn_test.cc
38+
crypto/fipsmodule/cmac/cmac_test.cc
39+
crypto/fipsmodule/ec/ec_test.cc
40+
crypto/fipsmodule/ec/p256-nistz_test.cc
41+
crypto/fipsmodule/ecdsa/ecdsa_test.cc
42+
crypto/fipsmodule/hkdf/hkdf_test.cc
43+
crypto/fipsmodule/md5/md5_test.cc
44+
crypto/fipsmodule/modes/gcm_test.cc
45+
crypto/fipsmodule/rand/ctrdrbg_test.cc
46+
crypto/fipsmodule/rand/fork_detect_test.cc
47+
crypto/fipsmodule/service_indicator/service_indicator_test.cc
48+
crypto/fipsmodule/sha/sha_test.cc
49+
crypto/hpke/hpke_test.cc
50+
crypto/hmac_extra/hmac_test.cc
51+
crypto/hrss/hrss_test.cc
52+
crypto/impl_dispatch_test.cc
53+
crypto/kyber/kyber_test.cc
54+
crypto/lhash/lhash_test.cc
55+
crypto/obj/obj_test.cc
56+
crypto/pem/pem_test.cc
57+
crypto/pkcs7/pkcs7_test.cc
58+
crypto/pkcs8/pkcs8_test.cc
59+
crypto/pkcs8/pkcs12_test.cc
60+
crypto/poly1305/poly1305_test.cc
61+
crypto/pool/pool_test.cc
62+
crypto/rand_extra/rand_test.cc
63+
crypto/refcount_test.cc
64+
crypto/rsa_extra/rsa_test.cc
65+
crypto/self_test.cc
66+
crypto/stack/stack_test.cc
67+
crypto/siphash/siphash_test.cc
68+
crypto/thread_test.cc
69+
crypto/trust_token/trust_token_test.cc
70+
crypto/x509/x509_test.cc
71+
crypto/x509/x509_time_test.cc
72+
crypto/x509v3/tab_test.cc
73+
)
74+
675
set(
776
CRYPTO_TEST_DATA
877

@@ -239,6 +308,31 @@ set(
239308
third_party/wycheproof_testvectors/xchacha20_poly1305_test.txt
240309
)
241310

311+
set(
312+
URANDOM_TEST_SOURCES
313+
314+
crypto/fipsmodule/rand/urandom_test.cc
315+
)
316+
317+
set(
318+
SSL_TEST_SOURCES
319+
320+
ssl/span_test.cc
321+
ssl/ssl_test.cc
322+
ssl/ssl_c_test.c
323+
)
324+
325+
set(
326+
DECREPIT_TEST_SOURCES
327+
328+
decrepit/blowfish/blowfish_test.cc
329+
decrepit/cast/cast_test.cc
330+
decrepit/cfb/cfb_test.cc
331+
decrepit/evp/evp_test.cc
332+
decrepit/ripemd/ripemd_test.cc
333+
decrepit/xts/xts_test.cc
334+
)
335+
242336
set(
243337
PKI_SOURCES
244338

ssl/CMakeLists.txt

-10
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,3 @@ add_library(
4545
install_if_enabled(TARGETS ssl EXPORT OpenSSLTargets ${INSTALL_DESTINATION_DEFAULT})
4646
set_property(TARGET ssl PROPERTY EXPORT_NAME SSL)
4747
target_link_libraries(ssl crypto)
48-
49-
add_executable(
50-
ssl_test
51-
52-
span_test.cc
53-
ssl_test.cc
54-
ssl_c_test.c
55-
)
56-
target_link_libraries(ssl_test test_support_lib boringssl_gtest_main ssl crypto)
57-
add_dependencies(all_tests ssl_test)

util/all_tests.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11
[
22
{
3-
"cmd": ["crypto/crypto_test"],
3+
"cmd": ["crypto_test"],
44
"shard": true
55
},
66
{
7-
"cmd": ["crypto/crypto_test", "--gtest_also_run_disabled_tests", "--gtest_filter=BNTest.DISABLED_WycheproofPrimality"]
7+
"cmd": ["crypto_test", "--gtest_also_run_disabled_tests", "--gtest_filter=BNTest.DISABLED_WycheproofPrimality"]
88
},
99
{
10-
"cmd": ["crypto/crypto_test", "--gtest_also_run_disabled_tests", "--gtest_filter=RSATest.DISABLED_BlindingCacheConcurrency"],
10+
"cmd": ["crypto_test", "--gtest_also_run_disabled_tests", "--gtest_filter=RSATest.DISABLED_BlindingCacheConcurrency"],
1111
"skip_sde": true
1212
},
1313
{
14-
"cmd": ["crypto/urandom_test"]
14+
"cmd": ["urandom_test"]
1515
},
1616
{
1717
"comment": "Without RDRAND",
18-
"cmd": ["crypto/urandom_test"],
18+
"cmd": ["urandom_test"],
1919
"env": ["OPENSSL_ia32cap=~0x4000000000000000"]
2020
},
2121
{
2222
"comment": "Potentially with RDRAND, but not Intel",
23-
"cmd": ["crypto/urandom_test"],
23+
"cmd": ["urandom_test"],
2424
"env": ["OPENSSL_ia32cap=~0x0000000040000000"]
2525
},
2626
{
2727
"comment": "Potentially with RDRAND, and forced to Intel",
28-
"cmd": ["crypto/urandom_test"],
28+
"cmd": ["urandom_test"],
2929
"env": ["OPENSSL_ia32cap=|0x0000000040000000"]
3030
},
3131
{
3232
"comment": "No RDRAND and without WIPEONFORK",
33-
"cmd": ["crypto/urandom_test"],
33+
"cmd": ["urandom_test"],
3434
"env": ["OPENSSL_ia32cap=~0x4000000000000000", "BORINGSSL_IGNORE_MADV_WIPEONFORK=1"]
3535
},
3636
{
3737
"comment": "Potentially with RDRAND, but not Intel, and no WIPEONFORK",
38-
"cmd": ["crypto/urandom_test"],
38+
"cmd": ["urandom_test"],
3939
"env": ["OPENSSL_ia32cap=~0x0000000040000000", "BORINGSSL_IGNORE_MADV_WIPEONFORK=1"]
4040
},
4141
{
42-
"cmd": ["crypto/crypto_test", "--fork_unsafe_buffering", "--gtest_filter=RandTest.*:-RandTest.Fork"]
42+
"cmd": ["crypto_test", "--fork_unsafe_buffering", "--gtest_filter=RandTest.*:-RandTest.Fork"]
4343
},
4444
{
45-
"cmd": ["decrepit/decrepit_test"],
45+
"cmd": ["decrepit_test"],
4646
"shard": true
4747
},
4848
{
49-
"cmd": ["ssl/ssl_test"],
49+
"cmd": ["ssl_test"],
5050
"shard": true
5151
},
5252
{

0 commit comments

Comments
 (0)