Skip to content

Commit

Permalink
Add switch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 23, 2021
1 parent c2c0af8 commit 9224e13
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions unittest/vslib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ testslibsaivs_SOURCES = main_libsaivs.cpp \
test_sai_vs_schedulergroup.cpp \
test_sai_vs_scheduler.cpp \
test_sai_vs_segmentroute.cpp \
test_sai_vs_switch.cpp \
test_sai_vs_stp.cpp \
test_sai_vs_vlan.cpp \
test_sai_vs_hostif.cpp \
Expand Down
35 changes: 35 additions & 0 deletions unittest/vslib/test_sai_vs_switch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <gtest/gtest.h>

extern "C" {
#include "sai.h"
}

#include "swss/logger.h"

TEST(libsaivs, switch)
{
sai_switch_api_t *api = nullptr;

sai_api_query(SAI_API_SWITCH, (void**)&api);

EXPECT_NE(api, nullptr);

sai_object_id_t id;

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_switch(&id,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_switch(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_switch_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_switch_attribute(0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->get_switch_stats(0,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_switch_stats_ext(0,0,0,SAI_STATS_MODE_READ,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_switch_stats(0,0,0));

EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->switch_mdio_read(0,0,0,0,0));
EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->switch_mdio_write(0,0,0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_switch_tunnel(&id,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_switch_tunnel(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_switch_tunnel_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_switch_tunnel_attribute(0,0,0));
}
8 changes: 4 additions & 4 deletions vslib/sai_vs_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static sai_status_t vs_create_switch_uniq(
attr_list);
}

static sai_status_t vs_mdio_read(
static sai_status_t vs_switch_mdio_read(
_In_ sai_object_id_t switch_id,
_In_ uint32_t device_addr,
_In_ uint32_t start_reg_addr,
Expand All @@ -30,7 +30,7 @@ static sai_status_t vs_mdio_read(
return SAI_STATUS_NOT_IMPLEMENTED;
}

static sai_status_t vs_mdio_write(
static sai_status_t vs_switch_mdio_write(
_In_ sai_object_id_t switch_id,
_In_ uint32_t device_addr,
_In_ uint32_t start_reg_addr,
Expand All @@ -51,8 +51,8 @@ const sai_switch_api_t vs_switch_api = {

VS_GENERIC_STATS_API(switch)

vs_mdio_read,
vs_mdio_write,
vs_switch_mdio_read,
vs_switch_mdio_write,

VS_GENERIC_QUAD_API(switch_tunnel)

Expand Down

0 comments on commit 9224e13

Please sign in to comment.