-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,650 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "sairedis.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
#include <iostream> | ||
|
||
static std::map<std::string, std::string> g_profileMap; | ||
static std::map<std::string, std::string>::iterator g_profileIter; | ||
|
||
static const char* profile_get_value( | ||
_In_ sai_switch_profile_id_t profile_id, | ||
_In_ const char* variable) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
if (variable == NULL) | ||
{ | ||
SWSS_LOG_WARN("variable is null"); | ||
return NULL; | ||
} | ||
|
||
auto it = g_profileMap.find(variable); | ||
|
||
if (it == g_profileMap.end()) | ||
{ | ||
SWSS_LOG_NOTICE("%s: NULL", variable); | ||
return NULL; | ||
} | ||
|
||
SWSS_LOG_NOTICE("%s: %s", variable, it->second.c_str()); | ||
|
||
return it->second.c_str(); | ||
} | ||
|
||
static int profile_get_next_value( | ||
_In_ sai_switch_profile_id_t profile_id, | ||
_Out_ const char** variable, | ||
_Out_ const char** value) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
if (value == NULL) | ||
{ | ||
SWSS_LOG_INFO("resetting profile map iterator"); | ||
|
||
g_profileIter = g_profileMap.begin(); | ||
return 0; | ||
} | ||
|
||
if (variable == NULL) | ||
{ | ||
SWSS_LOG_WARN("variable is null"); | ||
return -1; | ||
} | ||
|
||
if (g_profileIter == g_profileMap.end()) | ||
{ | ||
SWSS_LOG_INFO("iterator reached end"); | ||
return -1; | ||
} | ||
|
||
*variable = g_profileIter->first.c_str(); | ||
*value = g_profileIter->second.c_str(); | ||
|
||
SWSS_LOG_INFO("key: %s:%s", *variable, *value); | ||
|
||
g_profileIter++; | ||
|
||
return 0; | ||
} | ||
|
||
static sai_service_method_table_t test_services = { | ||
profile_get_value, | ||
profile_get_next_value | ||
}; | ||
|
||
class sairedisEnvironment: | ||
public ::testing::Environment | ||
{ | ||
public: | ||
|
||
virtual void SetUp() override | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
g_profileIter = g_profileMap.begin(); | ||
|
||
auto status = sai_api_initialize(0, (sai_service_method_table_t*)&test_services); | ||
|
||
EXPECT_EQ(status, SAI_STATUS_SUCCESS); | ||
} | ||
|
||
virtual void TearDown() override | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
auto status = sai_api_uninitialize(); | ||
|
||
EXPECT_EQ(status, SAI_STATUS_SUCCESS); | ||
} | ||
}; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
|
||
const auto env = new sairedisEnvironment(); | ||
|
||
testing::AddGlobalTestEnvironment(env); | ||
|
||
return RUN_ALL_TESTS(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <gtest/gtest.h> | ||
|
||
extern "C" { | ||
#include "sai.h" | ||
} | ||
|
||
#include "swss/logger.h" | ||
|
||
TEST(libsairedis, acl) | ||
{ | ||
sai_acl_api_t *api = nullptr; | ||
|
||
sai_api_query(SAI_API_ACL, (void**)&api); | ||
|
||
EXPECT_NE(api, nullptr); | ||
|
||
sai_object_id_t id; | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_table(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_table(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_table_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_table_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_entry(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_entry(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_entry_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_entry_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_counter(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_counter(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_counter_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_counter_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_range(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_range(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_range_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_range_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_table_group(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_table_group(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_table_group_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_table_group_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_table_group_member(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_table_group_member(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_table_group_member_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_table_group_member_attribute(0,0,0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <gtest/gtest.h> | ||
|
||
extern "C" { | ||
#include "sai.h" | ||
} | ||
|
||
#include "swss/logger.h" | ||
|
||
TEST(libsairedis, bfd) | ||
{ | ||
sai_bfd_api_t *api = nullptr; | ||
|
||
sai_api_query(SAI_API_BFD, (void**)&api); | ||
|
||
EXPECT_NE(api, nullptr); | ||
|
||
sai_object_id_t id; | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_bfd_session(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_bfd_session(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_bfd_session_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bfd_session_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bfd_session_stats(0,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bfd_session_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_bfd_session_stats(0,0,0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <gtest/gtest.h> | ||
|
||
extern "C" { | ||
#include "sai.h" | ||
#include "saiextensions.h" | ||
} | ||
|
||
#include "swss/logger.h" | ||
|
||
TEST(libsairedis, bmtor) | ||
{ | ||
sai_bmtor_api_t *api = nullptr; | ||
|
||
sai_api_query((sai_api_t)SAI_API_BMTOR, (void**)&api); | ||
|
||
EXPECT_NE(api, nullptr); | ||
|
||
sai_object_id_t id; | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_table_bitmap_classification_entry(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_table_bitmap_classification_entry(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_table_bitmap_classification_entry_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_classification_entry_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_classification_entry_stats(0,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_classification_entry_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_table_bitmap_classification_entry_stats(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_table_bitmap_router_entry(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_table_bitmap_router_entry(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_table_bitmap_router_entry_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_router_entry_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_router_entry_stats(0,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_router_entry_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_table_bitmap_router_entry_stats(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_table_meta_tunnel_entry(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_table_meta_tunnel_entry(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_table_meta_tunnel_entry_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_meta_tunnel_entry_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_meta_tunnel_entry_stats(0,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_meta_tunnel_entry_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_table_meta_tunnel_entry_stats(0,0,0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <gtest/gtest.h> | ||
|
||
extern "C" { | ||
#include "sai.h" | ||
} | ||
|
||
#include "swss/logger.h" | ||
|
||
TEST(libsairedis, bridge) | ||
{ | ||
sai_bridge_api_t *api = nullptr; | ||
|
||
sai_api_query(SAI_API_BRIDGE, (void**)&api); | ||
|
||
EXPECT_NE(api, nullptr); | ||
|
||
sai_object_id_t id; | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_bridge(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_bridge(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_bridge_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_stats(0,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_bridge_stats(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_bridge_port(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_bridge_port(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_bridge_port_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_port_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_port_stats(0,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_port_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_bridge_port_stats(0,0,0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <gtest/gtest.h> | ||
|
||
extern "C" { | ||
#include "sai.h" | ||
} | ||
|
||
#include "swss/logger.h" | ||
|
||
TEST(libsairedis, buffer) | ||
{ | ||
sai_buffer_api_t *api = nullptr; | ||
|
||
sai_api_query(SAI_API_BUFFER, (void**)&api); | ||
|
||
EXPECT_NE(api, nullptr); | ||
|
||
sai_object_id_t id; | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_buffer_pool(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_buffer_pool(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_buffer_pool_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_buffer_pool_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_buffer_pool_stats(0,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_buffer_pool_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_buffer_pool_stats(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_ingress_priority_group(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_ingress_priority_group(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_ingress_priority_group_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ingress_priority_group_attribute(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ingress_priority_group_stats(0,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ingress_priority_group_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_ingress_priority_group_stats(0,0,0)); | ||
|
||
EXPECT_NE(SAI_STATUS_SUCCESS, api->create_buffer_profile(&id,0,0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_buffer_profile(0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_buffer_profile_attribute(0,0)); | ||
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_buffer_profile_attribute(0,0,0)); | ||
} |
Oops, something went wrong.