aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/nist_x509.cpp38
-rw-r--r--src/tests/tests.cpp28
2 files changed, 10 insertions, 56 deletions
diff --git a/src/tests/nist_x509.cpp b/src/tests/nist_x509.cpp
index 8c1f0d696..e6792512c 100644
--- a/src/tests/nist_x509.cpp
+++ b/src/tests/nist_x509.cpp
@@ -18,6 +18,7 @@
#if defined(BOTAN_HAS_X509_CERTIFICATES)
#include <botan/x509path.h>
+#include <botan/fs.h>
#include <algorithm>
#include <iostream>
@@ -26,38 +27,15 @@
#include <vector>
#include <map>
#include <cstdlib>
-#include <boost/filesystem.hpp>
-
-namespace fs = boost::filesystem;
using namespace Botan;
-namespace {
-
-std::vector<std::string> dir_listing(const std::string& dir_name)
- {
- std::vector<std::string> paths;
-
- fs::directory_iterator dir(dir_name), end;
-
- while(dir != end)
- {
- paths.push_back(dir->path().string());
- ++dir;
- }
-
- std::sort(paths.begin(), paths.end());
-
- return paths;
- }
-
-}
-
std::map<size_t, Path_Validation_Result::Code> get_expected();
size_t test_nist_x509()
{
const std::string root_test_dir = "src/tests/data/nist_x509/";
+ const size_t total_tests = 76;
size_t unexp_failure = 0;
size_t unexp_success = 0;
@@ -69,14 +47,10 @@ size_t test_nist_x509()
try {
- const std::vector<std::string> test_dirs = dir_listing(root_test_dir);
-
- for(size_t i = 0; i != test_dirs.size(); i++)
+ for(size_t test_no = 1; test_no <= total_tests; ++test_no)
{
- const size_t test_no = i+1;
-
- const std::string test_dir = test_dirs[i];
- const std::vector<std::string> all_files = dir_listing(test_dir);
+ const std::string test_dir = root_test_dir + "/test" + (test_no <= 9 ? "0" : "") + std::to_string(test_no);
+ const std::vector<std::string> all_files = list_all_readable_files_in_or_under(test_dir);
std::vector<std::string> certs, crls;
std::string root_cert, to_verify;
@@ -96,7 +70,7 @@ size_t test_nist_x509()
crls.push_back(current);
}
- if(expected_results.find(i+1) == expected_results.end())
+ if(expected_results.find(test_no) == expected_results.end())
{
skipped++;
continue;
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index 9a0a29bdd..299d07403 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -8,47 +8,27 @@
#include <iostream>
#include <fstream>
#include <botan/auto_rng.h>
+#include <botan/fs.h>
#if defined(BOTAN_HAS_SYSTEM_RNG)
#include <botan/system_rng.h>
#endif
-#include <boost/filesystem.hpp>
-
-namespace fs = boost::filesystem;
-
Botan::RandomNumberGenerator& test_rng()
{
#if defined(BOTAN_HAS_SYSTEM_RNG)
return Botan::system_rng();
#else
- static AutoSeeded_RNG rng;
+ static Botan::AutoSeeded_RNG rng;
return rng;
#endif
}
-std::vector<std::string> list_dir(const std::string& dir_path)
- {
- std::vector<std::string> paths;
-
- fs::recursive_directory_iterator dir(dir_path), end;
-
- while (dir != end)
- {
- if(dir->path().extension().string() == ".vec")
- paths.push_back(dir->path().string());
- ++dir;
- }
-
- std::sort(paths.begin(), paths.end());
-
- return paths;
- }
-
size_t run_tests_in_dir(const std::string& dir, std::function<size_t (const std::string&)> fn)
{
size_t fails = 0;
- for(auto vec: list_dir(dir))
+
+ for(auto vec: Botan::list_all_readable_files_in_or_under(dir))
fails += fn(vec);
return fails;
}