From 3319d69ea59af5f64041c4bdc03e3e1304feb02b Mon Sep 17 00:00:00 2001 From: noloader Date: Sat, 27 Jun 2015 23:54:37 +0000 Subject: 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 --- test.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'test.cpp') diff --git a/test.cpp b/test.cpp index 6a5aab0..a3250a8 100644 --- a/test.cpp +++ b/test.cpp @@ -42,6 +42,10 @@ #include #endif +#ifdef _OPENMP +# include +#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; -- cgit v1.2.1