diff options
author | lloyd <[email protected]> | 2013-12-31 21:38:18 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2013-12-31 21:38:18 +0000 |
commit | c5dc7598403b5f7e739b2c27707663b16c4199f8 (patch) | |
tree | 632042be775d298f648247b824b97d493dca889d /checks/tests.cpp | |
parent | 7947d9787fe1cf448a418e2252edededdf887032 (diff) |
Split up tests by type
Diffstat (limited to 'checks/tests.cpp')
-rw-r--r-- | checks/tests.cpp | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/checks/tests.cpp b/checks/tests.cpp index 838c34b00..f9b5545ce 100644 --- a/checks/tests.cpp +++ b/checks/tests.cpp @@ -20,10 +20,18 @@ size_t run_tests_bb(std::istream& src, bool clear_between_cb, std::function<bool (std::map<std::string, std::string>)> cb) { + if(!src.good()) + { + std::cout << "Could not open input file for " << name_key << "\n"; + return 1; + } + std::map<std::string, std::string> vars; size_t test_cnt = 0; size_t test_fail = 0; + std::string fixed_name; + while(src.good()) { std::string line; @@ -35,31 +43,49 @@ size_t run_tests_bb(std::istream& src, if(line[0] == '#') continue; + if(line[0] == '[' && line[line.size()-1] == ']') + { + fixed_name = line.substr(1, line.size() - 2); + vars[name_key] = fixed_name; + continue; + } + const std::string key = line.substr(0, line.find_first_of(' ')); const std::string val = line.substr(line.find_last_of(' ') + 1, std::string::npos); vars[key] = val; + if(key == name_key) + fixed_name.clear(); + if(key == output_key) { + //std::cout << vars[name_key] << " " << test_cnt << "\n"; ++test_cnt; try { if(!cb(vars)) + { + std::cout << vars[name_key] << " test " << test_cnt << " failed\n"; ++test_fail; + } } catch(std::exception& e) { - std::cout << e.what() << "\n"; + std::cout << vars[name_key] << " test " << test_cnt << " failed: " << e.what() << "\n"; ++test_fail; } if(clear_between_cb) + { vars.clear(); + vars[name_key] = fixed_name; + } } } test_report(name_key, test_cnt, test_fail); + return test_fail; } @@ -82,3 +108,32 @@ size_t run_tests(std::istream& src, return true; }); } + +size_t run_all_tests() + { + 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); + + return run_tests(all_tests); + } |