aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/tests.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-11-11 10:52:33 -0500
committerJack Lloyd <[email protected]>2015-11-11 10:52:33 -0500
commit3dbcfb6297acfdb8818742acfb0fa9ffe70bcdbc (patch)
tree5be482d63c6c48675688e8dd1129c9a6880afce0 /src/tests/tests.cpp
parent554baafac906e1339fe85579c84b32a034fa60ad (diff)
Avoid calling get_files_recursive on a possible non-directory.
The Boost directory iterator throws an exception in that case. Interestingly the current VC version does not seem to. In the interests of portability just avoid this operation rather than trying to hack around it in the Boost fs version. GH #328
Diffstat (limited to 'src/tests/tests.cpp')
-rw-r--r--src/tests/tests.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index 3137c5ba7..55c9e3824 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -484,10 +484,10 @@ std::string Test::random_password()
return Botan::hex_encode(Test::rng().random_vec(len));
}
-Text_Based_Test::Text_Based_Test(const std::string& data_dir,
+Text_Based_Test::Text_Based_Test(const std::string& data_src,
const std::vector<std::string>& required_keys,
const std::vector<std::string>& optional_keys) :
- m_data_dir(data_dir)
+ m_data_src(data_src)
{
if(required_keys.empty())
throw std::runtime_error("Invalid test spec");
@@ -498,11 +498,11 @@ Text_Based_Test::Text_Based_Test(const std::string& data_dir,
}
Text_Based_Test::Text_Based_Test(const std::string& algo,
- const std::string& data_dir,
+ const std::string& data_src,
const std::vector<std::string>& required_keys,
const std::vector<std::string>& optional_keys) :
m_algo(algo),
- m_data_dir(data_dir)
+ m_data_src(data_src)
{
if(required_keys.empty())
throw std::runtime_error("Invalid test spec");
@@ -611,15 +611,16 @@ std::string Text_Based_Test::get_next_line()
{
if(m_first)
{
- std::vector<std::string> fs = Botan::get_files_recursive(m_data_dir);
-
- if(fs.empty() && m_data_dir.find(".vec") != std::string::npos)
+ if(m_data_src.find(".vec") != std::string::npos)
{
- m_srcs.push_back(m_data_dir);
+ m_srcs.push_back(m_data_src);
}
else
{
+ const auto fs = Botan::get_files_recursive(m_data_src);
m_srcs.assign(fs.begin(), fs.end());
+ if(m_srcs.empty())
+ throw std::runtime_error("Error reading test data dir " + m_data_src);
}
m_first = false;