]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3207] Remove old implementation
authorSlawek Figiel <slawek@isc.org>
Fri, 9 Feb 2024 11:49:40 +0000 (12:49 +0100)
committerSlawek Figiel <slawek@isc.org>
Tue, 20 Feb 2024 08:33:35 +0000 (09:33 +0100)
src/bin/perfdhcp/Makefile.am
src/bin/perfdhcp/random_number_generator.h [deleted file]
src/bin/perfdhcp/test_control.h
src/bin/perfdhcp/tests/Makefile.am
src/bin/perfdhcp/tests/random_number_generator_unittest.cc [deleted file]

index 63fa8352f9426efcc226a48c5116beab25d1d04e..b6d6169279dd7ce923e147c295c73c0b064cf3ae 100644 (file)
@@ -25,7 +25,6 @@ libperfdhcp_la_SOURCES += pkt_transform.cc pkt_transform.h
 libperfdhcp_la_SOURCES += rate_control.cc rate_control.h
 libperfdhcp_la_SOURCES += stats_mgr.cc stats_mgr.h
 libperfdhcp_la_SOURCES += test_control.cc test_control.h
-libperfdhcp_la_SOURCES += random_number_generator.h
 libperfdhcp_la_SOURCES += receiver.cc receiver.h
 libperfdhcp_la_SOURCES += perf_socket.cc perf_socket.h
 libperfdhcp_la_SOURCES += abstract_scen.h
diff --git a/src/bin/perfdhcp/random_number_generator.h b/src/bin/perfdhcp/random_number_generator.h
deleted file mode 100644 (file)
index 419b37e..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2010-2024 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifndef NSAS_RANDOM_NUMBER_GENERATOR_H
-#define NSAS_RANDOM_NUMBER_GENERATOR_H
-
-#include <algorithm>
-#include <cmath>
-#include <iterator>
-#include <numeric>
-#include <vector>
-
-#include <exceptions/exceptions.h>
-
-#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/uniform_int.hpp>
-#include <boost/random/uniform_real.hpp>
-#include <boost/random/variate_generator.hpp>
-
-/// PLEASE DO NOT USE THIS IN CRYPTOGRAPHICALLY SENSITIVE CODE.
-
-namespace isc {
-namespace perfdhcp {
-
-/// \brief Uniform random integer generator
-///
-/// Generate uniformly distributed integers in range of [min, max]
-class UniformRandomIntegerGenerator{
-public:
-    /// \brief Constructor
-    ///
-    /// \param min The minimum number in the range
-    /// \param max The maximum number in the range
-    UniformRandomIntegerGenerator(int min, int max):
-        min_(std::min(min, max)), max_(std::max(min, max)),
-        dist_(min_, max_), generator_(rng_, dist_)
-    {
-        // Init with the current time
-        rng_.seed(time(0));
-    }
-
-    /// \brief Generate uniformly distributed integer
-    int operator()() { return generator_(); }
-private:
-    /// Hide default and copy constructor
-    UniformRandomIntegerGenerator();///< Default constructor
-    UniformRandomIntegerGenerator(const UniformRandomIntegerGenerator&); ///< Copy constructor
-
-    int min_;                       ///< The minimum integer that can generate
-    int max_;                       ///< The maximum integer that can generate
-    boost::uniform_int<> dist_;     ///< Distribute uniformly.
-    boost::mt19937 rng_;            ///< Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator
-    boost::variate_generator<boost::mt19937&, boost::uniform_int<> > generator_; ///< Uniform generator
-};
-
-}   // namespace perfdhcp
-}   // namespace isc
-
-#endif//NSAS_RANDOM_NUMBER_GENERATOR_H
index 650d43eb754c47a4c508461ff5b6d8da426fc848..87955532bfef0aca8938cf93ed21bfbc8cd894ab 100644 (file)
@@ -196,7 +196,7 @@ public:
             NumberGenerator(),
             distribution(min, max) {
             // Initialize the randomness source with the current time.
-            randomnessGenerator.seed(time(NULL));
+            randomnessGenerator.seed(time(0));
         }
 
         /// \brief Generate number in range of [min, max].
index 4de5e30bf949a2b913a0e658a3e7836a2b45dcab..35ad72e80c92af34a375c4205bead896fdc24b7c 100644 (file)
@@ -11,13 +11,13 @@ if USE_STATIC_LINK
 AM_LDFLAGS = -static
 endif
 
+TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
 CLEANFILES = *.gcno *.gcda
 # The test[1-5].hex are created by the TestControl.PacketTemplates
 # unit tests and have to be removed.
 CLEANFILES += test1.hex test2.hex test3.hex test4.hex test5.hex
 
-TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
-
 TESTS =
 if HAVE_GTEST
 TESTS += run_unittests
@@ -35,7 +35,6 @@ run_unittests_SOURCES += perf_socket_unittest.cc
 run_unittests_SOURCES += basic_scen_unittest.cc
 run_unittests_SOURCES += avalanche_scen_unittest.cc
 run_unittests_SOURCES += command_options_helper.h
-run_unittests_SOURCES += random_number_generator_unittest.cc
 
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS  = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
diff --git a/src/bin/perfdhcp/tests/random_number_generator_unittest.cc b/src/bin/perfdhcp/tests/random_number_generator_unittest.cc
deleted file mode 100644 (file)
index be7abe4..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (C) 2010-2021 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#include <config.h>
-
-#include <perfdhcp/random_number_generator.h>
-
-#include <gtest/gtest.h>
-#include <boost/shared_ptr.hpp>
-
-#include <iostream>
-
-using namespace isc;
-using namespace isc::perfdhcp;
-using namespace std;
-
-/// \brief Test Fixture Class for uniform random number generator
-///
-/// The hard part for this test is how to test that the number is random?
-/// and how to test that the number is uniformly distributed?
-/// Or maybe we can trust the boost implementation
-class UniformRandomIntegerGeneratorTest : public ::testing::Test {
-public:
-    UniformRandomIntegerGeneratorTest():
-        gen_(min_, max_)
-    {
-    }
-    virtual ~UniformRandomIntegerGeneratorTest(){}
-
-    int gen() { return (gen_()); }
-    int max() const { return (max_); }
-    int min() const { return (min_); }
-
-private:
-    UniformRandomIntegerGenerator gen_;
-
-    const static int min_ = 1;
-    const static int max_ = 10;
-};
-
-// Test of the generated integers are in the range [min, max]
-TEST_F(UniformRandomIntegerGeneratorTest, IntegerRange) {
-    vector<int> numbers;
-
-    // Generate a lot of random integers
-    for (int i = 0; i < max()*10; ++i) {
-        numbers.push_back(gen());
-    }
-
-    // Remove the duplicated values
-    sort(numbers.begin(), numbers.end());
-    vector<int>::iterator it = unique(numbers.begin(), numbers.end());
-
-    // make sure the numbers are in range [min, max]
-    ASSERT_EQ(it - numbers.begin(), max() - min() + 1);
-}