From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
To: <dev@dpdk.org>
Cc: <ciara.power@intel.com>, <jerinj@marvell.com>,
<kirankumark@marvell.com>, <ndabilpuram@marvell.com>,
<skori@marvell.com>, <skoteshwar@marvell.com>,
Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Subject: [dpdk-dev] [v1, 2/3] test/telemetry: add unit tests for pointer value
Date: Thu, 29 Jul 2021 20:55:36 +0530 [thread overview]
Message-ID: <604cef7dae418edfa928e63731772e51ad26d6d3.1627572033.git.gmuthukrishn@marvell.com> (raw)
In-Reply-To: <cover.1627572033.git.gmuthukrishn@marvell.com>
Adding tests to evaluate pointer value in array and dict.
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
app/test/test_telemetry_data.c | 124 +++++++++++++++++++++++++++++++++
app/test/test_telemetry_json.c | 28 ++++++--
2 files changed, 145 insertions(+), 7 deletions(-)
diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c
index f34d691265..59f68f135a 100644
--- a/app/test/test_telemetry_data.c
+++ b/app/test/test_telemetry_data.c
@@ -301,6 +301,126 @@ test_array_with_array_u64_values(void)
return TEST_OUTPUT("{\"/test\":[[0,1,2,3,4],[0,1,2,3,4]]}");
}
+static int
+test_case_array_ptr(void)
+{
+ int *p, i, j, a[] = {1, 2, 3, 4, 5};
+ char exp[120];
+
+ memset(&response_data, 0, sizeof(response_data));
+ memset(exp, 0, sizeof(exp));
+ rte_tel_data_start_array(&response_data, RTE_TEL_PTR_VAL);
+
+ i = sprintf(exp, "{\"/test\":[");
+ for (j = 0; j < 5; j++) {
+ p = &a[j];
+ i += sprintf(exp + i, "\"%p\",", p);
+ rte_tel_data_add_array_ptr(&response_data, p);
+ }
+
+ sprintf(exp + i - 1, "]}");
+ return TEST_OUTPUT(exp);
+}
+
+static int
+test_case_add_dict_ptr(void)
+{
+ int *p, i, j, a[] = {1, 2, 3, 4, 5};
+ char name[8], exp[160];
+
+ memset(&response_data, 0, sizeof(response_data));
+ memset(exp, 0, sizeof(exp));
+ rte_tel_data_start_dict(&response_data);
+
+ i = sprintf(exp, "{\"/test\":{");
+ for (j = 0; j < 5; j++) {
+ p = &a[j];
+ sprintf(name, "dict_%d", j);
+ i += sprintf(exp + i, "\"%s\":\"%p\",", name, p);
+ rte_tel_data_add_dict_ptr(&response_data, name, p);
+ }
+
+ sprintf(exp + i - 1, "}}");
+ return TEST_OUTPUT(exp);
+}
+
+static int
+test_dict_with_array_ptr_values(void)
+{
+ int *p, i, j, a[] = {1, 2, 3, 4, 5};
+ char exp[256];
+
+ struct rte_tel_data *child_data = rte_tel_data_alloc();
+ rte_tel_data_start_array(child_data, RTE_TEL_PTR_VAL);
+
+ struct rte_tel_data *child_data2 = rte_tel_data_alloc();
+ rte_tel_data_start_array(child_data2, RTE_TEL_PTR_VAL);
+
+ memset(&response_data, 0, sizeof(response_data));
+ memset(exp, 0, sizeof(exp));
+ rte_tel_data_start_dict(&response_data);
+
+ i = sprintf(exp, "{\"/test\":{\"dict_0\":[");
+ for (j = 0; j < 5; j++) {
+ p = &a[j];
+ i += sprintf(exp + i, "\"%p\",", p);
+ rte_tel_data_add_array_ptr(child_data, p);
+ }
+
+ i += sprintf(exp + i - 1, "],\"dict_1\":[");
+ for (j = 5; j > 0; j--) {
+ p = &a[j - 1];
+ i += sprintf(exp + i - 1, "\"%p\",", p);
+ rte_tel_data_add_array_ptr(child_data2, p);
+ }
+
+ sprintf(exp + i - 2, "]}}");
+ rte_tel_data_add_dict_container(&response_data, "dict_0",
+ child_data, 0);
+ rte_tel_data_add_dict_container(&response_data, "dict_1",
+ child_data2, 0);
+
+ return TEST_OUTPUT(exp);
+}
+
+static int
+test_array_with_array_ptr_values(void)
+{
+ int *p, i, j, a[] = {1, 2, 3, 4, 5};
+ char exp[256];
+
+ struct rte_tel_data *child_data = rte_tel_data_alloc();
+ rte_tel_data_start_array(child_data, RTE_TEL_PTR_VAL);
+
+ struct rte_tel_data *child_data2 = rte_tel_data_alloc();
+ rte_tel_data_start_array(child_data2, RTE_TEL_PTR_VAL);
+
+ memset(&response_data, 0, sizeof(response_data));
+ memset(exp, 0, sizeof(exp));
+ rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
+
+ i = sprintf(exp, "{\"/test\":[[");
+ for (j = 0; j < 5; j++) {
+ p = &a[j];
+ i += sprintf(exp + i, "\"%p\",", p);
+ rte_tel_data_add_array_ptr(child_data, p);
+ }
+
+ i += sprintf(exp + i - 1, "],[");
+ for (j = 5; j > 0; j--) {
+ p = &a[j - 1];
+ i += sprintf(exp + i - 1, "\"%p\",", p);
+ rte_tel_data_add_array_ptr(child_data2, p);
+ }
+
+ sprintf(exp + i - 2, "]]}");
+
+ rte_tel_data_add_array_container(&response_data, child_data, 0);
+ rte_tel_data_add_array_container(&response_data, child_data2, 0);
+
+ return TEST_OUTPUT(exp);
+}
+
static int
connect_to_socket(void)
{
@@ -350,13 +470,17 @@ test_telemetry_data(void)
test_case test_cases[] = {test_case_array_string,
test_case_array_int, test_case_array_u64,
+ test_case_array_ptr,
test_case_add_dict_int, test_case_add_dict_u64,
+ test_case_add_dict_ptr,
test_case_add_dict_string,
test_dict_with_array_int_values,
test_dict_with_array_u64_values,
+ test_dict_with_array_ptr_values,
test_dict_with_array_string_values,
test_array_with_array_int_values,
test_array_with_array_u64_values,
+ test_array_with_array_ptr_values,
test_array_with_array_string_values };
rte_telemetry_register_cmd(REQUEST_CMD, test_cb, "Test");
diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c
index 790181d316..3e8e60638c 100644
--- a/app/test/test_telemetry_json.c
+++ b/app/test/test_telemetry_json.c
@@ -11,18 +11,22 @@
static int
test_basic_array(void)
{
- const char *expected = "[\"meaning of life\",42]";
- char buf[1024];
- int used = 0;
+ char buf[1024], expected[80];
+ int used = 0, n = 42, *p;
printf("%s: ", __func__);
used = rte_tel_json_empty_array(buf, sizeof(buf), used);
if (used != 2 || strcmp(buf, "[]"))
return -1;
+ p = &n;
+ memset(expected, 0, sizeof(expected));
+ sprintf(expected, "[\"meaning of life\",42,\"%p\"]", p);
+
used = rte_tel_json_add_array_string(buf, sizeof(buf), used,
"meaning of life");
- used = rte_tel_json_add_array_int(buf, sizeof(buf), used, 42);
+ used = rte_tel_json_add_array_int(buf, sizeof(buf), used, n);
+ used = rte_tel_json_add_array_ptr(buf, sizeof(buf), used, p);
printf("buf = '%s', expected = '%s'\n", buf, expected);
if (used != (int)strlen(expected))
@@ -33,14 +37,24 @@ test_basic_array(void)
static int
test_basic_obj(void)
{
- const char *expected = "{\"weddings\":4,\"funerals\":1}";
- char buf[1024];
- int used = 0;
+ char buf[1024], expected[80];
+ int used = 0, n = 42, *p;
+
+ p = &n;
+ memset(expected, 0, sizeof(expected));
+ sprintf(expected,
+ "{\"weddings\":4,\"funerals\":1,"
+ "\"address\":\"%p\",\"reset\":\"(nil)\"}", p);
used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
"weddings", 4);
used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
"funerals", 1);
+ used = rte_tel_json_add_obj_ptr(buf, sizeof(buf), used,
+ "address", p);
+ p = NULL;
+ used = rte_tel_json_add_obj_ptr(buf, sizeof(buf), used,
+ "reset", p);
printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
if (used != (int)strlen(expected))
--
2.25.1
next prev parent reply other threads:[~2021-07-29 15:26 UTC|newest]
Thread overview: 121+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-29 15:25 [dpdk-dev] [v1, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
2021-07-29 15:25 ` [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
2021-07-29 15:48 ` Bruce Richardson
2021-07-30 12:08 ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
2021-08-01 17:40 ` Gowrishankar Muthukrishnan
2021-07-29 15:25 ` Gowrishankar Muthukrishnan [this message]
2021-07-29 15:25 ` [dpdk-dev] [v1, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-01 17:37 ` [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
2021-08-01 17:37 ` [dpdk-dev] [v2, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
2021-08-01 17:37 ` [dpdk-dev] [v2, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
2021-08-01 17:37 ` [dpdk-dev] [v2, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-03 8:05 ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
2021-08-03 8:05 ` [dpdk-dev] [v3, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
2021-08-03 8:05 ` [dpdk-dev] [v3, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
2021-08-03 8:05 ` [dpdk-dev] [v3, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-11 15:59 ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Power, Ciara
2021-08-11 16:18 ` Gowrishankar Muthukrishnan
2021-08-24 8:53 ` Gowrishankar Muthukrishnan
2021-08-25 10:09 ` Thomas Monjalon
2021-08-25 14:38 ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
2021-08-26 17:15 ` [dpdk-dev] [v4, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
2021-08-26 17:15 ` [dpdk-dev] [v4, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-26 18:06 ` Bruce Richardson
2021-08-27 6:43 ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
2021-08-26 17:15 ` [dpdk-dev] [v4, 2/2] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-08-27 6:41 ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
2021-08-27 6:41 ` [dpdk-dev] [v5, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-27 6:41 ` [dpdk-dev] [v5, 2/2] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-09-04 3:25 ` [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
2021-09-04 3:25 ` [dpdk-dev] [v6, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-09-04 3:25 ` [dpdk-dev] [v6, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-09-04 3:25 ` [dpdk-dev] [v6, 3/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-09-04 3:25 ` [dpdk-dev] [v6, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
2021-09-08 17:03 ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
2021-09-08 17:03 ` [dpdk-dev] [v7, 1/6] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-09-08 17:03 ` [dpdk-dev] [v7, 2/6] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-09-08 17:03 ` [dpdk-dev] [v7, 3/6] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-09-08 17:03 ` [dpdk-dev] [v7, 4/6] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
2021-09-08 17:03 ` [dpdk-dev] [v7, 5/6] telemetry: fix json output buffer size Gowrishankar Muthukrishnan
2021-09-21 11:02 ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
2021-09-22 9:21 ` Power, Ciara
2021-09-23 5:53 ` Gowrishankar Muthukrishnan
2021-09-30 8:47 ` Power, Ciara
2021-09-30 9:00 ` Gowrishankar Muthukrishnan
2021-10-07 9:04 ` Power, Ciara
2021-09-23 6:21 ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
2021-09-23 6:26 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
2021-09-29 4:18 ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
2021-10-06 17:38 ` Thomas Monjalon
2021-10-07 4:58 ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
2021-10-07 7:22 ` Thomas Monjalon
2021-10-07 8:36 ` Gowrishankar Muthukrishnan
2021-10-11 10:54 ` [dpdk-dev] [v6] telemetry: remove limitation on JSON output buffer length Gowrishankar Muthukrishnan
2021-10-13 11:06 ` Power, Ciara
2021-10-13 15:25 ` Thomas Monjalon
2021-09-08 17:03 ` [dpdk-dev] [v7, 6/6] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
2021-09-21 11:32 ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
2021-09-29 6:45 ` [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info Gowrishankar Muthukrishnan
2021-10-22 12:28 ` [dpdk-dev] [v2] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
2021-10-22 12:37 ` [dpdk-dev] [v5] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
2021-10-22 12:59 ` [dpdk-dev] [v6] " Gowrishankar Muthukrishnan
2021-10-22 12:57 ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
2021-10-22 16:02 ` [dpdk-dev] [v7] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
2021-10-26 13:44 ` [dpdk-dev] [v8] " Gowrishankar Muthukrishnan
2021-10-26 14:10 ` Akhil Goyal
2021-11-03 4:43 ` Gowrishankar Muthukrishnan
2021-10-30 17:41 ` [dpdk-dev] [v9] " Gowrishankar Muthukrishnan
2021-10-30 17:45 ` [dpdk-dev] [v1] security: add telemetry endpoint for cryptodev security capabilities Gowrishankar Muthukrishnan
2021-10-31 5:24 ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
2021-11-02 14:42 ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
2021-11-02 14:52 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
2021-11-03 19:37 ` Akhil Goyal
2021-11-04 4:29 ` Gowrishankar Muthukrishnan
2021-11-04 5:11 ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
2021-11-04 10:50 ` Akhil Goyal
2021-10-25 7:26 ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Akhil Goyal
2021-10-26 13:13 ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
2021-10-26 14:12 ` Akhil Goyal
2021-10-26 15:44 ` Gowrishankar Muthukrishnan
2021-10-26 18:34 ` Akhil Goyal
2021-10-26 12:52 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
2021-09-29 7:01 ` [dpdk-dev] [v3] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
2021-09-29 8:56 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
2021-09-16 8:52 ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Jerin Jacob
2021-09-21 10:52 ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
2021-09-21 10:52 ` [dpdk-dev] [v8, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-09-21 10:52 ` [dpdk-dev] [v8, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-09-29 6:40 ` [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info Gowrishankar Muthukrishnan
2021-10-13 15:21 ` Thomas Monjalon
2021-10-13 15:26 ` Bruce Richardson
2021-10-13 15:40 ` Bruce Richardson
2021-10-22 3:28 ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
2021-10-22 5:55 ` David Marchand
2021-10-22 16:11 ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
2021-10-22 20:38 ` Thomas Monjalon
2021-09-21 10:52 ` [dpdk-dev] [v8, 3/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-09-21 10:52 ` [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
2021-09-21 11:27 ` Jerin Jacob
2021-09-21 11:53 ` Bruce Richardson
2021-09-21 12:16 ` Olivier Matz
2021-09-29 4:25 ` [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info Gowrishankar Muthukrishnan
2021-10-11 14:40 ` Ferruh Yigit
2021-10-11 15:40 ` Bruce Richardson
2021-10-11 15:44 ` Ferruh Yigit
2021-10-14 21:47 ` Ferruh Yigit
2021-09-29 6:54 ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
2021-09-29 6:55 ` [dpdk-dev] [v9 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-10-14 15:22 ` [dpdk-dev] [EXT] " Harman Kalra
2021-09-29 6:55 ` [dpdk-dev] [v9 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-10-14 16:37 ` [dpdk-dev] [EXT] " Harman Kalra
2021-09-29 6:55 ` [dpdk-dev] [v9 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
2021-10-14 16:43 ` [dpdk-dev] [EXT] " Harman Kalra
2021-09-29 6:55 ` [dpdk-dev] [v9 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
2021-10-14 16:47 ` [dpdk-dev] [EXT] " Harman Kalra
2021-10-19 11:27 ` [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
2021-10-19 11:27 ` [dpdk-dev] [v10 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-10-19 11:27 ` [dpdk-dev] [v10 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-10-19 11:27 ` [dpdk-dev] [v10 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
2021-10-19 11:27 ` [dpdk-dev] [v10 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
2021-10-19 16:42 ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Jerin Jacob
2021-10-20 13:30 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=604cef7dae418edfa928e63731772e51ad26d6d3.1627572033.git.gmuthukrishn@marvell.com \
--to=gmuthukrishn@marvell.com \
--cc=ciara.power@intel.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=skori@marvell.com \
--cc=skoteshwar@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).