Skip to content

Commit

Permalink
Use one process for all tests.
Browse files Browse the repository at this point in the history
Instead of building the test suites inherited from BoringSSL as
seperate executables, link them all together into one executable,
giving all their `main` functions unique names.

This allows all the tests to be run, even on platforms that don't have
traditional process spawning, and avoids the need to keep track of
directory names even on platforms that do support process spawning.

This also makes it easier to integrate new BoringSSL test suites on
Windows, because we don't need to create a new `vcxproj` file for each
one.

Having one test executable may also make code coverage easier.
  • Loading branch information
briansmith committed Apr 17, 2016
1 parent 8b5a1a5 commit 4165289
Show file tree
Hide file tree
Showing 32 changed files with 233 additions and 878 deletions.
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@ include mk/ring.mk

OBJS += \
$(RING_OBJS) \
$(RING_TEST_LIB_OBJS) \
$(RING_TEST_MAIN_OBJS) \
$(NULL)

LIBS += \
$(RING_LIB) \
$(RING_LIBS) \
$(NULL)

EXES += $(RING_TEST_EXES)

check:: check-ring

include mk/bottom_of_makefile.mk
12 changes: 9 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ fn build_c_code(out_dir: &str) -> Result<(), std::env::VarError> {

let command_name;
let args;
let lib_path;
if !use_msbuild {
command_name = "make";
// Environment variables |CC|, |CXX|, etc. will be inherited from this
Expand All @@ -117,7 +116,6 @@ fn build_c_code(out_dir: &str) -> Result<(), std::env::VarError> {
} else {
"RELWITHDEBINFO"
};
lib_path = Path::new(out_dir).join("lib");
args = vec![
format!("-j{}", num_jobs),
format!("TARGET={}", target_str),
Expand Down Expand Up @@ -145,7 +143,6 @@ fn build_c_code(out_dir: &str) -> Result<(), std::env::VarError> {
format!("/p:OutRootDir={}/", out_dir),
format!("/p:GENERATED_CODE_DIR={}", out_dir),
];
lib_path = Path::new(&out_dir).join("lib");
}

if !std::process::Command::new(command_name)
Expand All @@ -157,7 +154,16 @@ fn build_c_code(out_dir: &str) -> Result<(), std::env::VarError> {
panic!("{} execution failed", command_name);
}

let lib_path = Path::new(out_dir).join("lib");
println!("cargo:rustc-link-search=native={}", lib_path.to_str().unwrap());
println!("cargo:rustc-link-lib=static={}-core", LIB_NAME);

// XXX: Ideally, this would only happen for `cargo test`, but we don't know
// how to do that yet.
println!("cargo:rustc-link-lib=static={}-test", LIB_NAME);
if !use_msbuild {
println!("cargo:rustc-flags=-l dylib=stdc++");
}

Ok(())
}
25 changes: 0 additions & 25 deletions crypto/aes/aes_test.Windows.vcxproj

This file was deleted.

4 changes: 3 additions & 1 deletion crypto/aes/aes_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <openssl/crypto.h>


extern "C" int bssl_aes_test_main();

static bool TestAES(const uint8_t *key, size_t key_len,
const uint8_t plaintext[AES_BLOCK_SIZE],
const uint8_t ciphertext[AES_BLOCK_SIZE]) {
Expand Down Expand Up @@ -66,7 +68,7 @@ static bool TestAES(const uint8_t *key, size_t key_len,
return true;
}

int main() {
extern "C" int bssl_aes_test_main() {
CRYPTO_library_init();

// Test vectors from FIPS-197, Appendix C.
Expand Down
25 changes: 0 additions & 25 deletions crypto/bn/bn_test.Windows.vcxproj

This file was deleted.

Loading

0 comments on commit 4165289

Please sign in to comment.