diff options
author | noloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2015-06-27 23:54:37 +0000 |
---|---|---|
committer | noloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2015-06-27 23:54:37 +0000 |
commit | 3319d69ea59af5f64041c4bdc03e3e1304feb02b (patch) | |
tree | 03a180892ab61e89861ef0290d97074a7c4ac73b | |
parent | 664b9ef808858768e0b9486be52aed2e77839edf (diff) | |
download | cryptopp-3319d69ea59af5f64041c4bdc03e3e1304feb02b.tar.gz |
Fixed potential missing argument when using tv subcommand with argv[2]. Print OMP thread count when usong OpenMP
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@545 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r-- | test.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -42,6 +42,10 @@ #include <console.h> #endif +#ifdef _OPENMP +# include <omp.h> +#endif + #ifdef __BORLANDC__ #pragma comment(lib, "cryptlib_bds.lib") #pragma comment(lib, "ws2_32.lib") @@ -113,6 +117,8 @@ int CRYPTOPP_API main(int argc, char *argv[]) #if defined(__MWERKS__) && defined(macintosh) argc = ccommand(&argv); #endif + + CRYPTOPP_UNUSED(argc), CRYPTOPP_UNUSED(argv); try { @@ -249,7 +255,7 @@ int CRYPTOPP_API main(int argc, char *argv[]) DigestFile(argv[2]); else if (command == "tv") { - std::string fname = argv[2]; + std::string fname = (argc >= 3 ? argv[2] : "all"); if (fname.find(".txt") == std::string::npos) fname = "TestVectors/" + fname + ".txt"; return !RunTestDataFile(fname.c_str()); @@ -767,9 +773,21 @@ bool Validate(int alg, bool thorough, const char *seedInput) std::string seed = seedInput ? std::string(seedInput) : IntToString(time(NULL)); seed.resize(16); - cout << "Using seed: " << seed << endl << endl; + cout << "Using seed: " << seed << endl; s_globalRNG.SetKeyWithIV((byte *)seed.data(), 16, (byte *)seed.data()); +#ifdef _OPENMP + int tc = 0; + #pragma omp parallel + { + tc = omp_get_num_threads(); + } + + cout << "Using " << tc << " OMP " << (tc == 1 ? "thread" : "threads") << endl; +#endif + + cout << endl; + switch (alg) { case 0: result = ValidateAll(thorough); break; |