diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2024-01-10 15:26:05 +0100 |
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2024-01-18 22:04:05 +0100 |
| commit | 09047d2bf614d7794fb855923caa94cbfeb94ceb (patch) | |
| tree | 3550cb1119ba8a4c598f2e245f33355e84eab447 /pceplib/test/pcep_utils_counters_test.c | |
| parent | 94178edac3b36c6b2ebc09173a589b14419cf04e (diff) | |
pceplib: add json string option to subgroup counter
The created counters in pceplib library are structures with
a string attribute which is used for further display. This
string information is not formatted for json output.
Add a second option in the create_subgroup_counter() creation
API to provide the json attribute output.
Create a json naming compatible with caml format for each
subgroup counter used.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'pceplib/test/pcep_utils_counters_test.c')
| -rw-r--r-- | pceplib/test/pcep_utils_counters_test.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/pceplib/test/pcep_utils_counters_test.c b/pceplib/test/pcep_utils_counters_test.c index 2cad9a6443..d3d5197b53 100644 --- a/pceplib/test/pcep_utils_counters_test.c +++ b/pceplib/test/pcep_utils_counters_test.c @@ -106,17 +106,19 @@ void test_create_subgroup_counter() { uint16_t counter_id = 1; char counter_name[] = "my counter"; + char counter_name_json[] = "myCounter"; struct counters_subgroup *subgroup = create_counters_subgroup("subgroup", 1, 2); - CU_ASSERT_FALSE( - create_subgroup_counter(NULL, counter_id, counter_name)); + CU_ASSERT_FALSE(create_subgroup_counter(NULL, counter_id, counter_name, + counter_name_json)); CU_ASSERT_FALSE(create_subgroup_counter(subgroup, counter_id + 1, counter_name)); - CU_ASSERT_FALSE(create_subgroup_counter(subgroup, counter_id, NULL)); + CU_ASSERT_FALSE( + create_subgroup_counter(subgroup, counter_id, NULL, NULL)); CU_ASSERT_EQUAL(subgroup->num_counters, 0); - CU_ASSERT_TRUE( - create_subgroup_counter(subgroup, counter_id, counter_name)); + CU_ASSERT_TRUE(create_subgroup_counter(subgroup, counter_id, + counter_name, counter_name_json)); CU_ASSERT_EQUAL(subgroup->num_counters, 1); delete_counters_subgroup(subgroup); @@ -146,7 +148,7 @@ void test_reset_group_counters() struct counters_group *group = create_counters_group("group", 10); struct counters_subgroup *subgroup = create_counters_subgroup("subgroup", subgroup_id, 10); - create_subgroup_counter(subgroup, counter_id, "counter"); + create_subgroup_counter(subgroup, counter_id, "counter", "counter"); add_counters_subgroup(group, subgroup); struct counter *counter = subgroup->counters[counter_id]; @@ -164,7 +166,7 @@ void test_reset_subgroup_counters() uint16_t counter_id = 1; struct counters_subgroup *subgroup = create_counters_subgroup("subgroup", 1, 10); - create_subgroup_counter(subgroup, counter_id, "counter"); + create_subgroup_counter(subgroup, counter_id, "counter", "counter"); struct counter *counter = subgroup->counters[counter_id]; counter->counter_value = 100; @@ -183,7 +185,7 @@ void test_increment_counter() struct counters_group *group = create_counters_group("group", 10); struct counters_subgroup *subgroup = create_counters_subgroup("subgroup", subgroup_id, 10); - create_subgroup_counter(subgroup, counter_id, "counter"); + create_subgroup_counter(subgroup, counter_id, "counter", "counter"); add_counters_subgroup(group, subgroup); struct counter *counter = subgroup->counters[counter_id]; @@ -205,7 +207,7 @@ void test_increment_subgroup_counter() uint32_t counter_value = 100; struct counters_subgroup *subgroup = create_counters_subgroup("subgroup", 1, 10); - create_subgroup_counter(subgroup, counter_id, "counter"); + create_subgroup_counter(subgroup, counter_id, "counter", "counter"); struct counter *counter = subgroup->counters[counter_id]; counter->counter_value = counter_value; @@ -225,7 +227,7 @@ void test_dump_counters_group_to_log() struct counters_group *group = create_counters_group("group", 10); struct counters_subgroup *subgroup = create_counters_subgroup("subgroup", subgroup_id, 10); - create_subgroup_counter(subgroup, counter_id, "counter"); + create_subgroup_counter(subgroup, counter_id, "counter", "counter"); add_counters_subgroup(group, subgroup); CU_ASSERT_FALSE(dump_counters_group_to_log(NULL)); @@ -240,7 +242,7 @@ void test_dump_counters_subgroup_to_log() uint16_t counter_id = 1; struct counters_subgroup *subgroup = create_counters_subgroup("subgroup", subgroup_id, 10); - create_subgroup_counter(subgroup, counter_id, "counter"); + create_subgroup_counter(subgroup, counter_id, "counter", "counter"); CU_ASSERT_FALSE(dump_counters_subgroup_to_log(NULL)); CU_ASSERT_TRUE(dump_counters_subgroup_to_log(subgroup)); |
