@@ -25,6 +25,8 @@ class TestClient
25
25
26
26
void test_query_api ();
27
27
28
+ void test_fdb_flush ();
29
+
28
30
private:
29
31
30
32
int profileGetNextValue (
@@ -411,6 +413,50 @@ void TestClient::test_query_api()
411
413
ASSERT_SUCCESS (sai_api_uninitialize ());
412
414
}
413
415
416
+ void TestClient::test_fdb_flush ()
417
+ {
418
+ SWSS_LOG_ENTER ();
419
+
420
+ m_profileMap.clear ();
421
+
422
+ m_profileMap[SAI_REDIS_KEY_ENABLE_CLIENT] = " true" ; // act as a client
423
+
424
+ m_profileIter = m_profileMap.begin ();
425
+
426
+ m_smt.profileGetValue = std::bind (&TestClient::profileGetValue, this , _1, _2);
427
+ m_smt.profileGetNextValue = std::bind (&TestClient::profileGetNextValue, this , _1, _2, _3);
428
+
429
+ m_test_services = m_smt.getServiceMethodTable ();
430
+
431
+ ASSERT_SUCCESS (sai_api_initialize (0 , &m_test_services));
432
+
433
+ sai_switch_api_t * switch_api;
434
+
435
+ ASSERT_SUCCESS (sai_api_query (SAI_API_SWITCH, (void **)&switch_api));
436
+
437
+ sai_attribute_t attr;
438
+
439
+ // connect to existing switch
440
+ attr.id = SAI_SWITCH_ATTR_INIT_SWITCH;
441
+ attr.value .booldata = false ;
442
+
443
+ sai_object_id_t switch_id = SAI_NULL_OBJECT_ID;
444
+
445
+ ASSERT_SUCCESS (switch_api->create_switch (&switch_id, 1 , &attr));
446
+
447
+ ASSERT_TRUE (switch_id != SAI_NULL_OBJECT_ID);
448
+
449
+ SWSS_LOG_NOTICE (" switchId: %s" , sai_serialize_object_id (switch_id).c_str ());
450
+
451
+ sai_fdb_api_t * fdb_api;
452
+
453
+ ASSERT_SUCCESS (sai_api_query (SAI_API_FDB, (void **)&fdb_api));
454
+
455
+ ASSERT_SUCCESS (fdb_api->flush_fdb_entries (switch_id, 0 , NULL ));
456
+
457
+ ASSERT_SUCCESS (sai_api_uninitialize ());
458
+ }
459
+
414
460
int main ()
415
461
{
416
462
swss::Logger::getInstance ().setMinPrio (swss::Logger::SWSS_DEBUG);
@@ -427,5 +473,7 @@ int main()
427
473
428
474
tc.test_query_api ();
429
475
476
+ tc.test_fdb_flush ();
477
+
430
478
return EXIT_SUCCESS;
431
479
}
0 commit comments