Skip to content

Commit

Permalink
Add nat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 23, 2021
1 parent 7468777 commit fc28438
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions unittest/vslib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ testslibsaivs_SOURCES = main_libsaivs.cpp \
test_sai_vs_mcastfdb.cpp \
test_sai_vs_mirror.cpp \
test_sai_vs_mpls.cpp \
test_sai_vs_nat.cpp \
test_sai_vs_hash.cpp \
test_sai_vs_vlan.cpp \
test_sai_vs_hostif.cpp \
Expand Down
35 changes: 35 additions & 0 deletions unittest/vslib/test_sai_vs_nat.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, nat)
{
sai_nat_api_t *api = nullptr;

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

EXPECT_NE(api, nullptr);

sai_nat_entry_t id ;

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_nat_entry(&id,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_nat_entry(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_nat_entry_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_nat_entry_attribute(0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_nat_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_nat_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_nat_entries_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_nat_entries_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0));

sai_object_id_t id1;

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_nat_zone_counter(&id1,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_nat_zone_counter(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_nat_zone_counter_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_nat_zone_counter_attribute(0,0,0));
}

0 comments on commit fc28438

Please sign in to comment.