diff --git a/src/bgp/state_machine.h b/src/bgp/state_machine.h index 3676bce5000..730d3d05015 100644 --- a/src/bgp/state_machine.h +++ b/src/bgp/state_machine.h @@ -94,7 +94,7 @@ class StateMachine : public sc::state_machine { }; explicit StateMachine(BgpPeer *peer); - ~StateMachine(); + virtual ~StateMachine(); void Initialize(); void Shutdown(int subcode); @@ -125,7 +125,7 @@ class StateMachine : public sc::state_machine { bool IdleHoldTimerRunning(); void StartSession(); - void DeleteSession(BgpSession *session); + virtual void DeleteSession(BgpSession *session); void AssignSession(bool active); virtual void OnSessionEvent(TcpSession *session, TcpSession::Event event); diff --git a/src/bgp/test/bgp_peer_test.cc b/src/bgp/test/bgp_peer_test.cc index 3bf92a354c2..a0db553ff01 100644 --- a/src/bgp/test/bgp_peer_test.cc +++ b/src/bgp/test/bgp_peer_test.cc @@ -7,6 +7,7 @@ #include "base/task_annotations.h" #include "base/test/task_test_util.h" #include "bgp/bgp_config.h" +#include "bgp/bgp_factory.h" #include "bgp/bgp_log.h" #include "bgp/bgp_peer.h" #include "bgp/bgp_session.h" @@ -15,6 +16,12 @@ // Use this test to mock BgpPeer and test selected functionality in BgpPeer as // desired. e.g. EndOfRibSendTimerExpired() API. +class StateMachineMock : public StateMachine { +public: + explicit StateMachineMock(BgpPeer *peer) : StateMachine(peer) { } + virtual void DeleteSession(BgpSession *session) { } +}; + class BgpSessionMock : public BgpSession { public: BgpSessionMock(BgpSessionManager *manager) @@ -415,6 +422,8 @@ INSTANTIATE_TEST_CASE_P(BgpPeerTestWithParams, BgpPeerParamTest, static void SetUp() { bgp_log_test::init(); ControlNode::SetDefaultSchedulingPolicy(); + BgpObjectFactory::Register( + boost::factory()); } static void TearDown() {