Bug Summary

File:home/fedora/workspace/kea-dev/clang-static-analyzer/build/meson-private/tmpk3qwau10/../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc
Warning:line 539, column 10
Value stored to 'start_time' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name monitored_duration_unittests.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/fedora/workspace/kea-dev/clang-static-analyzer/build/meson-private/tmpk3qwau10 -fcoverage-compilation-dir=/home/fedora/workspace/kea-dev/clang-static-analyzer/build/meson-private/tmpk3qwau10 -resource-dir /usr/bin/../lib/clang/22 -I src/hooks/dhcp/perfmon/tests/dhcp-perfmon-lib-tests.p -I src/hooks/dhcp/perfmon/tests -I ../../../src/hooks/dhcp/perfmon/tests -I src/hooks/dhcp -I ../../../src/hooks/dhcp -I . -I ../../.. -I src -I ../../../src -I src/bin -I ../../../src/bin -I src/lib -I ../../../src/lib -I /usr/src/googletest/googletest -I /usr/src/googletest/googletest/include -I /usr/include -D _GLIBCXX_ASSERTIONS=1 -D _FILE_OFFSET_BITS=64 -D BOOST_ALL_NO_LIB -D PERFMON_LIB_SO="/home/fedora/workspace/kea-dev/clang-static-analyzer/build/meson-private/tmpk3qwau10/src/hooks/dhcp/perfmon/libdhcp_perfmon.so" -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16/backward -internal-isystem /usr/bin/../lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wwrite-strings -Wno-missing-field-initializers -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -fdwarf2-cfi-asm -o /home/fedora/workspace/kea-dev/clang-static-analyzer/build/meson-logs/scanbuild/2026-09-28-125224-4737-1 -x c++ ../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc
1// Copyright (C) 2024-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <cc/data.h>
10#include <dhcp/dhcp6.h>
11#include <perfmon/monitored_duration.h>
12#include <testutils/gtest_utils.h>
13#include <testutils/test_to_element.h>
14#include <util/boost_time_utils.h>
15
16#include <sstream>
17#include <unordered_set>
18
19#include <gtest/gtest.h>
20
21using namespace isc;
22using namespace isc::data;
23using namespace isc::dhcp;
24using namespace isc::perfmon;
25using namespace isc::util;
26using namespace isc::test;
27using namespace boost::posix_time;
28
29namespace {
30
31// Exercises the basic functions of DurationDataInterval.
32TEST(DurationDataInterval, basics)static_assert(sizeof("DurationDataInterval") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("basics") > 1, "test_name must not be empty"
); class DurationDataInterval_basics_Test : public ::testing::
Test { public: DurationDataInterval_basics_Test() = default; ~
DurationDataInterval_basics_Test() override = default; DurationDataInterval_basics_Test
(const DurationDataInterval_basics_Test &) = delete; DurationDataInterval_basics_Test
& operator=( const DurationDataInterval_basics_Test &
) = delete; DurationDataInterval_basics_Test (DurationDataInterval_basics_Test
&&) noexcept = delete; DurationDataInterval_basics_Test
& operator=( DurationDataInterval_basics_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const DurationDataInterval_basics_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "DurationDataInterval"
, "basics", nullptr, nullptr, ::testing::internal::CodeLocation
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 32), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 32), ::testing::internal::SuiteApiResolver< ::testing::Test
>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 32), new ::testing::internal::TestFactoryImpl<DurationDataInterval_basics_Test
>); void DurationDataInterval_basics_Test::TestBody()
{
33 auto start_time = PktEvent::now();
34
35 DurationDataIntervalPtr interval;
36
37 // Default Construct a interval.
38 interval.reset(new DurationDataInterval());
39 ASSERT_TRUE(interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(interval)) ; else return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 39, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "interval", "false", "true") .c_str()) = ::testing::Message
()
;
40
41 // Verify contents.
42 // Start time is set to current time by default.
43 EXPECT_GE(interval->getStartTime(), start_time)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperGE("interval->getStartTime()"
, "start_time", interval->getStartTime(), start_time))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 43, gtest_ar.failure_message()) = ::testing::Message()
;
44 EXPECT_EQ(interval->getOccurrences(), 0U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()"
, "0U", interval->getOccurrences(), 0U))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 44, gtest_ar.failure_message()) = ::testing::Message()
;
45 EXPECT_EQ(interval->getMinDuration(), pos_infin)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()"
, "pos_infin", interval->getMinDuration(), pos_infin))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 45, gtest_ar.failure_message()) = ::testing::Message()
;
46 EXPECT_EQ(interval->getMaxDuration(), neg_infin)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()"
, "neg_infin", interval->getMaxDuration(), neg_infin))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 46, gtest_ar.failure_message()) = ::testing::Message()
;
47 EXPECT_EQ(interval->getTotalDuration(), DurationDataInterval::ZERO_DURATION())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()"
, "DurationDataInterval::ZERO_DURATION()", interval->getTotalDuration
(), DurationDataInterval::ZERO_DURATION()))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 47, gtest_ar.failure_message()) = ::testing::Message()
;
48 EXPECT_EQ(interval->getMeanDuration(), DurationDataInterval::ZERO_DURATION())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMeanDuration()"
, "DurationDataInterval::ZERO_DURATION()", interval->getMeanDuration
(), DurationDataInterval::ZERO_DURATION()))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 48, gtest_ar.failure_message()) = ::testing::Message()
;
49
50 // Verify that start time can be specified.
51 interval.reset(new DurationDataInterval(start_time + milliseconds(5000)));
52 ASSERT_TRUE(interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(interval)) ; else return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 52, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "interval", "false", "true") .c_str()) = ::testing::Message
()
;
53 EXPECT_EQ(interval->getStartTime() - start_time, milliseconds(5000))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getStartTime() - start_time"
, "milliseconds(5000)", interval->getStartTime() - start_time
, milliseconds(5000)))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 53, gtest_ar.failure_message()) = ::testing::Message()
;
54
55 // Add 100ms duration and check contents.
56 Duration d100(milliseconds(100));
57 interval->addDuration(d100);
58 EXPECT_EQ(interval->getOccurrences(), 1U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()"
, "1U", interval->getOccurrences(), 1U))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 58, gtest_ar.failure_message()) = ::testing::Message()
;
59 EXPECT_EQ(interval->getMinDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()"
, "d100", interval->getMinDuration(), d100))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 59, gtest_ar.failure_message()) = ::testing::Message()
;
60 EXPECT_EQ(interval->getMaxDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()"
, "d100", interval->getMaxDuration(), d100))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 60, gtest_ar.failure_message()) = ::testing::Message()
;
61 EXPECT_EQ(interval->getTotalDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()"
, "d100", interval->getTotalDuration(), d100))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 61, gtest_ar.failure_message()) = ::testing::Message()
;
62 EXPECT_EQ(interval->getMeanDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMeanDuration()"
, "d100", interval->getMeanDuration(), d100))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 62, gtest_ar.failure_message()) = ::testing::Message()
;
63
64 // Add 300ms duration and check contents.
65 Duration d300(milliseconds(300));
66 interval->addDuration(d300);
67 EXPECT_EQ(interval->getOccurrences(), 2U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()"
, "2U", interval->getOccurrences(), 2U))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 67, gtest_ar.failure_message()) = ::testing::Message()
;
68 EXPECT_EQ(interval->getMinDuration(), d100)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()"
, "d100", interval->getMinDuration(), d100))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 68, gtest_ar.failure_message()) = ::testing::Message()
;
69 EXPECT_EQ(interval->getMaxDuration(), d300)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()"
, "d300", interval->getMaxDuration(), d300))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 69, gtest_ar.failure_message()) = ::testing::Message()
;
70 EXPECT_EQ(interval->getTotalDuration(), d100 + d300)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()"
, "d100 + d300", interval->getTotalDuration(), d100 + d300
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 70, gtest_ar.failure_message()) = ::testing::Message()
;
71 EXPECT_EQ(interval->getMeanDuration(), Duration(milliseconds(200)))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMeanDuration()"
, "Duration(milliseconds(200))", interval->getMeanDuration
(), Duration(milliseconds(200))))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 71, gtest_ar.failure_message()) = ::testing::Message()
;
72
73 // Add 50ms duration and check contents.
74 Duration d50(milliseconds(50));
75 interval->addDuration(d50);
76 EXPECT_EQ(interval->getOccurrences(), 3U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()"
, "3U", interval->getOccurrences(), 3U))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 76, gtest_ar.failure_message()) = ::testing::Message()
;
77 EXPECT_EQ(interval->getMinDuration(), d50)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()"
, "d50", interval->getMinDuration(), d50))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 77, gtest_ar.failure_message()) = ::testing::Message()
;
78 EXPECT_EQ(interval->getMaxDuration(), d300)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()"
, "d300", interval->getMaxDuration(), d300))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 78, gtest_ar.failure_message()) = ::testing::Message()
;
79 EXPECT_EQ(interval->getTotalDuration(), d100 + d300 + d50)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()"
, "d100 + d300 + d50", interval->getTotalDuration(), d100 +
d300 + d50))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 79, gtest_ar.failure_message()) = ::testing::Message()
;
80 EXPECT_EQ(interval->getMeanDuration(), Duration(milliseconds(150)))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMeanDuration()"
, "Duration(milliseconds(150))", interval->getMeanDuration
(), Duration(milliseconds(150))))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 80, gtest_ar.failure_message()) = ::testing::Message()
;
81
82 // Add a zero duration and check contents.
83 interval->addDuration(DurationDataInterval::ZERO_DURATION());
84 EXPECT_EQ(interval->getOccurrences(), 4U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getOccurrences()"
, "4U", interval->getOccurrences(), 4U))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 84, gtest_ar.failure_message()) = ::testing::Message()
;
85 EXPECT_EQ(interval->getMinDuration(), DurationDataInterval::ZERO_DURATION())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMinDuration()"
, "DurationDataInterval::ZERO_DURATION()", interval->getMinDuration
(), DurationDataInterval::ZERO_DURATION()))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 85, gtest_ar.failure_message()) = ::testing::Message()
;
86 EXPECT_EQ(interval->getMaxDuration(), d300)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMaxDuration()"
, "d300", interval->getMaxDuration(), d300))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 86, gtest_ar.failure_message()) = ::testing::Message()
;
87 EXPECT_EQ(interval->getTotalDuration(), d100 + d300 + d50)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getTotalDuration()"
, "d100 + d300 + d50", interval->getTotalDuration(), d100 +
d300 + d50))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 87, gtest_ar.failure_message()) = ::testing::Message()
;
88 EXPECT_EQ(interval->getMeanDuration(), Duration(microseconds(112500)))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("interval->getMeanDuration()"
, "Duration(microseconds(112500))", interval->getMeanDuration
(), Duration(microseconds(112500))))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 88, gtest_ar.failure_message()) = ::testing::Message()
;
89}
90
91// Exercises the basic functions of DurationDataInterval.
92TEST(DurationKey, basics)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("basics") > 1, "test_name must not be empty"
); class DurationKey_basics_Test : public ::testing::Test { public
: DurationKey_basics_Test() = default; ~DurationKey_basics_Test
() override = default; DurationKey_basics_Test (const DurationKey_basics_Test
&) = delete; DurationKey_basics_Test & operator=( const
DurationKey_basics_Test &) = delete; DurationKey_basics_Test
(DurationKey_basics_Test &&) noexcept = delete; DurationKey_basics_Test
& operator=( DurationKey_basics_Test &&) noexcept
= delete; private: void TestBody() override; [[maybe_unused]
] static ::testing::TestInfo* const test_info_; }; ::testing::
TestInfo* const DurationKey_basics_Test::test_info_ = ::testing
::internal::MakeAndRegisterTestInfo( "DurationKey", "basics",
nullptr, nullptr, ::testing::internal::CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 92), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 92), ::testing::internal::SuiteApiResolver< ::testing::Test
>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 92), new ::testing::internal::TestFactoryImpl<DurationKey_basics_Test
>); void DurationKey_basics_Test::TestBody()
{
93 DurationKeyPtr key;
94
95 // Create valid v4 key, verify contents and label.
96 ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER,
"process_started", "process_completed", SUBNET_ID_GLOBAL)); }
catch (const std::exception& ex) { return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 98, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 98, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw non-std::exception"; } }
97 "process_started", "process_completed",{ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER,
"process_started", "process_completed", SUBNET_ID_GLOBAL)); }
catch (const std::exception& ex) { return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 98, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 98, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw non-std::exception"; } }
98 SUBNET_ID_GLOBAL))){ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER,
"process_started", "process_completed", SUBNET_ID_GLOBAL)); }
catch (const std::exception& ex) { return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 98, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 98, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw non-std::exception"; } }
;
99 ASSERT_TRUE(key)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(key)) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 99, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "key", "false", "true") .c_str()) = ::testing::Message()
;
100 EXPECT_EQ(key->getFamily(), AF_INET)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getFamily()"
, "2", key->getFamily(), 2))) ; else ::testing::internal::
AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 100, gtest_ar.failure_message()) = ::testing::Message()
;
101 EXPECT_EQ(key->getQueryType(), DHCPDISCOVER)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getQueryType()"
, "DHCPDISCOVER", key->getQueryType(), DHCPDISCOVER))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 101, gtest_ar.failure_message()) = ::testing::Message()
;
102 EXPECT_EQ(key->getResponseType(), DHCPOFFER)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getResponseType()"
, "DHCPOFFER", key->getResponseType(), DHCPOFFER))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 102, gtest_ar.failure_message()) = ::testing::Message()
;
103 EXPECT_EQ(key->getStartEventLabel(), "process_started")switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getStartEventLabel()"
, "\"process_started\"", key->getStartEventLabel(), "process_started"
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 103, gtest_ar.failure_message()) = ::testing::Message()
;
104 EXPECT_EQ(key->getStopEventLabel(), "process_completed")switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getStopEventLabel()"
, "\"process_completed\"", key->getStopEventLabel(), "process_completed"
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 104, gtest_ar.failure_message()) = ::testing::Message()
;
105 EXPECT_EQ(key->getSubnetId(), SUBNET_ID_GLOBAL)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getSubnetId()"
, "SUBNET_ID_GLOBAL", key->getSubnetId(), SUBNET_ID_GLOBAL
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 105, gtest_ar.failure_message()) = ::testing::Message()
;
106 EXPECT_EQ("DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0",switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\""
, "key->getLabel()", "DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0"
, key->getLabel()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 107, gtest_ar.failure_message()) = ::testing::Message()
107 key->getLabel())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\""
, "key->getLabel()", "DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0"
, key->getLabel()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 107, gtest_ar.failure_message()) = ::testing::Message()
;
108 EXPECT_EQ("perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.mean-usecs",switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.mean-usecs\""
, "key->getStatName(\"mean-usecs\")", "perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.mean-usecs"
, key->getStatName("mean-usecs")))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 109, gtest_ar.failure_message()) = ::testing::Message()
109 key->getStatName("mean-usecs"))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.mean-usecs\""
, "key->getStatName(\"mean-usecs\")", "perfmon.DHCPDISCOVER-DHCPOFFER.process_started-process_completed.mean-usecs"
, key->getStatName("mean-usecs")))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 109, gtest_ar.failure_message()) = ::testing::Message()
;
110
111 // Create valid v6 key, verify contents and label.
112 ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,{ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE
, "mt_queued", "process_started", 77)); } catch (const std::exception
& ex) { return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 113, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 113, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw non-std::exception"; } }
113 "mt_queued", "process_started", 77))){ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE
, "mt_queued", "process_started", 77)); } catch (const std::exception
& ex) { return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 113, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 113, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw non-std::exception"; } }
;
114 ASSERT_TRUE(key)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(key)) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 114, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "key", "false", "true") .c_str()) = ::testing::Message()
;
115 EXPECT_EQ(key->getFamily(), AF_INET6)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getFamily()"
, "10", key->getFamily(), 10))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 115, gtest_ar.failure_message()) = ::testing::Message()
;
116 EXPECT_EQ(key->getQueryType(), DHCPV6_SOLICIT)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getQueryType()"
, "DHCPV6_SOLICIT", key->getQueryType(), DHCPV6_SOLICIT)))
; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 116, gtest_ar.failure_message()) = ::testing::Message()
;
117 EXPECT_EQ(key->getResponseType(), DHCPV6_ADVERTISE)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getResponseType()"
, "DHCPV6_ADVERTISE", key->getResponseType(), DHCPV6_ADVERTISE
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 117, gtest_ar.failure_message()) = ::testing::Message()
;
118 EXPECT_EQ(key->getStartEventLabel(), "mt_queued")switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getStartEventLabel()"
, "\"mt_queued\"", key->getStartEventLabel(), "mt_queued")
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 118, gtest_ar.failure_message()) = ::testing::Message()
;
119 EXPECT_EQ(key->getStopEventLabel(), "process_started")switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getStopEventLabel()"
, "\"process_started\"", key->getStopEventLabel(), "process_started"
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 119, gtest_ar.failure_message()) = ::testing::Message()
;
120 EXPECT_EQ(key->getSubnetId(), 77U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("key->getSubnetId()"
, "77U", key->getSubnetId(), 77U))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 120, gtest_ar.failure_message()) = ::testing::Message()
;
121 EXPECT_EQ("SOLICIT-ADVERTISE.mt_queued-process_started.77",switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"SOLICIT-ADVERTISE.mt_queued-process_started.77\""
, "key->getLabel()", "SOLICIT-ADVERTISE.mt_queued-process_started.77"
, key->getLabel()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 122, gtest_ar.failure_message()) = ::testing::Message()
122 key->getLabel())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"SOLICIT-ADVERTISE.mt_queued-process_started.77\""
, "key->getLabel()", "SOLICIT-ADVERTISE.mt_queued-process_started.77"
, key->getLabel()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 122, gtest_ar.failure_message()) = ::testing::Message()
;
123 EXPECT_EQ("subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.mean-usecs",switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.mean-usecs\""
, "key->getStatName(\"mean-usecs\")", "subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.mean-usecs"
, key->getStatName("mean-usecs")))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 124, gtest_ar.failure_message()) = ::testing::Message()
124 key->getStatName("mean-usecs"))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.mean-usecs\""
, "key->getStatName(\"mean-usecs\")", "subnet-id[77].perfmon.SOLICIT-ADVERTISE.mt_queued-process_started.mean-usecs"
, key->getStatName("mean-usecs")))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 124, gtest_ar.failure_message()) = ::testing::Message()
;
125
126 // Make sure constructor catches an insane message pairing.
127 ASSERT_THROW_MSG(key.reset(new DurationKey(AF_INET6, DHCPV6_ADVERTISE, DHCPV6_SOLICIT,{ try { key.reset(new DurationKey(10, DHCPV6_ADVERTISE, DHCPV6_SOLICIT
, "mt_queued", "process_started", 77)); return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"Query type not supported by monitoring: ADVERTISE\"", std
::string(ex.what()), "Query type not supported by monitoring: ADVERTISE"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
128 "mt_queued", "process_started", 77)), BadValue,{ try { key.reset(new DurationKey(10, DHCPV6_ADVERTISE, DHCPV6_SOLICIT
, "mt_queued", "process_started", 77)); return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"Query type not supported by monitoring: ADVERTISE\"", std
::string(ex.what()), "Query type not supported by monitoring: ADVERTISE"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
129 "Query type not supported by monitoring: ADVERTISE"){ try { key.reset(new DurationKey(10, DHCPV6_ADVERTISE, DHCPV6_SOLICIT
, "mt_queued", "process_started", 77)); return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"Query type not supported by monitoring: ADVERTISE\"", std
::string(ex.what()), "Query type not supported by monitoring: ADVERTISE"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 129, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
;
130}
131
132// Verify v4 message pair validation works.
133TEST(DurationKey, validateMessagePairs4)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("validateMessagePairs4") > 1, "test_name must not be empty"
); class DurationKey_validateMessagePairs4_Test : public ::testing
::Test { public: DurationKey_validateMessagePairs4_Test() = default
; ~DurationKey_validateMessagePairs4_Test() override = default
; DurationKey_validateMessagePairs4_Test (const DurationKey_validateMessagePairs4_Test
&) = delete; DurationKey_validateMessagePairs4_Test &
operator=( const DurationKey_validateMessagePairs4_Test &
) = delete; DurationKey_validateMessagePairs4_Test (DurationKey_validateMessagePairs4_Test
&&) noexcept = delete; DurationKey_validateMessagePairs4_Test
& operator=( DurationKey_validateMessagePairs4_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const DurationKey_validateMessagePairs4_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "DurationKey"
, "validateMessagePairs4", nullptr, nullptr, ::testing::internal
::CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 133), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 133), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 133), new ::testing::internal::TestFactoryImpl<DurationKey_validateMessagePairs4_Test
>); void DurationKey_validateMessagePairs4_Test::TestBody(
)
{
134 // Defines a test scenario.
135 struct Scenario {
136 // Query type to use in the scenario.
137 uint8_t query_type_;
138 // Valid response types for query type (if any).
139 std::unordered_set<uint8_t> valid_responses_;
140 };
141
142 // List of scenarios to test, one per v4 message type.
143 std::list<Scenario> scenarios {
144 {DHCP_NOTYPE, {DHCP_NOTYPE, DHCPOFFER, DHCPACK, DHCPNAK}},
145 {DHCPDISCOVER, {DHCP_NOTYPE, DHCPOFFER, DHCPNAK}},
146 {DHCPOFFER, {}},
147 {DHCPREQUEST, {DHCP_NOTYPE, DHCPACK, DHCPNAK}},
148 {DHCPDECLINE, {}},
149 {DHCPACK, {}},
150 {DHCPNAK, {}},
151 {DHCPRELEASE, {}},
152 {DHCPINFORM, {DHCP_NOTYPE, DHCPACK}},
153// {DHCPFORCERENEW, {}}, commented out in dhcp4.h
154 {DHCPLEASEQUERY, {}},
155 {DHCPLEASEUNASSIGNED, {}},
156 {DHCPLEASEUNKNOWN, {}},
157 {DHCPLEASEACTIVE, {}},
158 {DHCPBULKLEASEQUERY, {}},
159 {DHCPLEASEQUERYDONE, {}},
160// {DHCPACTIVELEASEQUERY, {}}, commented out in dhcp4.h
161 {DHCPLEASEQUERYSTATUS, {}},
162 {DHCPTLS, {}},
163 };
164
165 // Iterate over the scenarios. Attempt to pair each scenario query type with every v4 message
166 // type as a response type. If the response type is in the scenario's valid list, the pair
167 // should validate, otherwise it should throw.
168 for (auto const& scenario : scenarios) {
169 for (uint8_t response_type = DHCP_NOTYPE; response_type < DHCP_TYPES_EOF; ++response_type) {
170 if (scenario.valid_responses_.count(response_type)) {
171 ASSERT_NO_THROW_LOG({ try { DurationKey::validateMessagePair(2, scenario.query_type_
, response_type); } catch (const std::exception& ex) { return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 172, "Failed") = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 172, "Failed") = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)"
<< " threw non-std::exception"; } }
172 DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)){ try { DurationKey::validateMessagePair(2, scenario.query_type_
, response_type); } catch (const std::exception& ex) { return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 172, "Failed") = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 172, "Failed") = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type)"
<< " threw non-std::exception"; } }
;
173 } else {
174 ASSERT_THROW(switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { bool gtest_caught_expected = false; try { if (
::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair
(2, scenario.query_type_, response_type); } else static_assert
(true, ""); } catch (BadValue const&) { gtest_caught_expected
= true; } catch (typename std::conditional< std::is_same<
typename std::remove_cv<typename std::remove_reference<
BadValue>::type>::type, std::exception>::value, const
::testing::internal::NeverThrown&, const std::exception&
>::type e) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws "
; gtest_msg.value += ::testing::internal::GetTypeName(typeid(
e)); gtest_msg.value += " with description \""; gtest_msg.value
+= e.what(); gtest_msg.value += "\"."; goto gtest_label_testthrow_176
; } catch (...) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws a different type."
; goto gtest_label_testthrow_176; } if (!gtest_caught_expected
) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws nothing."
; goto gtest_label_testthrow_176; } } else gtest_label_testthrow_176
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 176, gtest_msg.value.c_str()) = ::testing::Message()
175 DurationKey::validateMessagePair(AF_INET, scenario.query_type_, response_type),switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { bool gtest_caught_expected = false; try { if (
::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair
(2, scenario.query_type_, response_type); } else static_assert
(true, ""); } catch (BadValue const&) { gtest_caught_expected
= true; } catch (typename std::conditional< std::is_same<
typename std::remove_cv<typename std::remove_reference<
BadValue>::type>::type, std::exception>::value, const
::testing::internal::NeverThrown&, const std::exception&
>::type e) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws "
; gtest_msg.value += ::testing::internal::GetTypeName(typeid(
e)); gtest_msg.value += " with description \""; gtest_msg.value
+= e.what(); gtest_msg.value += "\"."; goto gtest_label_testthrow_176
; } catch (...) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws a different type."
; goto gtest_label_testthrow_176; } if (!gtest_caught_expected
) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws nothing."
; goto gtest_label_testthrow_176; } } else gtest_label_testthrow_176
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 176, gtest_msg.value.c_str()) = ::testing::Message()
176 BadValue)switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { bool gtest_caught_expected = false; try { if (
::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair
(2, scenario.query_type_, response_type); } else static_assert
(true, ""); } catch (BadValue const&) { gtest_caught_expected
= true; } catch (typename std::conditional< std::is_same<
typename std::remove_cv<typename std::remove_reference<
BadValue>::type>::type, std::exception>::value, const
::testing::internal::NeverThrown&, const std::exception&
>::type e) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws "
; gtest_msg.value += ::testing::internal::GetTypeName(typeid(
e)); gtest_msg.value += " with description \""; gtest_msg.value
+= e.what(); gtest_msg.value += "\"."; goto gtest_label_testthrow_176
; } catch (...) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws a different type."
; goto gtest_label_testthrow_176; } if (!gtest_caught_expected
) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(2, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws nothing."
; goto gtest_label_testthrow_176; } } else gtest_label_testthrow_176
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 176, gtest_msg.value.c_str()) = ::testing::Message()
;
177 }
178 }
179 }
180}
181
182// Verify v6 message pair validation works.
183TEST(DurationKey, validateMessagePairs6)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("validateMessagePairs6") > 1, "test_name must not be empty"
); class DurationKey_validateMessagePairs6_Test : public ::testing
::Test { public: DurationKey_validateMessagePairs6_Test() = default
; ~DurationKey_validateMessagePairs6_Test() override = default
; DurationKey_validateMessagePairs6_Test (const DurationKey_validateMessagePairs6_Test
&) = delete; DurationKey_validateMessagePairs6_Test &
operator=( const DurationKey_validateMessagePairs6_Test &
) = delete; DurationKey_validateMessagePairs6_Test (DurationKey_validateMessagePairs6_Test
&&) noexcept = delete; DurationKey_validateMessagePairs6_Test
& operator=( DurationKey_validateMessagePairs6_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const DurationKey_validateMessagePairs6_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "DurationKey"
, "validateMessagePairs6", nullptr, nullptr, ::testing::internal
::CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 183), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 183), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 183), new ::testing::internal::TestFactoryImpl<DurationKey_validateMessagePairs6_Test
>); void DurationKey_validateMessagePairs6_Test::TestBody(
)
{
184 // Defines a test scenario.
185 struct Scenario {
186 // Query type to use in the scenario.
187 uint8_t query_type_;
188 // Valid response types for query type (if any).
189 std::unordered_set<uint8_t> valid_responses_;
190 };
191
192 // List of scenarios to test, one per v6 message type.
193 std::list<Scenario> scenarios {
194 {DHCPV6_NOTYPE, {DHCPV6_NOTYPE, DHCPV6_ADVERTISE, DHCPV6_REPLY}},
195 {DHCPV6_SOLICIT, {DHCPV6_NOTYPE, DHCPV6_ADVERTISE, DHCPV6_REPLY}},
196 {DHCPV6_ADVERTISE, {}},
197 {DHCPV6_REQUEST, {DHCPV6_NOTYPE, DHCPV6_REPLY}},
198 {DHCPV6_CONFIRM, {DHCPV6_NOTYPE, DHCPV6_REPLY}},
199 {DHCPV6_RENEW, {DHCPV6_NOTYPE, DHCPV6_REPLY}},
200 {DHCPV6_REBIND, {DHCPV6_NOTYPE, DHCPV6_REPLY}},
201 {DHCPV6_REPLY, {}},
202 {DHCPV6_RELEASE, {}},
203 {DHCPV6_DECLINE, {}},
204 {DHCPV6_RECONFIGURE, {}},
205 {DHCPV6_INFORMATION_REQUEST, {}},
206 {DHCPV6_RELAY_FORW, {}},
207 {DHCPV6_RELAY_REPL, {}},
208 {DHCPV6_LEASEQUERY, {}},
209 {DHCPV6_LEASEQUERY_REPLY, {}},
210 {DHCPV6_LEASEQUERY_DONE, {}},
211 {DHCPV6_LEASEQUERY_DATA, {}},
212 {DHCPV6_RECONFIGURE_REQUEST, {}},
213 {DHCPV6_RECONFIGURE_REPLY, {}},
214 {DHCPV6_DHCPV4_QUERY, {}},
215 {DHCPV6_DHCPV4_RESPONSE, {}},
216 {DHCPV6_ACTIVELEASEQUERY, {}},
217 {DHCPV6_STARTTLS, {}},
218 {DHCPV6_BNDUPD, {}},
219 {DHCPV6_BNDREPLY, {}},
220 {DHCPV6_POOLREQ, {}},
221 {DHCPV6_POOLRESP, {}},
222 {DHCPV6_UPDREQ, {}},
223 {DHCPV6_UPDREQALL, {}},
224 {DHCPV6_UPDDONE, {}},
225 {DHCPV6_CONNECT, {}},
226 {DHCPV6_CONNECTREPLY, {}},
227 {DHCPV6_DISCONNECT, {}},
228 {DHCPV6_STATE, {}},
229 {DHCPV6_CONTACT, {}}
230 };
231
232 // Iterate over the scenarios. Attempt to pair each scenario query type with every v6 message
233 // type as a response type. If the response type is in the scenario's valid list, the pair
234 // should validate, otherwise it should throw.
235 for (auto const& scenario : scenarios) {
236 for (uint8_t response_type = DHCPV6_NOTYPE; response_type < DHCPV6_TYPES_EOF; ++response_type) {
237 if (scenario.valid_responses_.count(response_type)) {
238 ASSERT_NO_THROW_LOG({ try { DurationKey::validateMessagePair(10, scenario.query_type_
, response_type); } catch (const std::exception& ex) { return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 239, "Failed") = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 239, "Failed") = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)"
<< " threw non-std::exception"; } }
239 DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)){ try { DurationKey::validateMessagePair(10, scenario.query_type_
, response_type); } catch (const std::exception& ex) { return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 239, "Failed") = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 239, "Failed") = ::testing::Message() << "DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type)"
<< " threw non-std::exception"; } }
;
240 } else {
241 ASSERT_THROW(switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { bool gtest_caught_expected = false; try { if (
::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair
(10, scenario.query_type_, response_type); } else static_assert
(true, ""); } catch (BadValue const&) { gtest_caught_expected
= true; } catch (typename std::conditional< std::is_same<
typename std::remove_cv<typename std::remove_reference<
BadValue>::type>::type, std::exception>::value, const
::testing::internal::NeverThrown&, const std::exception&
>::type e) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws "
; gtest_msg.value += ::testing::internal::GetTypeName(typeid(
e)); gtest_msg.value += " with description \""; gtest_msg.value
+= e.what(); gtest_msg.value += "\"."; goto gtest_label_testthrow_243
; } catch (...) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws a different type."
; goto gtest_label_testthrow_243; } if (!gtest_caught_expected
) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws nothing."
; goto gtest_label_testthrow_243; } } else gtest_label_testthrow_243
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 243, gtest_msg.value.c_str()) = ::testing::Message()
242 DurationKey::validateMessagePair(AF_INET6, scenario.query_type_, response_type),switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { bool gtest_caught_expected = false; try { if (
::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair
(10, scenario.query_type_, response_type); } else static_assert
(true, ""); } catch (BadValue const&) { gtest_caught_expected
= true; } catch (typename std::conditional< std::is_same<
typename std::remove_cv<typename std::remove_reference<
BadValue>::type>::type, std::exception>::value, const
::testing::internal::NeverThrown&, const std::exception&
>::type e) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws "
; gtest_msg.value += ::testing::internal::GetTypeName(typeid(
e)); gtest_msg.value += " with description \""; gtest_msg.value
+= e.what(); gtest_msg.value += "\"."; goto gtest_label_testthrow_243
; } catch (...) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws a different type."
; goto gtest_label_testthrow_243; } if (!gtest_caught_expected
) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws nothing."
; goto gtest_label_testthrow_243; } } else gtest_label_testthrow_243
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 243, gtest_msg.value.c_str()) = ::testing::Message()
243 BadValue)switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { bool gtest_caught_expected = false; try { if (
::testing::internal::AlwaysTrue()) { DurationKey::validateMessagePair
(10, scenario.query_type_, response_type); } else static_assert
(true, ""); } catch (BadValue const&) { gtest_caught_expected
= true; } catch (typename std::conditional< std::is_same<
typename std::remove_cv<typename std::remove_reference<
BadValue>::type>::type, std::exception>::value, const
::testing::internal::NeverThrown&, const std::exception&
>::type e) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws "
; gtest_msg.value += ::testing::internal::GetTypeName(typeid(
e)); gtest_msg.value += " with description \""; gtest_msg.value
+= e.what(); gtest_msg.value += "\"."; goto gtest_label_testthrow_243
; } catch (...) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws a different type."
; goto gtest_label_testthrow_243; } if (!gtest_caught_expected
) { gtest_msg.value = "Expected: " "DurationKey::validateMessagePair(10, scenario.query_type_, response_type)"
" throws an exception of type " "BadValue" ".\n Actual: it throws nothing."
; goto gtest_label_testthrow_243; } } else gtest_label_testthrow_243
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 243, gtest_msg.value.c_str()) = ::testing::Message()
;
244 }
245 }
246 }
247}
248
249/// @brief Verify DurationKey equality operator
250TEST(DurationKey, equalityOperators)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("equalityOperators") > 1, "test_name must not be empty"
); class DurationKey_equalityOperators_Test : public ::testing
::Test { public: DurationKey_equalityOperators_Test() = default
; ~DurationKey_equalityOperators_Test() override = default; DurationKey_equalityOperators_Test
(const DurationKey_equalityOperators_Test &) = delete; DurationKey_equalityOperators_Test
& operator=( const DurationKey_equalityOperators_Test &
) = delete; DurationKey_equalityOperators_Test (DurationKey_equalityOperators_Test
&&) noexcept = delete; DurationKey_equalityOperators_Test
& operator=( DurationKey_equalityOperators_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const DurationKey_equalityOperators_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "DurationKey"
, "equalityOperators", nullptr, nullptr, ::testing::internal::
CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 250), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 250), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 250), new ::testing::internal::TestFactoryImpl<DurationKey_equalityOperators_Test
>); void DurationKey_equalityOperators_Test::TestBody()
{
251 DurationKeyPtr refkey;
252 DurationKeyPtr compkey;
253
254 ASSERT_NO_THROW_LOG(refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY,{ try { refkey.reset(new DurationKey(10, DHCPV6_REQUEST, DHCPV6_REPLY
, "event_2", "event_3", 100)); } catch (const std::exception&
ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 255, "Failed") = ::testing::Message() << "refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 255, "Failed") = ::testing::Message() << "refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw non-std::exception"; } }
255 "event_2", "event_3", 100))){ try { refkey.reset(new DurationKey(10, DHCPV6_REQUEST, DHCPV6_REPLY
, "event_2", "event_3", 100)); } catch (const std::exception&
ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 255, "Failed") = ::testing::Message() << "refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 255, "Failed") = ::testing::Message() << "refkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw non-std::exception"; } }
;
256
257 ASSERT_NO_THROW_LOG(compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY,{ try { compkey.reset(new DurationKey(10, DHCPV6_REQUEST, DHCPV6_REPLY
, "event_2", "event_3", 100)); } catch (const std::exception&
ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 258, "Failed") = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 258, "Failed") = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw non-std::exception"; } }
258 "event_2", "event_3", 100))){ try { compkey.reset(new DurationKey(10, DHCPV6_REQUEST, DHCPV6_REPLY
, "event_2", "event_3", 100)); } catch (const std::exception&
ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 258, "Failed") = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 258, "Failed") = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_REQUEST, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw non-std::exception"; } }
;
259 EXPECT_EQ(*compkey, *refkey)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("*compkey"
, "*refkey", *compkey, *refkey))) ; else ::testing::internal::
AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 259, gtest_ar.failure_message()) = ::testing::Message()
;
260
261 ASSERT_NO_THROW_LOG(compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY,{ try { compkey.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_REPLY
, "event_2", "event_3", 100)); } catch (const std::exception&
ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 262, "Failed") = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 262, "Failed") = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw non-std::exception"; } }
262 "event_2", "event_3", 100))){ try { compkey.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_REPLY
, "event_2", "event_3", 100)); } catch (const std::exception&
ex) { return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 262, "Failed") = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 262, "Failed") = ::testing::Message() << "compkey.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_REPLY, \"event_2\", \"event_3\", 100))"
<< " threw non-std::exception"; } }
;
263 EXPECT_NE(*compkey, *refkey)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("*compkey", "*refkey"
, *compkey, *refkey))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 263, gtest_ar.failure_message()) = ::testing::Message()
;
264}
265
266// Verifies the DurationKey::toElement()
267TEST(DurationKey, toElement)static_assert(sizeof("DurationKey") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("toElement") > 1, "test_name must not be empty"
); class DurationKey_toElement_Test : public ::testing::Test {
public: DurationKey_toElement_Test() = default; ~DurationKey_toElement_Test
() override = default; DurationKey_toElement_Test (const DurationKey_toElement_Test
&) = delete; DurationKey_toElement_Test & operator=(
const DurationKey_toElement_Test &) = delete; DurationKey_toElement_Test
(DurationKey_toElement_Test &&) noexcept = delete; DurationKey_toElement_Test
& operator=( DurationKey_toElement_Test &&) noexcept
= delete; private: void TestBody() override; [[maybe_unused]
] static ::testing::TestInfo* const test_info_; }; ::testing::
TestInfo* const DurationKey_toElement_Test::test_info_ = ::testing
::internal::MakeAndRegisterTestInfo( "DurationKey", "toElement"
, nullptr, nullptr, ::testing::internal::CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 267), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 267), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 267), new ::testing::internal::TestFactoryImpl<DurationKey_toElement_Test
>); void DurationKey_toElement_Test::TestBody()
{
268 DurationKeyPtr key;
269
270 // Create valid v4 key, verify contents and label.
271 ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER,
"process_started", "process_completed", SUBNET_ID_GLOBAL)); }
catch (const std::exception& ex) { return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 273, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 273, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw non-std::exception"; } }
272 "process_started", "process_completed",{ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER,
"process_started", "process_completed", SUBNET_ID_GLOBAL)); }
catch (const std::exception& ex) { return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 273, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 273, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw non-std::exception"; } }
273 SUBNET_ID_GLOBAL))){ try { key.reset(new DurationKey(2, DHCPDISCOVER, DHCPOFFER,
"process_started", "process_completed", SUBNET_ID_GLOBAL)); }
catch (const std::exception& ex) { return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 273, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 273, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL))"
<< " threw non-std::exception"; } }
;
274 ASSERT_TRUE(key)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(key)) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 274, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "key", "false", "true") .c_str()) = ::testing::Message()
;
275
276 std::string expected_json =
277 R"({
278 "query-type": "DHCPDISCOVER",
279 "response-type": "DHCPOFFER",
280 "start-event": "process_started",
281 "stop-event": "process_completed",
282 "subnet-id": 0
283 })";
284
285 runToElementTest(expected_json, *key);
286
287 // Create valid v6 key, verify contents and label.
288 ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,{ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE
, "mt_queued", "process_started", 77)); } catch (const std::exception
& ex) { return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 289, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 289, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw non-std::exception"; } }
289 "mt_queued", "process_started", 77))){ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE
, "mt_queued", "process_started", 77)); } catch (const std::exception
& ex) { return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 289, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 289, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw non-std::exception"; } }
;
290 ASSERT_TRUE(key)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(key)) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 290, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "key", "false", "true") .c_str()) = ::testing::Message()
;
291
292 expected_json =
293 R"({
294 "query-type": "SOLICIT",
295 "response-type": "ADVERTISE",
296 "start-event": "mt_queued",
297 "stop-event": "process_started",
298 "subnet-id": 77
299 })";
300
301 runToElementTest(expected_json, *key);
302}
303
304// Verifies MonitoredDuration valid construction.
305TEST(MonitoredDuration, validConstructors)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("validConstructors") > 1, "test_name must not be empty"
); class MonitoredDuration_validConstructors_Test : public ::
testing::Test { public: MonitoredDuration_validConstructors_Test
() = default; ~MonitoredDuration_validConstructors_Test() override
= default; MonitoredDuration_validConstructors_Test (const MonitoredDuration_validConstructors_Test
&) = delete; MonitoredDuration_validConstructors_Test &
operator=( const MonitoredDuration_validConstructors_Test &
) = delete; MonitoredDuration_validConstructors_Test (MonitoredDuration_validConstructors_Test
&&) noexcept = delete; MonitoredDuration_validConstructors_Test
& operator=( MonitoredDuration_validConstructors_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const MonitoredDuration_validConstructors_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration"
, "validConstructors", nullptr, nullptr, ::testing::internal::
CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 305), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 305), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 305), new ::testing::internal::TestFactoryImpl<MonitoredDuration_validConstructors_Test
>); void MonitoredDuration_validConstructors_Test::TestBody
()
{
306 MonitoredDurationPtr mond;
307 Duration interval_duration(seconds(60));
308
309 // Create valid v4 duration, verify contents and label.
310 ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 312, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 312, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
311 "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 312, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 312, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
312 SUBNET_ID_GLOBAL, interval_duration))){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 312, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 312, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
;
313 ASSERT_TRUE(mond)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(mond)) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 313, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond", "false", "true") .c_str()) = ::testing::Message()
;
314 EXPECT_EQ(mond->getFamily(), AF_INET)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getFamily()"
, "2", mond->getFamily(), 2))) ; else ::testing::internal::
AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 314, gtest_ar.failure_message()) = ::testing::Message()
;
315 EXPECT_EQ(mond->getQueryType(), DHCPDISCOVER)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getQueryType()"
, "DHCPDISCOVER", mond->getQueryType(), DHCPDISCOVER))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 315, gtest_ar.failure_message()) = ::testing::Message()
;
316 EXPECT_EQ(mond->getResponseType(), DHCPOFFER)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getResponseType()"
, "DHCPOFFER", mond->getResponseType(), DHCPOFFER))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 316, gtest_ar.failure_message()) = ::testing::Message()
;
317 EXPECT_EQ(mond->getStartEventLabel(), "process_started")switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getStartEventLabel()"
, "\"process_started\"", mond->getStartEventLabel(), "process_started"
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 317, gtest_ar.failure_message()) = ::testing::Message()
;
318 EXPECT_EQ(mond->getStopEventLabel(), "process_completed")switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getStopEventLabel()"
, "\"process_completed\"", mond->getStopEventLabel(), "process_completed"
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 318, gtest_ar.failure_message()) = ::testing::Message()
;
319 EXPECT_EQ(mond->getSubnetId(), SUBNET_ID_GLOBAL)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getSubnetId()"
, "SUBNET_ID_GLOBAL", mond->getSubnetId(), SUBNET_ID_GLOBAL
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 319, gtest_ar.failure_message()) = ::testing::Message()
;
320 EXPECT_EQ("DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0", mond->getLabel())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\""
, "mond->getLabel()", "DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0"
, mond->getLabel()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 320, gtest_ar.failure_message()) = ::testing::Message()
;
321 EXPECT_EQ(mond->getIntervalDuration(), interval_duration)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getIntervalDuration()"
, "interval_duration", mond->getIntervalDuration(), interval_duration
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 321, gtest_ar.failure_message()) = ::testing::Message()
;
322 EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 322, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getCurrentInterval()", "true", "false") .c_str())
= ::testing::Message()
;
323 EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 323, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
324
325 // Create valid v6 key and use that to create an alarm. Verify contents and label.
326 DurationKeyPtr key;
327 ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,{ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE
, "mt_queued", "process_started", 77)); } catch (const std::exception
& ex) { return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 328, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 328, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw non-std::exception"; } }
328 "mt_queued", "process_started", 77))){ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE
, "mt_queued", "process_started", 77)); } catch (const std::exception
& ex) { return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 328, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 328, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw non-std::exception"; } }
;
329
330 ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(*key, interval_duration))){ try { mond.reset(new MonitoredDuration(*key, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 330, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(*key, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 330, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(*key, interval_duration))"
<< " threw non-std::exception"; } }
;
331 ASSERT_TRUE(mond)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(mond)) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 331, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond", "false", "true") .c_str()) = ::testing::Message()
;
332 EXPECT_EQ(mond->getFamily(), AF_INET6)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getFamily()"
, "10", mond->getFamily(), 10))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 332, gtest_ar.failure_message()) = ::testing::Message()
;
333 EXPECT_EQ(mond->getQueryType(), DHCPV6_SOLICIT)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getQueryType()"
, "DHCPV6_SOLICIT", mond->getQueryType(), DHCPV6_SOLICIT))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 333, gtest_ar.failure_message()) = ::testing::Message()
;
334 EXPECT_EQ(mond->getResponseType(), DHCPV6_ADVERTISE)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getResponseType()"
, "DHCPV6_ADVERTISE", mond->getResponseType(), DHCPV6_ADVERTISE
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 334, gtest_ar.failure_message()) = ::testing::Message()
;
335 EXPECT_EQ(mond->getStartEventLabel(), "mt_queued")switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getStartEventLabel()"
, "\"mt_queued\"", mond->getStartEventLabel(), "mt_queued"
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 335, gtest_ar.failure_message()) = ::testing::Message()
;
336 EXPECT_EQ(mond->getStopEventLabel(), "process_started")switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getStopEventLabel()"
, "\"process_started\"", mond->getStopEventLabel(), "process_started"
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 336, gtest_ar.failure_message()) = ::testing::Message()
;
337 EXPECT_EQ(mond->getSubnetId(), 77U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getSubnetId()"
, "77U", mond->getSubnetId(), 77U))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 337, gtest_ar.failure_message()) = ::testing::Message()
;
338 EXPECT_EQ("SOLICIT-ADVERTISE.mt_queued-process_started.77", mond->getLabel())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("\"SOLICIT-ADVERTISE.mt_queued-process_started.77\""
, "mond->getLabel()", "SOLICIT-ADVERTISE.mt_queued-process_started.77"
, mond->getLabel()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 338, gtest_ar.failure_message()) = ::testing::Message()
;
339 EXPECT_EQ(mond->getIntervalDuration(), interval_duration)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getIntervalDuration()"
, "interval_duration", mond->getIntervalDuration(), interval_duration
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 339, gtest_ar.failure_message()) = ::testing::Message()
;
340 EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 340, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getCurrentInterval()", "true", "false") .c_str())
= ::testing::Message()
;
341 EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 341, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
342}
343
344// Verifies Copy construction. Since current and previous intervals are not
345// exposed, this test relies on addSample() to alter them.
346TEST(MonitoredDuration, copyConstructors)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("copyConstructors") > 1, "test_name must not be empty"
); class MonitoredDuration_copyConstructors_Test : public ::testing
::Test { public: MonitoredDuration_copyConstructors_Test() = default
; ~MonitoredDuration_copyConstructors_Test() override = default
; MonitoredDuration_copyConstructors_Test (const MonitoredDuration_copyConstructors_Test
&) = delete; MonitoredDuration_copyConstructors_Test &
operator=( const MonitoredDuration_copyConstructors_Test &
) = delete; MonitoredDuration_copyConstructors_Test (MonitoredDuration_copyConstructors_Test
&&) noexcept = delete; MonitoredDuration_copyConstructors_Test
& operator=( MonitoredDuration_copyConstructors_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const MonitoredDuration_copyConstructors_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration"
, "copyConstructors", nullptr, nullptr, ::testing::internal::
CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 346), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 346), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 346), new ::testing::internal::TestFactoryImpl<MonitoredDuration_copyConstructors_Test
>); void MonitoredDuration_copyConstructors_Test::TestBody
()
{
347 MonitoredDurationPtr mond;
348 Duration interval_duration(microseconds(10));
349
350 // Create valid v4 duration, verify contents and label.
351 ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 353, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 353, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
352 "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 353, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 353, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
353 SUBNET_ID_GLOBAL, interval_duration))){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 353, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 353, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
;
354
355 // Make a copy.
356 MonitoredDurationPtr duplicate;
357 duplicate.reset(new MonitoredDuration(*mond));
358
359 // Should have different pointers.
360 EXPECT_NE(duplicate, mond)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("duplicate", "mond"
, duplicate, mond))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 360, gtest_ar.failure_message()) = ::testing::Message()
;
361
362 // Key values should be equal (DurationKey::operator==).
363 EXPECT_EQ(*duplicate, *mond)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("*duplicate"
, "*mond", *duplicate, *mond))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 363, gtest_ar.failure_message()) = ::testing::Message()
;
364
365 // Check non-key members.
366 EXPECT_EQ(duplicate->getIntervalDuration(), mond->getIntervalDuration())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("duplicate->getIntervalDuration()"
, "mond->getIntervalDuration()", duplicate->getIntervalDuration
(), mond->getIntervalDuration()))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 366, gtest_ar.failure_message()) = ::testing::Message()
;
367 EXPECT_FALSE(duplicate->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(duplicate->getCurrentInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 367, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "duplicate->getCurrentInterval()", "true", "false") .c_str
()) = ::testing::Message()
;
368 EXPECT_FALSE(duplicate->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(duplicate->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 368, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "duplicate->getPreviousInterval()", "true", "false") .c_str
()) = ::testing::Message()
;
369
370 // Add a sample to the original.
371 EXPECT_FALSE(mond->addSample(microseconds(2)))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->addSample(
microseconds(2))))) ; else ::testing::internal::AssertHelper(
::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 371, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->addSample(microseconds(2))", "true", "false") .c_str
()) = ::testing::Message()
;
372
373 // Make a new copy.
374 duplicate.reset(new MonitoredDuration(*mond));
375
376 // Current intervals should exist.
377 ASSERT_TRUE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(mond->getCurrentInterval
())) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 377, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getCurrentInterval()", "false", "true") .c_str())
= ::testing::Message()
;
378 ASSERT_TRUE(duplicate->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(duplicate->getCurrentInterval
())) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 378, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "duplicate->getCurrentInterval()", "false", "true") .c_str
()) = ::testing::Message()
;
379 // They should not be the same object but the content should be equal.
380 EXPECT_NE(duplicate->getCurrentInterval(), mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("duplicate->getCurrentInterval()"
, "mond->getCurrentInterval()", duplicate->getCurrentInterval
(), mond->getCurrentInterval()))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 380, gtest_ar.failure_message()) = ::testing::Message()
;
381 EXPECT_EQ(*duplicate->getCurrentInterval(), *mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("*duplicate->getCurrentInterval()"
, "*mond->getCurrentInterval()", *duplicate->getCurrentInterval
(), *mond->getCurrentInterval()))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 381, gtest_ar.failure_message()) = ::testing::Message()
;
382 // Previous interval should not exist.
383 ASSERT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 383, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
384 ASSERT_FALSE(duplicate->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(duplicate->getPreviousInterval
()))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 384, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "duplicate->getPreviousInterval()", "true", "false") .c_str
()) = ::testing::Message()
;
385
386 // Sleep past interval duration.
387 usleep(20);
388
389 // Add another sample to the original.
390 EXPECT_TRUE(mond->addSample(microseconds(2)))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(mond->addSample(microseconds
(2)))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 390, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->addSample(microseconds(2))", "false", "true") .c_str
()) = ::testing::Message()
;
391
392 // Make a new copy.
393 duplicate.reset(new MonitoredDuration(*mond));
394
395 // Current intervals should exist.
396 ASSERT_TRUE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(mond->getCurrentInterval
())) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 396, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getCurrentInterval()", "false", "true") .c_str())
= ::testing::Message()
;
397 ASSERT_TRUE(duplicate->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(duplicate->getCurrentInterval
())) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 397, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "duplicate->getCurrentInterval()", "false", "true") .c_str
()) = ::testing::Message()
;
398 // They should not be the same object but the content should be equal.
399 EXPECT_NE(duplicate->getCurrentInterval(), mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("duplicate->getCurrentInterval()"
, "mond->getCurrentInterval()", duplicate->getCurrentInterval
(), mond->getCurrentInterval()))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 399, gtest_ar.failure_message()) = ::testing::Message()
;
400 EXPECT_EQ(*duplicate->getCurrentInterval(), *mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("*duplicate->getCurrentInterval()"
, "*mond->getCurrentInterval()", *duplicate->getCurrentInterval
(), *mond->getCurrentInterval()))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 400, gtest_ar.failure_message()) = ::testing::Message()
;
401
402 // Current previous should exist.
403 ASSERT_TRUE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(mond->getPreviousInterval
())) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 403, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "false", "true") .c_str()
) = ::testing::Message()
;
404 ASSERT_TRUE(duplicate->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(duplicate->getPreviousInterval
())) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 404, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "duplicate->getPreviousInterval()", "false", "true") .c_str
()) = ::testing::Message()
;
405 // They should not be the same object but the content should be equal.
406 EXPECT_NE(duplicate->getPreviousInterval(), mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("duplicate->getPreviousInterval()"
, "mond->getPreviousInterval()", duplicate->getPreviousInterval
(), mond->getPreviousInterval()))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 406, gtest_ar.failure_message()) = ::testing::Message()
;
407 EXPECT_EQ(*duplicate->getPreviousInterval(), *mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("*duplicate->getPreviousInterval()"
, "*mond->getPreviousInterval()", *duplicate->getPreviousInterval
(), *mond->getPreviousInterval()))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 407, gtest_ar.failure_message()) = ::testing::Message()
;
408}
409
410// Verifies MonitoredDuration invalid construction.
411TEST(MonitoredDuration, invalidConstructors)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("invalidConstructors") > 1, "test_name must not be empty"
); class MonitoredDuration_invalidConstructors_Test : public ::
testing::Test { public: MonitoredDuration_invalidConstructors_Test
() = default; ~MonitoredDuration_invalidConstructors_Test() override
= default; MonitoredDuration_invalidConstructors_Test (const
MonitoredDuration_invalidConstructors_Test &) = delete; MonitoredDuration_invalidConstructors_Test
& operator=( const MonitoredDuration_invalidConstructors_Test
&) = delete; MonitoredDuration_invalidConstructors_Test (
MonitoredDuration_invalidConstructors_Test &&) noexcept
= delete; MonitoredDuration_invalidConstructors_Test & operator
=( MonitoredDuration_invalidConstructors_Test &&) noexcept
= delete; private: void TestBody() override; [[maybe_unused]
] static ::testing::TestInfo* const test_info_; }; ::testing::
TestInfo* const MonitoredDuration_invalidConstructors_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration"
, "invalidConstructors", nullptr, nullptr, ::testing::internal
::CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 411), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 411), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 411), new ::testing::internal::TestFactoryImpl<MonitoredDuration_invalidConstructors_Test
>); void MonitoredDuration_invalidConstructors_Test::TestBody
()
{
412 MonitoredDurationPtr mond;
413
414 // Make sure we catch an invalid message pairing.
415 Duration interval_duration = seconds(60);
416 ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPDISCOVER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\""
, std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
417 "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\""
, std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
418 SUBNET_ID_GLOBAL, interval_duration)),{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\""
, std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
419 BadValue,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\""
, std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
420 "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER"){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPDISCOVER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER\""
, std::string(ex.what()), "Response type: DHCPDISCOVER not valid for query type: DHCPDISCOVER"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 420, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
;
421
422 // Interval duration cannot be zero.
423 interval_duration = DurationDataInterval::ZERO_DURATION();
424 ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
425 "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
426 SUBNET_ID_GLOBAL, interval_duration)),{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
427 BadValue,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
428 "MonitoredDuration - interval_duration 00:00:00,"{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
429 " is invalid, it must be greater than 0"){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 429, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
;
430
431 // Interval duration cannot be negative.
432 ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds
(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
433 "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds
(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
434 SUBNET_ID_GLOBAL, seconds(-5))),{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds
(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
435 BadValue,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds
(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
436 "MonitoredDuration - interval_duration -00:00:05,"{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds
(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
437 " is invalid, it must be greater than 0"){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, seconds
(-5))); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 437, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
;
438
439 // Create valid v6 key.
440 DurationKeyPtr key;
441 ASSERT_NO_THROW_LOG(key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,{ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE
, "mt_queued", "process_started", 77)); } catch (const std::exception
& ex) { return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 442, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 442, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw non-std::exception"; } }
442 "mt_queued", "process_started", 77))){ try { key.reset(new DurationKey(10, DHCPV6_SOLICIT, DHCPV6_ADVERTISE
, "mt_queued", "process_started", 77)); } catch (const std::exception
& ex) { return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 442, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 442, "Failed") = ::testing::Message() << "key.reset(new DurationKey(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"mt_queued\", \"process_started\", 77))"
<< " threw non-std::exception"; } }
;
443
444 // Interval duration cannot be zero.
445 ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(*key, interval_duration)),{ try { mond.reset(new MonitoredDuration(*key, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
446 BadValue,{ try { mond.reset(new MonitoredDuration(*key, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
447 "MonitoredDuration - interval_duration 00:00:00,"{ try { mond.reset(new MonitoredDuration(*key, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
448 " is invalid, it must be greater than 0"){ try { mond.reset(new MonitoredDuration(*key, interval_duration
)); return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration 00:00:00,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration 00:00:00,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 448, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
;
449
450 // Interval duration cannot be negative.
451 ASSERT_THROW_MSG(mond.reset(new MonitoredDuration(*key, seconds(-5))),{ try { mond.reset(new MonitoredDuration(*key, seconds(-5)));
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
452 BadValue,{ try { mond.reset(new MonitoredDuration(*key, seconds(-5)));
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
453 "MonitoredDuration - interval_duration -00:00:05,"{ try { mond.reset(new MonitoredDuration(*key, seconds(-5)));
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
454 " is invalid, it must be greater than 0"){ try { mond.reset(new MonitoredDuration(*key, seconds(-5)));
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, "Failed") = ::testing::Message() << "no exception, expected: "
<< "BadValue"; } catch (const BadValue& ex) { switch
(0) case 0: default: if (const ::testing::AssertionResult gtest_ar
= (::testing::internal::EqHelper::Compare("std::string(ex.what())"
, "\"MonitoredDuration - interval_duration -00:00:05,\" \" is invalid, it must be greater than 0\""
, std::string(ex.what()), "MonitoredDuration - interval_duration -00:00:05,"
" is invalid, it must be greater than 0"))) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 454, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "BadValue"; } }
;
455}
456
457// Exercises MonitoredDuration::addSample() and MonitoredDuration::clear().
458TEST(MonitoredDuration, addSampleAndClear)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("addSampleAndClear") > 1, "test_name must not be empty"
); class MonitoredDuration_addSampleAndClear_Test : public ::
testing::Test { public: MonitoredDuration_addSampleAndClear_Test
() = default; ~MonitoredDuration_addSampleAndClear_Test() override
= default; MonitoredDuration_addSampleAndClear_Test (const MonitoredDuration_addSampleAndClear_Test
&) = delete; MonitoredDuration_addSampleAndClear_Test &
operator=( const MonitoredDuration_addSampleAndClear_Test &
) = delete; MonitoredDuration_addSampleAndClear_Test (MonitoredDuration_addSampleAndClear_Test
&&) noexcept = delete; MonitoredDuration_addSampleAndClear_Test
& operator=( MonitoredDuration_addSampleAndClear_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const MonitoredDuration_addSampleAndClear_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration"
, "addSampleAndClear", nullptr, nullptr, ::testing::internal::
CodeLocation("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 458), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 458), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 458), new ::testing::internal::TestFactoryImpl<MonitoredDuration_addSampleAndClear_Test
>); void MonitoredDuration_addSampleAndClear_Test::TestBody
()
{
459 MonitoredDurationPtr mond;
460 Duration interval_duration(milliseconds(50));
461
462 // Create valid v4 duration with interval duration of 50ms.
463 ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 465, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 465, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
464 "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 465, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 465, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
465 SUBNET_ID_GLOBAL, interval_duration))){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 465, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 465, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
;
466 ASSERT_TRUE(mond)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(mond)) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 466, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond", "false", "true") .c_str()) = ::testing::Message()
;
467
468 // Initially there are no intervals.
469 EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 469, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getCurrentInterval()", "true", "false") .c_str())
= ::testing::Message()
;
470 EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 470, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
471
472 auto two_ms = milliseconds(2);
473 bool should_report = false;
474
475 // Add a sample and verify nothing to report and that it creates a
476 // current interval.
477 ASSERT_NO_THROW(should_report = mond->addSample(two_ms))switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { try { if (::testing::internal::AlwaysTrue()) {
should_report = mond->addSample(two_ms); } else static_assert
(true, ""); } catch (std::exception const& e) { gtest_msg
.value = "it throws "; gtest_msg.value += ::testing::internal
::GetTypeName(typeid(e)); gtest_msg.value += " with description \""
; gtest_msg.value += e.what(); gtest_msg.value += "\"."; goto
gtest_label_testnothrow_477; } catch (...) { gtest_msg.value
= "it throws."; goto gtest_label_testnothrow_477; } } else gtest_label_testnothrow_477
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 477, ("Expected: " "should_report = mond->addSample(two_ms)"
" doesn't throw an exception.\n" " Actual: " + gtest_msg.value
) .c_str()) = ::testing::Message()
;
478 EXPECT_FALSE(should_report)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(should_report))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 478, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "should_report", "true", "false") .c_str()) = ::testing::Message
()
;
479 DurationDataIntervalPtr current_interval = mond->getCurrentInterval();
480 ASSERT_TRUE(current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(current_interval)) ; else
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 480, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "current_interval", "false", "true") .c_str()) = ::testing::
Message()
;
481
482 // First pass, we should only have a current interval,
483 // nothing to report, one occurrence and a total duration of 10ms.
484 EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 484, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
485 EXPECT_FALSE(should_report)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(should_report))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 485, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "should_report", "true", "false") .c_str()) = ::testing::Message
()
;
486 EXPECT_EQ(current_interval->getOccurrences(), 1U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getOccurrences()"
, "1U", current_interval->getOccurrences(), 1U))) ; else ::
testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 486, gtest_ar.failure_message()) = ::testing::Message()
;
487 EXPECT_EQ(current_interval->getTotalDuration(), two_ms)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getTotalDuration()"
, "two_ms", current_interval->getTotalDuration(), two_ms))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 487, gtest_ar.failure_message()) = ::testing::Message()
;
488
489 // Save a copy of the current interval pointer.
490 DurationDataIntervalPtr original_interval = current_interval;
491
492 // Add 4 two ms samples during the current interval.
493 DurationDataIntervalPtr previous_interval;
494 for (unsigned i = 1; i < 5; ++i) {
495 // Add a two ms sample, it should return false as its not
496 // time to report.
497 ASSERT_NO_THROW(should_report = mond->addSample(two_ms))switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { try { if (::testing::internal::AlwaysTrue()) {
should_report = mond->addSample(two_ms); } else static_assert
(true, ""); } catch (std::exception const& e) { gtest_msg
.value = "it throws "; gtest_msg.value += ::testing::internal
::GetTypeName(typeid(e)); gtest_msg.value += " with description \""
; gtest_msg.value += e.what(); gtest_msg.value += "\"."; goto
gtest_label_testnothrow_497; } catch (...) { gtest_msg.value
= "it throws."; goto gtest_label_testnothrow_497; } } else gtest_label_testnothrow_497
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 497, ("Expected: " "should_report = mond->addSample(two_ms)"
" doesn't throw an exception.\n" " Actual: " + gtest_msg.value
) .c_str()) = ::testing::Message()
;
498 EXPECT_FALSE(should_report)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(should_report))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 498, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "should_report", "true", "false") .c_str()) = ::testing::Message
()
;
499 current_interval = mond->getCurrentInterval();
500 ASSERT_TRUE(current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(current_interval)) ; else
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 500, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "current_interval", "false", "true") .c_str()) = ::testing::
Message()
;
501
502 // Make sure the current interval hasn't been replaced and we
503 // have no previous interval.
504 EXPECT_EQ(current_interval, original_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval"
, "original_interval", current_interval, original_interval)))
; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 504, gtest_ar.failure_message()) = ::testing::Message()
;
505 EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 505, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
506 // Verify the sample was added.
507 EXPECT_EQ(current_interval->getOccurrences(), (i + 1))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getOccurrences()"
, "(i + 1)", current_interval->getOccurrences(), (i + 1)))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 507, gtest_ar.failure_message()) = ::testing::Message()
;
508 EXPECT_EQ(current_interval->getTotalDuration(), (two_ms * (i + 1)))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getTotalDuration()"
, "(two_ms * (i + 1))", current_interval->getTotalDuration
(), (two_ms * (i + 1))))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 508, gtest_ar.failure_message()) = ::testing::Message()
;
509 }
510
511 // Sleep til past the end of interval
512 usleep(60 * 1000);
513
514 // Add another sample.
515 ASSERT_NO_THROW(should_report = mond->addSample(two_ms))switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { try { if (::testing::internal::AlwaysTrue()) {
should_report = mond->addSample(two_ms); } else static_assert
(true, ""); } catch (std::exception const& e) { gtest_msg
.value = "it throws "; gtest_msg.value += ::testing::internal
::GetTypeName(typeid(e)); gtest_msg.value += " with description \""
; gtest_msg.value += e.what(); gtest_msg.value += "\"."; goto
gtest_label_testnothrow_515; } catch (...) { gtest_msg.value
= "it throws."; goto gtest_label_testnothrow_515; } } else gtest_label_testnothrow_515
: return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 515, ("Expected: " "should_report = mond->addSample(two_ms)"
" doesn't throw an exception.\n" " Actual: " + gtest_msg.value
) .c_str()) = ::testing::Message()
;
516 current_interval = mond->getCurrentInterval();
517 ASSERT_TRUE(current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(current_interval)) ; else
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 517, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "current_interval", "false", "true") .c_str()) = ::testing::
Message()
;
518
519 // We should have crossed the interval boundary.
520 // Previous interval should be equal to the original interval and
521 // should_report should be true. The new current interval should
522 // have 1 occurrence and a total of 10ms.
523 previous_interval = mond->getPreviousInterval();
524 EXPECT_TRUE(previous_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(previous_interval)) ;
else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 524, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "previous_interval", "false", "true") .c_str()) = ::testing
::Message()
;
525 EXPECT_EQ(previous_interval, original_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("previous_interval"
, "original_interval", previous_interval, original_interval))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 525, gtest_ar.failure_message()) = ::testing::Message()
;
526 EXPECT_TRUE(should_report)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(should_report)) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 526, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "should_report", "false", "true") .c_str()) = ::testing::Message
()
;
527 EXPECT_EQ(current_interval->getOccurrences(), 1U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getOccurrences()"
, "1U", current_interval->getOccurrences(), 1U))) ; else ::
testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 527, gtest_ar.failure_message()) = ::testing::Message()
;
528 EXPECT_EQ(current_interval->getTotalDuration(), two_ms)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getTotalDuration()"
, "two_ms", current_interval->getTotalDuration(), two_ms))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 528, gtest_ar.failure_message()) = ::testing::Message()
;
529
530 // Verify that clear wipes the intervals.
531 ASSERT_NO_THROW_LOG(mond->clear()){ try { mond->clear(); } catch (const std::exception& ex
) { return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 531, "Failed") = ::testing::Message() << "mond->clear()"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 531, "Failed") = ::testing::Message() << "mond->clear()"
<< " threw non-std::exception"; } }
;
532 EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 532, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getCurrentInterval()", "true", "false") .c_str())
= ::testing::Message()
;
533 EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 533, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
534}
535
536TEST(MonitoredDuration, expireInterval)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("expireInterval") > 1, "test_name must not be empty"
); class MonitoredDuration_expireInterval_Test : public ::testing
::Test { public: MonitoredDuration_expireInterval_Test() = default
; ~MonitoredDuration_expireInterval_Test() override = default
; MonitoredDuration_expireInterval_Test (const MonitoredDuration_expireInterval_Test
&) = delete; MonitoredDuration_expireInterval_Test &
operator=( const MonitoredDuration_expireInterval_Test &
) = delete; MonitoredDuration_expireInterval_Test (MonitoredDuration_expireInterval_Test
&&) noexcept = delete; MonitoredDuration_expireInterval_Test
& operator=( MonitoredDuration_expireInterval_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const MonitoredDuration_expireInterval_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration"
, "expireInterval", nullptr, nullptr, ::testing::internal::CodeLocation
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 536), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 536), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 536), new ::testing::internal::TestFactoryImpl<MonitoredDuration_expireInterval_Test
>); void MonitoredDuration_expireInterval_Test::TestBody()
{
537 MonitoredDurationPtr mond;
538 Duration interval_duration(milliseconds(50));
539 auto start_time = PktEvent::now();
Value stored to 'start_time' during its initialization is never read
540 auto ten_ms = milliseconds(10);
541
542 // Create valid v4 duration with interval duration of 50ms.
543 ASSERT_NO_THROW_LOG(mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 545, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 545, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
544 "process_started", "process_completed",{ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 545, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 545, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
545 SUBNET_ID_GLOBAL, interval_duration))){ try { mond.reset(new MonitoredDuration(2, DHCPDISCOVER, DHCPOFFER
, "process_started", "process_completed", SUBNET_ID_GLOBAL, interval_duration
)); } catch (const std::exception& ex) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 545, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 545, "Failed") = ::testing::Message() << "mond.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
;
546 ASSERT_TRUE(mond)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(mond)) ; else return ::
testing::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 546, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond", "false", "true") .c_str()) = ::testing::Message()
;
547
548 // Initially there are no intervals.
549 EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 549, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getCurrentInterval()", "true", "false") .c_str())
= ::testing::Message()
;
550 EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 550, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
551 EXPECT_EQ(mond->getCurrentIntervalStart(), PktEvent::MIN_TIME())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getCurrentIntervalStart()"
, "PktEvent::MIN_TIME()", mond->getCurrentIntervalStart(),
PktEvent::MIN_TIME()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 551, gtest_ar.failure_message()) = ::testing::Message()
;
552
553 ASSERT_THROW_MSG(mond->expireCurrentInterval(), InvalidOperation,{ try { mond->expireCurrentInterval(); return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, "Failed") = ::testing::Message() << "no exception, expected: "
<< "InvalidOperation"; } catch (const InvalidOperation
& ex) { switch (0) case 0: default: if (const ::testing::
AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare
("std::string(ex.what())", "\"MonitoredDuration::expireInterval - no current interval for:\" \" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\""
, std::string(ex.what()), "MonitoredDuration::expireInterval - no current interval for:"
" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "InvalidOperation"; } }
554 "MonitoredDuration::expireInterval - no current interval for:"{ try { mond->expireCurrentInterval(); return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, "Failed") = ::testing::Message() << "no exception, expected: "
<< "InvalidOperation"; } catch (const InvalidOperation
& ex) { switch (0) case 0: default: if (const ::testing::
AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare
("std::string(ex.what())", "\"MonitoredDuration::expireInterval - no current interval for:\" \" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\""
, std::string(ex.what()), "MonitoredDuration::expireInterval - no current interval for:"
" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "InvalidOperation"; } }
555 " DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0"){ try { mond->expireCurrentInterval(); return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, "Failed") = ::testing::Message() << "no exception, expected: "
<< "InvalidOperation"; } catch (const InvalidOperation
& ex) { switch (0) case 0: default: if (const ::testing::
AssertionResult gtest_ar = (::testing::internal::EqHelper::Compare
("std::string(ex.what())", "\"MonitoredDuration::expireInterval - no current interval for:\" \" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0\""
, std::string(ex.what()), "MonitoredDuration::expireInterval - no current interval for:"
" DHCPDISCOVER-DHCPOFFER.process_started-process_completed.0"
))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, gtest_ar.failure_message()) = ::testing::Message(); } catch
(...) { return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 555, "Failed") = ::testing::Message() << "wrong exception type thrown, expected: "
<< "InvalidOperation"; } }
;
556
557 ASSERT_NO_THROW(mond->addSample(ten_ms))switch (0) case 0: default: if (::testing::internal::TrueWithString
gtest_msg{}) { try { if (::testing::internal::AlwaysTrue()) {
mond->addSample(ten_ms); } else static_assert(true, ""); }
catch (std::exception const& e) { gtest_msg.value = "it throws "
; gtest_msg.value += ::testing::internal::GetTypeName(typeid(
e)); gtest_msg.value += " with description \""; gtest_msg.value
+= e.what(); gtest_msg.value += "\"."; goto gtest_label_testnothrow_557
; } catch (...) { gtest_msg.value = "it throws."; goto gtest_label_testnothrow_557
; } } else gtest_label_testnothrow_557 : return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 557, ("Expected: " "mond->addSample(ten_ms)" " doesn't throw an exception.\n"
" Actual: " + gtest_msg.value) .c_str()) = ::testing::Message
()
;
558 auto current_interval = mond->getCurrentInterval();
559 ASSERT_TRUE(current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(current_interval)) ; else
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 559, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "current_interval", "false", "true") .c_str()) = ::testing::
Message()
;
560 EXPECT_EQ(current_interval->getOccurrences(), 1U)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getOccurrences()"
, "1U", current_interval->getOccurrences(), 1U))) ; else ::
testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 560, gtest_ar.failure_message()) = ::testing::Message()
;
561 EXPECT_EQ(current_interval->getTotalDuration(), ten_ms)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("current_interval->getTotalDuration()"
, "ten_ms", current_interval->getTotalDuration(), ten_ms))
) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 561, gtest_ar.failure_message()) = ::testing::Message()
;
562 EXPECT_FALSE(mond->getPreviousInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getPreviousInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 562, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getPreviousInterval()", "true", "false") .c_str()
) = ::testing::Message()
;
563 EXPECT_GE(mond->getCurrentIntervalStart(), start_time)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperGE("mond->getCurrentIntervalStart()"
, "start_time", mond->getCurrentIntervalStart(), start_time
))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 563, gtest_ar.failure_message()) = ::testing::Message()
;
564 EXPECT_EQ(mond->getCurrentIntervalStart(), current_interval->getStartTime())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getCurrentIntervalStart()"
, "current_interval->getStartTime()", mond->getCurrentIntervalStart
(), current_interval->getStartTime()))) ; else ::testing::
internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 564, gtest_ar.failure_message()) = ::testing::Message()
;
565
566 ASSERT_NO_THROW_LOG(mond->expireCurrentInterval()){ try { mond->expireCurrentInterval(); } catch (const std::
exception& ex) { return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 566, "Failed") = ::testing::Message() << "mond->expireCurrentInterval()"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 566, "Failed") = ::testing::Message() << "mond->expireCurrentInterval()"
<< " threw non-std::exception"; } }
;
567 EXPECT_FALSE(mond->getCurrentInterval())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(!(mond->getCurrentInterval
()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 567, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "mond->getCurrentInterval()", "true", "false") .c_str())
= ::testing::Message()
;
568
569 auto previous_interval = mond->getPreviousInterval();
570 EXPECT_EQ(previous_interval, current_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("previous_interval"
, "current_interval", previous_interval, current_interval))) ;
else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 570, gtest_ar.failure_message()) = ::testing::Message()
;
571 EXPECT_EQ(mond->getCurrentIntervalStart(), PktEvent::MIN_TIME())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("mond->getCurrentIntervalStart()"
, "PktEvent::MIN_TIME()", mond->getCurrentIntervalStart(),
PktEvent::MIN_TIME()))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 571, gtest_ar.failure_message()) = ::testing::Message()
;
572}
573
574// Verifies the MonitoredDuration::toElement(). We do not bother with
575// a v6 version of this test as family only influences DurationKey content
576// and that is tested elsewhere.
577TEST(MonitoredDuration, toElement)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("toElement") > 1, "test_name must not be empty"
); class MonitoredDuration_toElement_Test : public ::testing::
Test { public: MonitoredDuration_toElement_Test() = default; ~
MonitoredDuration_toElement_Test() override = default; MonitoredDuration_toElement_Test
(const MonitoredDuration_toElement_Test &) = delete; MonitoredDuration_toElement_Test
& operator=( const MonitoredDuration_toElement_Test &
) = delete; MonitoredDuration_toElement_Test (MonitoredDuration_toElement_Test
&&) noexcept = delete; MonitoredDuration_toElement_Test
& operator=( MonitoredDuration_toElement_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const MonitoredDuration_toElement_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration"
, "toElement", nullptr, nullptr, ::testing::internal::CodeLocation
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 577), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 577), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 577), new ::testing::internal::TestFactoryImpl<MonitoredDuration_toElement_Test
>); void MonitoredDuration_toElement_Test::TestBody()
{
578 MonitoredDurationPtr duration;
579 Duration interval_duration(milliseconds(50));
580
581 // Create valid v4 duration.
582 ASSERT_NO_THROW_LOG(duration.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER,{ try { duration.reset(new MonitoredDuration(2, DHCPDISCOVER,
DHCPOFFER, "process_started", "process_completed", SUBNET_ID_GLOBAL
, interval_duration)); } catch (const std::exception& ex)
{ return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 584, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 584, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
583 "process_started", "process_completed",{ try { duration.reset(new MonitoredDuration(2, DHCPDISCOVER,
DHCPOFFER, "process_started", "process_completed", SUBNET_ID_GLOBAL
, interval_duration)); } catch (const std::exception& ex)
{ return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 584, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 584, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
584 SUBNET_ID_GLOBAL, interval_duration))){ try { duration.reset(new MonitoredDuration(2, DHCPDISCOVER,
DHCPOFFER, "process_started", "process_completed", SUBNET_ID_GLOBAL
, interval_duration)); } catch (const std::exception& ex)
{ return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 584, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 584, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET, DHCPDISCOVER, DHCPOFFER, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
;
585 ASSERT_TRUE(duration)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(duration)) ; else return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 585, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "duration", "false", "true") .c_str()) = ::testing::Message
()
;
586 duration->addSample(microseconds(5));
587 duration->addSample(microseconds(2));
588 duration->addSample(microseconds(7));
589
590 ElementPtr ref_duration_elem = Element::createMap();
591 // Add the key.
592 ElementPtr ref_key_elem = Element::createMap();
593 ref_key_elem->set("query-type", Element::create("DHCPDISCOVER"));
594 ref_key_elem->set("response-type", Element::create("DHCPOFFER"));
595 ref_key_elem->set("start-event", Element::create("process_started"));
596 ref_key_elem->set("stop-event", Element::create("process_completed"));
597 ref_key_elem->set("subnet-id", Element::create(SUBNET_ID_GLOBAL));
598 ref_duration_elem->set("duration-key", ref_key_elem);
599
600 // Add the data. Should have empty values as we do not have a previous interval.
601 ref_duration_elem->set("mean-duration-usecs", Element::create(0));
602 ref_duration_elem->set("max-duration-usecs", Element::create(0));
603 ref_duration_elem->set("min-duration-usecs", Element::create(0));
604 ref_duration_elem->set("occurrences", Element::create(0));
605 ref_duration_elem->set("start-time", Element::create("<none>"));
606 ref_duration_elem->set("total-duration-usecs", Element::create(0));
607
608 std::string expected_json =
609 R"({
610 "mean-duration-usecs": 0,
611 "duration-key": {
612 "query-type": "DHCPDISCOVER",
613 "response-type": "DHCPOFFER",
614 "start-event": "process_started",
615 "stop-event": "process_completed",
616 "subnet-id": 0 },
617 "max-duration-usecs": 0,
618 "min-duration-usecs": 0,
619 "occurrences": 0,
620 "start-time": "<none>",
621 "total-duration-usecs": 0
622 })";
623
624 // Check toElement() against expected JSON.
625 runToElementTest(expected_json, *duration);
626
627 // Now expire the current interval so we'll have a previous interval.
628 duration->expireCurrentInterval();
629 auto previous_interval = duration->getPreviousInterval();
630 ASSERT_TRUE(previous_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(previous_interval)) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 630, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "previous_interval", "false", "true") .c_str()) = ::testing
::Message()
;
631
632 std::ostringstream oss;
633 oss <<
634 R"({
635 "mean-duration-usecs": 4,
636 "duration-key": {
637 "query-type": "DHCPDISCOVER",
638 "response-type": "DHCPOFFER",
639 "start-event": "process_started",
640 "stop-event": "process_completed",
641 "subnet-id": 0 },
642 "max-duration-usecs": 7,
643 "min-duration-usecs": 2,
644 "occurrences": 3,
645 "start-time": ")"
646 << ptimeToText(previous_interval->getStartTime())
647 << R"(", "total-duration-usecs": 14 })";
648
649 // Check toElement() against expected JSON.
650 runToElementTest(oss.str(), *duration);
651}
652
653// Verifies the column labels used by MonitoredDuration value rows.
654TEST(MonitoredDuration, valueRowColumns)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("valueRowColumns") > 1, "test_name must not be empty"
); class MonitoredDuration_valueRowColumns_Test : public ::testing
::Test { public: MonitoredDuration_valueRowColumns_Test() = default
; ~MonitoredDuration_valueRowColumns_Test() override = default
; MonitoredDuration_valueRowColumns_Test (const MonitoredDuration_valueRowColumns_Test
&) = delete; MonitoredDuration_valueRowColumns_Test &
operator=( const MonitoredDuration_valueRowColumns_Test &
) = delete; MonitoredDuration_valueRowColumns_Test (MonitoredDuration_valueRowColumns_Test
&&) noexcept = delete; MonitoredDuration_valueRowColumns_Test
& operator=( MonitoredDuration_valueRowColumns_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const MonitoredDuration_valueRowColumns_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration"
, "valueRowColumns", nullptr, nullptr, ::testing::internal::CodeLocation
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 654), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 654), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 654), new ::testing::internal::TestFactoryImpl<MonitoredDuration_valueRowColumns_Test
>); void MonitoredDuration_valueRowColumns_Test::TestBody(
)
{
655 ConstElementPtr expected_columns = Element::fromJSON(R"([
656 "query-type",
657 "response-type",
658 "start-event",
659 "end-event",
660 "subnet-id",
661 "interval-start",
662 "occurrences",
663 "min-duration-usecs",
664 "max-duration-usecs",
665 "total-duration-usecs",
666 "mean-duration-usecs"
667 ])");
668
669 ConstElementPtr columns = MonitoredDuration::valueRowColumns();
670
671 ASSERT_TRUE(columns)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(columns)) ; else return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 671, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "columns", "false", "true") .c_str()) = ::testing::Message(
)
;
672 EXPECT_EQ(*expected_columns, *columns)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("*expected_columns"
, "*columns", *expected_columns, *columns))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 672, gtest_ar.failure_message()) = ::testing::Message()
;
673}
674
675// Verifies the MonitoredDuration::toElement(). We do not bother with
676// a v4 version of this test as family only influences DurationKey content
677// and that is tested elsewhere.
678TEST(MonitoredDuration, toValueRow)static_assert(sizeof("MonitoredDuration") > 1, "test_suite_name must not be empty"
); static_assert(sizeof("toValueRow") > 1, "test_name must not be empty"
); class MonitoredDuration_toValueRow_Test : public ::testing
::Test { public: MonitoredDuration_toValueRow_Test() = default
; ~MonitoredDuration_toValueRow_Test() override = default; MonitoredDuration_toValueRow_Test
(const MonitoredDuration_toValueRow_Test &) = delete; MonitoredDuration_toValueRow_Test
& operator=( const MonitoredDuration_toValueRow_Test &
) = delete; MonitoredDuration_toValueRow_Test (MonitoredDuration_toValueRow_Test
&&) noexcept = delete; MonitoredDuration_toValueRow_Test
& operator=( MonitoredDuration_toValueRow_Test &&
) noexcept = delete; private: void TestBody() override; [[maybe_unused
]] static ::testing::TestInfo* const test_info_; }; ::testing
::TestInfo* const MonitoredDuration_toValueRow_Test::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "MonitoredDuration"
, "toValueRow", nullptr, nullptr, ::testing::internal::CodeLocation
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 678), (::testing::internal::GetTestTypeId()), ::testing::internal
::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite
("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 678), ::testing::internal::SuiteApiResolver< ::testing::
Test>::GetTearDownCaseOrSuite("../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 678), new ::testing::internal::TestFactoryImpl<MonitoredDuration_toValueRow_Test
>); void MonitoredDuration_toValueRow_Test::TestBody()
{
679 MonitoredDurationPtr duration;
680 Duration interval_duration(milliseconds(50));
681
682 // Create valid v4 duration.
683 ASSERT_NO_THROW_LOG(duration.reset(new MonitoredDuration(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE,{ try { duration.reset(new MonitoredDuration(10, DHCPV6_SOLICIT
, DHCPV6_ADVERTISE, "process_started", "process_completed", SUBNET_ID_GLOBAL
, interval_duration)); } catch (const std::exception& ex)
{ return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 685, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 685, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
684 "process_started", "process_completed",{ try { duration.reset(new MonitoredDuration(10, DHCPV6_SOLICIT
, DHCPV6_ADVERTISE, "process_started", "process_completed", SUBNET_ID_GLOBAL
, interval_duration)); } catch (const std::exception& ex)
{ return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 685, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 685, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
685 SUBNET_ID_GLOBAL, interval_duration))){ try { duration.reset(new MonitoredDuration(10, DHCPV6_SOLICIT
, DHCPV6_ADVERTISE, "process_started", "process_completed", SUBNET_ID_GLOBAL
, interval_duration)); } catch (const std::exception& ex)
{ return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 685, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw type: " << typeid(ex).name() <<
", what: " << ex.what(); } catch (...) { return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 685, "Failed") = ::testing::Message() << "duration.reset(new MonitoredDuration(AF_INET6, DHCPV6_SOLICIT, DHCPV6_ADVERTISE, \"process_started\", \"process_completed\", SUBNET_ID_GLOBAL, interval_duration))"
<< " threw non-std::exception"; } }
;
686 ASSERT_TRUE(duration)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(duration)) ; else return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 686, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "duration", "false", "true") .c_str()) = ::testing::Message
()
;
687 duration->addSample(microseconds(5));
688 duration->addSample(microseconds(2));
689 duration->addSample(microseconds(7));
690
691 ElementPtr ref_row_elem = Element::createList();
692 // Add key values first.
693 ref_row_elem->add(Element::create("SOLICIT")); // query-type
694 ref_row_elem->add(Element::create("ADVERTISE")); // response-type
695 ref_row_elem->add(Element::create("process_started")); // start-event
696 ref_row_elem->add(Element::create("process_completed")); // stop-event
697 ref_row_elem->add(Element::create(SUBNET_ID_GLOBAL)); // subnet-id
698
699 // Remember where the data values begin.
700 auto data_start = ref_row_elem->size();
701
702 // Add the data values. Should have empty values as we do not have a previous interval.
703 ref_row_elem->add(Element::create("<none>")); // start-time
704 ref_row_elem->add(Element::create(0)); // occurrences
705 ref_row_elem->add(Element::create(0)); // min-duration-usecs
706 ref_row_elem->add(Element::create(0)); // max-duration-usecs
707 ref_row_elem->add(Element::create(0)); // total-duration-usecs
708 ref_row_elem->add(Element::create(0)); // mean-duration-usecs
709
710 // Generate the valueRow Element and compare it to the reference.
711 auto row_elem = duration->toValueRow();
712
713 ASSERT_TRUE(row_elem)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(row_elem)) ; else return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 713, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "row_elem", "false", "true") .c_str()) = ::testing::Message
()
;
714 EXPECT_EQ(prettyPrint(ref_row_elem), prettyPrint(row_elem))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("prettyPrint(ref_row_elem)"
, "prettyPrint(row_elem)", prettyPrint(ref_row_elem), prettyPrint
(row_elem)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 714, gtest_ar.failure_message()) = ::testing::Message()
;
715
716 // Now expire the current interval so we'll have a previous interval.
717 duration->expireCurrentInterval();
718 auto previous_interval = duration->getPreviousInterval();
719 ASSERT_TRUE(previous_interval)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(previous_interval)) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 719, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "previous_interval", "false", "true") .c_str()) = ::testing
::Message()
;
720
721 // Remove the old reference data values.
722 while (ref_row_elem->size() > data_start) {
723 ref_row_elem->remove(data_start);
724 }
725
726 // Add the new reference data values.
727 ref_row_elem->add(Element::create(ptimeToText(previous_interval->getStartTime())));
728 ref_row_elem->add(Element::create(3)); // occurrences
729 ref_row_elem->add(Element::create(2)); // min-duration-usecs
730 ref_row_elem->add(Element::create(7)); // max-duration-usecs
731 ref_row_elem->add(Element::create(14)); // total-duration-usecs
732 ref_row_elem->add(Element::create(4)); // mean-duration-usecs
733
734 // Generate the valueRow Element and compare it to the reference.
735 row_elem = duration->toValueRow();
736 ASSERT_TRUE(row_elem)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(row_elem)) ; else return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 736, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "row_elem", "false", "true") .c_str()) = ::testing::Message
()
;
737 EXPECT_EQ(prettyPrint(ref_row_elem), prettyPrint(row_elem))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::EqHelper::Compare("prettyPrint(ref_row_elem)"
, "prettyPrint(row_elem)", prettyPrint(ref_row_elem), prettyPrint
(row_elem)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "../../../src/hooks/dhcp/perfmon/tests/monitored_duration_unittests.cc"
, 737, gtest_ar.failure_message()) = ::testing::Message()
;
738}
739
740} // end of anonymous namespace