Skip to content

Commit cd13f49

Browse files
committed
Update Switch tests
1 parent 6fc213d commit cd13f49

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

unittest/lib/TestSwitch.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,50 @@ TEST(Switch, ctr)
1010
{
1111
EXPECT_THROW(std::make_shared<Switch>(SAI_NULL_OBJECT_ID), std::runtime_error);
1212
}
13+
14+
TEST(Switch, getSwitchNotifications)
15+
{
16+
auto s = std::make_shared<Switch>(7);
17+
18+
s->getSwitchNotifications();
19+
}
20+
21+
TEST(Switch, updateNotifications)
22+
{
23+
auto s = std::make_shared<Switch>(7);
24+
25+
sai_attribute_t attrs[10];
26+
27+
attrs[0].id = 10000;
28+
29+
EXPECT_THROW(s->updateNotifications(1, attrs), std::runtime_error);
30+
31+
attrs[0].value.ptr = (void*)1;
32+
attrs[1].value.ptr = (void*)1;
33+
attrs[2].value.ptr = (void*)1;
34+
attrs[3].value.ptr = (void*)1;
35+
attrs[4].value.ptr = (void*)1;
36+
attrs[5].value.ptr = (void*)1;
37+
attrs[6].value.ptr = (void*)1;
38+
39+
attrs[0].id = SAI_SWITCH_ATTR_SWITCH_STATE_CHANGE_NOTIFY;
40+
attrs[1].id = SAI_SWITCH_ATTR_SHUTDOWN_REQUEST_NOTIFY;
41+
attrs[2].id = SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY;
42+
attrs[3].id = SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY;
43+
attrs[4].id = SAI_SWITCH_ATTR_PACKET_EVENT_NOTIFY;
44+
attrs[5].id = SAI_SWITCH_ATTR_QUEUE_PFC_DEADLOCK_NOTIFY;
45+
attrs[6].id = SAI_SWITCH_ATTR_BFD_SESSION_STATE_CHANGE_NOTIFY;
46+
attrs[7].id = SAI_SWITCH_ATTR_INIT_SWITCH;
47+
48+
s->updateNotifications(8, attrs);
49+
50+
auto sn = s->getSwitchNotifications();
51+
52+
EXPECT_EQ((void*)1, sn.on_bfd_session_state_change);
53+
EXPECT_EQ((void*)1, sn.on_fdb_event);
54+
EXPECT_EQ((void*)1, sn.on_packet_event);
55+
EXPECT_EQ((void*)1, sn.on_port_state_change);
56+
EXPECT_EQ((void*)1, sn.on_queue_pfc_deadlock);
57+
EXPECT_EQ((void*)1, sn.on_switch_shutdown_request);
58+
EXPECT_EQ((void*)1, sn.on_switch_state_change);
59+
}

0 commit comments

Comments
 (0)