forked from sonic-net/sonic-sairedis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue: bulk counter feature cannot compile on platforms having no…
… sai_bulk_object_get_stats/sai_bulk_object_clear_stats (sonic-net#1105) Why I did this? bulk counter feature uses two new SAI API sai_bulk_object_get_stats/sai_bulk_object_clear_stats. Some vendors have no such API implemented in their SAI code. Need a way to make compilation pass. How I fix this? Add AC_CHECK_FUNCS for sai_bulk_object_get_stats/sai_bulk_object_clear_stats which generates macro HAVE_SAI_BULK_OBJECT_CLEAR_STATS/HAVE_SAI_BULK_OBJECT_GET_STATS in config.h. Use ifdef to avoid compilation failure.
- Loading branch information
1 parent
31f3258
commit 5582b11
Showing
4 changed files
with
71 additions
and
1 deletion.
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
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,59 @@ | ||
#include <gtest/gtest.h> | ||
#include "VendorSai.h" | ||
#include "swss/logger.h" | ||
|
||
#ifdef HAVE_SAI_BULK_OBJECT_GET_STATS | ||
#undef HAVE_SAI_BULK_OBJECT_GET_STATS | ||
#endif | ||
|
||
using namespace syncd; | ||
|
||
static const char* profile_get_value( | ||
_In_ sai_switch_profile_id_t profile_id, | ||
_In_ const char* variable) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
if (variable == NULL) | ||
return NULL; | ||
|
||
return nullptr; | ||
} | ||
|
||
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(); | ||
|
||
return 0; | ||
} | ||
|
||
static sai_service_method_table_t test_services = { | ||
profile_get_value, | ||
profile_get_next_value | ||
}; | ||
|
||
TEST(VendorSai, bulkGetStats) | ||
{ | ||
VendorSai sai; | ||
sai.initialize(0, &test_services); | ||
ASSERT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.bulkGetStats(SAI_NULL_OBJECT_ID, | ||
SAI_OBJECT_TYPE_PORT, | ||
0, | ||
nullptr, | ||
0, | ||
nullptr, | ||
SAI_STATS_MODE_BULK_READ_AND_CLEAR, | ||
nullptr, | ||
nullptr)); | ||
ASSERT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.bulkClearStats(SAI_NULL_OBJECT_ID, | ||
SAI_OBJECT_TYPE_PORT, | ||
0, | ||
nullptr, | ||
0, | ||
nullptr, | ||
SAI_STATS_MODE_BULK_READ_AND_CLEAR, | ||
nullptr)); | ||
} |