summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2015-06-27 23:54:37 +0000
committernoloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2015-06-27 23:54:37 +0000
commit3319d69ea59af5f64041c4bdc03e3e1304feb02b (patch)
tree03a180892ab61e89861ef0290d97074a7c4ac73b
parent664b9ef808858768e0b9486be52aed2e77839edf (diff)
downloadcryptopp-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.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/test.cpp b/test.cpp
index 6a5aab0..a3250a8 100644
--- a/test.cpp
+++ b/test.cpp
@@ -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;