From cd13f498a321dd03a4ac54327cce04762b59538c Mon Sep 17 00:00:00 2001 From: kcudnik Date: Mon, 13 Sep 2021 10:41:55 +0200 Subject: [PATCH] Update Switch tests --- unittest/lib/TestSwitch.cpp | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/unittest/lib/TestSwitch.cpp b/unittest/lib/TestSwitch.cpp index 69d9616a1..5e7bc9294 100644 --- a/unittest/lib/TestSwitch.cpp +++ b/unittest/lib/TestSwitch.cpp @@ -10,3 +10,50 @@ TEST(Switch, ctr) { EXPECT_THROW(std::make_shared(SAI_NULL_OBJECT_ID), std::runtime_error); } + +TEST(Switch, getSwitchNotifications) +{ + auto s = std::make_shared(7); + + s->getSwitchNotifications(); +} + +TEST(Switch, updateNotifications) +{ + auto s = std::make_shared(7); + + sai_attribute_t attrs[10]; + + attrs[0].id = 10000; + + EXPECT_THROW(s->updateNotifications(1, attrs), std::runtime_error); + + attrs[0].value.ptr = (void*)1; + attrs[1].value.ptr = (void*)1; + attrs[2].value.ptr = (void*)1; + attrs[3].value.ptr = (void*)1; + attrs[4].value.ptr = (void*)1; + attrs[5].value.ptr = (void*)1; + attrs[6].value.ptr = (void*)1; + + attrs[0].id = SAI_SWITCH_ATTR_SWITCH_STATE_CHANGE_NOTIFY; + attrs[1].id = SAI_SWITCH_ATTR_SHUTDOWN_REQUEST_NOTIFY; + attrs[2].id = SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY; + attrs[3].id = SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY; + attrs[4].id = SAI_SWITCH_ATTR_PACKET_EVENT_NOTIFY; + attrs[5].id = SAI_SWITCH_ATTR_QUEUE_PFC_DEADLOCK_NOTIFY; + attrs[6].id = SAI_SWITCH_ATTR_BFD_SESSION_STATE_CHANGE_NOTIFY; + attrs[7].id = SAI_SWITCH_ATTR_INIT_SWITCH; + + s->updateNotifications(8, attrs); + + auto sn = s->getSwitchNotifications(); + + EXPECT_EQ((void*)1, sn.on_bfd_session_state_change); + EXPECT_EQ((void*)1, sn.on_fdb_event); + EXPECT_EQ((void*)1, sn.on_packet_event); + EXPECT_EQ((void*)1, sn.on_port_state_change); + EXPECT_EQ((void*)1, sn.on_queue_pfc_deadlock); + EXPECT_EQ((void*)1, sn.on_switch_shutdown_request); + EXPECT_EQ((void*)1, sn.on_switch_state_change); +}