This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tsg-service-chaining-…/platform/test/gtest_sf_status.cpp
2024-09-27 19:11:47 +08:00

50 lines
1.3 KiB
C++

#include <gtest/gtest.h>
#include "sf_status.h"
TEST(SF_STATUS, TEST)
{
uuid_t sf_uuid1;
uuid_t sf_uuid2;
uuid_generate(sf_uuid1);
uuid_generate(sf_uuid2);
struct kafka *kfk = kafka_create("./test_resource/sce.conf");
EXPECT_TRUE(kfk != NULL);
struct sf_status *status = sf_status_create("./test_resource/sce.conf", kfk);
EXPECT_TRUE(status != NULL);
EXPECT_TRUE(sf_status_get_ouput_interval_ms(status) == 1000);
struct sf_status_key key1 = {0};
key1.vsys_id = 11;
uuid_copy(key1.sf_uuid, sf_uuid1);
struct sf_status_key key2 = {0};
key2.vsys_id = 22;
uuid_copy(key2.sf_uuid, sf_uuid2);
sf_status_update(status, &key1, 0, 1);
sf_status_update(status, &key2, 1, 2);
printf("\n========================================\n expect key1 + key2 \n========================================\n");
sf_status_output(status);
sf_status_delete(status, &key1);
printf("\n========================================\n expect only key2 \n========================================\n");
sf_status_output(status);
sf_status_delete(status, &key2);
printf("\n========================================\n expect no output \n========================================\n");
sf_status_output(status);
sleep(2);
sf_status_destory(status);
kafka_destroy(kfk);
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}