Skip to content

Commit

Permalink
fixing aclorch_ut
Browse files Browse the repository at this point in the history
Signed-off-by: Nikola Dancejic <ndancejic@microsoft.com>
  • Loading branch information
Ndancejic committed May 23, 2024
1 parent 4fd3503 commit 11e5cce
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/mock_tests/aclorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern sai_port_api_t *sai_port_api;
extern sai_vlan_api_t *sai_vlan_api;
extern sai_bridge_api_t *sai_bridge_api;
extern sai_route_api_t *sai_route_api;
extern sai_route_api_t *sai_neighbor_api;
extern sai_mpls_api_t *sai_mpls_api;
extern sai_next_hop_group_api_t* sai_next_hop_group_api;
extern string gMySwitchType;
Expand Down Expand Up @@ -318,6 +319,7 @@ namespace aclorch_test
sai_api_query(SAI_API_PORT, (void **)&sai_port_api);
sai_api_query(SAI_API_VLAN, (void **)&sai_vlan_api);
sai_api_query(SAI_API_ROUTE, (void **)&sai_route_api);
sai_api_query(SAI_API_NEIGHBOR, (void **)&sai_neighbor_api);
sai_api_query(SAI_API_MPLS, (void **)&sai_mpls_api);
sai_api_query(SAI_API_ACL, (void **)&sai_acl_api);
sai_api_query(SAI_API_NEXT_HOP_GROUP, (void **)&sai_next_hop_group_api);
Expand Down Expand Up @@ -490,6 +492,7 @@ namespace aclorch_test
sai_vlan_api = nullptr;
sai_bridge_api = nullptr;
sai_route_api = nullptr;
sai_neighbor_api = nullptr;
sai_mpls_api = nullptr;
}

Expand Down
31 changes: 31 additions & 0 deletions tests/mock_tests/bulker_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "bulker.h"

extern sai_route_api_t *sai_route_api;
extern sai_neighbor_api_t *sai_neighbor_api;

namespace bulker_test
{
Expand All @@ -17,12 +18,18 @@ namespace bulker_test
{
ASSERT_EQ(sai_route_api, nullptr);
sai_route_api = new sai_route_api_t();

ASSERT_EQ(sai_neighbor_api, nullptr);
sai_neighbor_api = new sai_neighbor_api_t();
}

void TearDown() override
{
delete sai_route_api;
sai_route_api = nullptr;

delete sai_neighbor_api;
sai_neighbor_api = nullptr;
}
};

Expand Down Expand Up @@ -142,4 +149,28 @@ namespace bulker_test
// Confirm route entry is not pending removal
ASSERT_FALSE(gRouteBulker.bulk_entry_pending_removal(route_entry_non_remove));
}

TEST_F(BulkerTest, NeighborBulker)
{
// Create bulker
EntityBulker<sai_neighbor_api_t> gNeighBulker(sai_neighbor_api, 1000);
deque<sai_status_t> object_statuses;

// Check max bulk size
ASSERT_EQ(gNeighBulker.max_bulk_size, 1000);

// Create a dummy neighbor entry
sai_neighbor_entry_t neighbor_entry_remove;
neighbor_entry_remove.ip_address.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
neighbor_entry_remove.ip_address.addr.ip4 = 0x10000001;
neighbor_entry_remove.rif_id = 0x0;
neighbor_entry_remove.switch_id = 0x0;

// Put neighbor entry into remove
object_statuses.emplace_back();
gNeighBulker.remove_entry(&object_statuses.back(), &neighbor_entry_remove);

// Confirm neighbor entry is pending removal
ASSERT_TRUE(gNeighBulker.bulk_entry_pending_removal(neighbor_entry_remove));
}
}

0 comments on commit 11e5cce

Please sign in to comment.