diff --git a/unittest/vslib/Makefile.am b/unittest/vslib/Makefile.am index 1022a88319f4..88af94614e15 100644 --- a/unittest/vslib/Makefile.am +++ b/unittest/vslib/Makefile.am @@ -35,6 +35,7 @@ testslibsaivs_SOURCES = main_libsaivs.cpp \ test_sai_vs_neighbor.cpp \ test_sai_vs_nexthop.cpp \ test_sai_vs_nexthopgroup.cpp \ + test_sai_vs_port.cpp \ test_sai_vs_policer.cpp \ test_sai_vs_vlan.cpp \ test_sai_vs_hostif.cpp \ diff --git a/unittest/vslib/test_sai_vs_port.cpp b/unittest/vslib/test_sai_vs_port.cpp new file mode 100644 index 000000000000..91d5e43d1ade --- /dev/null +++ b/unittest/vslib/test_sai_vs_port.cpp @@ -0,0 +1,48 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaivs, port) +{ + sai_port_api_t *api = nullptr; + + sai_api_query(SAI_API_PORT, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_port(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_port(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_port_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_port_stats(0,0,0)); + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->clear_port_all_stats(0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_port_pool(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_port_pool(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_port_pool_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_pool_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_pool_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_pool_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_port_pool_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_port_connector(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_port_connector(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_port_connector_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_connector_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_port_serdes(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_port_serdes(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_port_serdes_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_serdes_attribute(0,0,0)); +}