Skip to content

Commit

Permalink
Update Switch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Sep 20, 2021
1 parent 6fc213d commit cd13f49
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions unittest/lib/TestSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,50 @@ TEST(Switch, ctr)
{
EXPECT_THROW(std::make_shared<Switch>(SAI_NULL_OBJECT_ID), std::runtime_error);
}

TEST(Switch, getSwitchNotifications)
{
auto s = std::make_shared<Switch>(7);

s->getSwitchNotifications();
}

TEST(Switch, updateNotifications)
{
auto s = std::make_shared<Switch>(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);
}

0 comments on commit cd13f49

Please sign in to comment.