aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-05-21 09:40:30 -0400
committerJack Lloyd <[email protected]>2017-05-21 09:40:30 -0400
commit1f0aa5fc418a76e9c244f7ba35c8d29b98257c5f (patch)
tree7d0705946e9c7caafcfd0416365989927869cd7e
parentb7200c05c6fe841cd5f4a5942a5be3d63124914e (diff)
Add a bogus fallback RNG for the tests
This allows all tests to run even if no RNG type enabled in the build
-rw-r--r--src/tests/main.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index bdd751e48..e30c268c0 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -13,6 +13,7 @@
#include <deque>
#include <thread>
#include <future>
+#include <cstdlib>
#include <botan/version.h>
#include <botan/loadstor.h>
@@ -206,9 +207,45 @@ class Test_Runner : public Botan_CLI::Command
#elif defined(BOTAN_HAS_AUTO_SEEDING_RNG)
output() << " rng:autoseeded";
rng.reset(new Botan::Serialized_RNG(new Botan::AutoSeeded_RNG));
+#else
+ // last ditch fallback for RNG-less build
+ class Bogus_Fallback_RNG : public Botan::RandomNumberGenerator
+ {
+ public:
+ std::string name() const override
+ {
+ return "Bogus_Fallback_RNG";
+ }
+
+ void clear() override
+ {
+ /* ignored */
+ }
+
+ void randomize(uint8_t out[], size_t len) override
+ {
+ for(size_t i = 0; i != len; ++i)
+ {
+ out[i] = std::rand();
+ }
+ }
+
+ bool is_seeded() const override
+ {
+ return true;
+ }
+
+ void add_entropy(const uint8_t[], size_t) override
+ {
+ /* ignored */
+ }
+ };
+
+ rng.reset(new Bogus_Fallback_RNG);
#endif
#endif
+
output() << "\n";
Botan_Tests::Test::setup_tests(log_success, run_online_tests, run_long_tests,