[PATCH v8 5/7] perf/tests/expr: Added test for runtime param in metric expression

From: Kajol Jain
Date: Wed Apr 01 2020 - 16:35:03 EST


Added test case for parsing "?" in metric expression.

Signed-off-by: Kajol Jain <kjain@xxxxxxxxxxxxx>
---
tools/perf/tests/expr.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
index 516504cf0ea5..f9e8e5628836 100644
--- a/tools/perf/tests/expr.c
+++ b/tools/perf/tests/expr.c
@@ -59,6 +59,14 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
TEST_ASSERT_VAL("find other", !strcmp(other[2], "BOZO"));
TEST_ASSERT_VAL("find other", other[3] == NULL);

+ TEST_ASSERT_VAL("find other",
+ expr__find_other("EVENT1\\,param\\=?@ + EVENT2\\,param\\=?@", NULL,
+ &other, &num_other, 3) == 0);
+ TEST_ASSERT_VAL("find other", num_other == 2);
+ TEST_ASSERT_VAL("find other", !strcmp(other[0], "EVENT1,param=3/"));
+ TEST_ASSERT_VAL("find other", !strcmp(other[1], "EVENT2,param=3/"));
+ TEST_ASSERT_VAL("find other", other[2] == NULL);
+
for (i = 0; i < num_other; i++)
zfree(&other[i]);
free((void *)other);
--
2.21.0