diff options
-rw-r--r-- | src/main.cpp | 5 | ||||
-rw-r--r-- | src/tests/tests.cpp | 79 | ||||
-rw-r--r-- | src/tests/tests.h | 2 |
3 files changed, 43 insertions, 43 deletions
diff --git a/src/main.cpp b/src/main.cpp index f1451becf..8bbad670d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -129,10 +129,7 @@ int main(int argc, char* argv[]) } if(cmd == "test") - { - const size_t failures = run_all_tests(); - return failures ? 1 : 0; - } + return test_main(argc - 1, argv + 1); if(cmd == "speed") return speed_main(argc - 1, argv + 1); diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 622894803..fdcfae06a 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -149,43 +149,46 @@ size_t run_tests(std::istream& src, }); } -size_t run_all_tests() +int test_main(int argc, char* argv[]) { - std::vector<test_fn> all_tests; - - all_tests.push_back(test_block); - all_tests.push_back(test_stream); - all_tests.push_back(test_hash); - all_tests.push_back(test_mac); - - all_tests.push_back(test_modes); - - all_tests.push_back(test_aead); - all_tests.push_back(test_ocb); - all_tests.push_back(test_eax); - - all_tests.push_back(test_pbkdf); - all_tests.push_back(test_kdf); - all_tests.push_back(test_hkdf); - all_tests.push_back(test_keywrap); - all_tests.push_back(test_transform); - - all_tests.push_back(test_rngs); - all_tests.push_back(test_passhash9); - all_tests.push_back(test_bcrypt); - all_tests.push_back(test_cryptobox); - all_tests.push_back(test_tss); - - all_tests.push_back(test_bigint); - all_tests.push_back(test_pubkey); - - all_tests.push_back(test_ecc); - all_tests.push_back(test_ecdsa); - all_tests.push_back(test_ecdh); - all_tests.push_back(test_pk_keygen); - all_tests.push_back(test_cvc); - all_tests.push_back(test_x509); - all_tests.push_back(test_tls); - - return run_tests(all_tests); + //bool verbose = true; + std::string target = "all"; + if(argc == 2) + target = argv[1]; + + std::vector<test_fn> tests; + +#define DEF_TEST(test) do { if(target == "all" || target == #test) \ + tests.push_back(test_ ## test); \ + } while(0) + + DEF_TEST(block); + DEF_TEST(stream); + DEF_TEST(hash); + DEF_TEST(mac); + DEF_TEST(modes); + DEF_TEST(aead); + DEF_TEST(ocb); + DEF_TEST(eax); + DEF_TEST(pbkdf); + DEF_TEST(kdf); + DEF_TEST(hkdf); + DEF_TEST(keywrap); + DEF_TEST(transform); + DEF_TEST(rngs); + DEF_TEST(passhash9); + DEF_TEST(bcrypt); + DEF_TEST(cryptobox); + DEF_TEST(tss); + DEF_TEST(bigint); + DEF_TEST(pubkey); + DEF_TEST(ecc); + DEF_TEST(ecdsa); + DEF_TEST(ecdh); + DEF_TEST(pk_keygen); + DEF_TEST(cvc); + DEF_TEST(x509); + DEF_TEST(tls); + + return run_tests(tests); } diff --git a/src/tests/tests.h b/src/tests/tests.h index dff493f5f..87587144e 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -32,7 +32,7 @@ void test_report(const std::string& name, size_t ran, size_t failed); #define CHECKS_DIR "src/test-data/" -size_t run_all_tests(); +int test_main(int argc, char* argv[]); // Tests using reader framework above size_t test_block(); |