22 void add(
const int value)
36 ASSERT_TRUE(m > low && m < hi) << title <<
' ' <<
to_string() <<
" outside of range=(" << low <<
',' << hi <<
')';
66 const unsigned int skew_factor,
71 const Time::Duration after =
TimeSkew::skew(dur, skew_factor, prng);
72 md.
mean.
add(
static_cast<int>(after.to_binary_ms()));
73 md.
dev.
add(
my_abs(
int(dur.to_binary_ms()) -
int(after.to_binary_ms())));
75 OPENVPN_LOG(
"BEFORE=" << dur.to_binary_ms() <<
" AFTER=" << after.to_binary_ms());
82 for (
int i = 0; i < 10000; ++i)
107 if (sec != last_sec || frac != last_frac)
118 const Time::Duration d = t1 - t2;
121 ASSERT_GE(d.raw(), 100000U);
123 ASSERT_EQ(d.raw(), 0U);
126static void sub(
const Time::Duration &d1,
const Time::Duration &d2)
128 const Time::Duration d = d1 - d2;
130 Time::Duration x = d1;
132 ASSERT_EQ(x, d) <<
"D-D INCONSISTENCY DETECTED";
135static void add(
const Time &t1,
const Time::Duration &d1)
137 const Time t = t1 + d1;
141 ASSERT_EQ(x, t) <<
"T+D INCONSISTENCY DETECTED";
144static void add(
const Time::Duration &d1,
const Time::Duration &d2)
146 const Time::Duration d = d1 + d2;
148 Time::Duration x = d1;
150 ASSERT_EQ(x, d) <<
"D+D INCONSISTENCY DETECTED";
158 sub(now, now,
false);
160 sub(now, inf,
false);
161 sub(inf, inf,
false);
164 const Time::Duration sec = Time::Duration::seconds(1);
174 const Time::Duration df = Time::Duration::seconds(1);
182 const Time::Duration sec = Time::Duration::seconds(1);
void add(const int value)
std::string to_string() const
void check_mean_range(const std::string &title, const int low, const int hi) const
Abstract base class for random number generators.
static TimeType infinite()
base_type seconds_since_epoch() const
T fractional_binary_ms() const
#define OPENVPN_LOG(args)
std::string printfmt(const std::string &fmt, Args... args)
std::string to_string() const
static Time::Duration skew(const Time::Duration &dur, const unsigned int factor, RandomAPI &prng)
void test_skew(const Time::Duration &dur, const unsigned int skew_factor, MeanDev &md, const bool verbose, RandomAPI &prng)
int my_abs(const int value)
static void add(const Time &t1, const Time::Duration &d1)
static void sub(const Time &t1, const Time &t2, bool large)