perf test: Add basic core_wide expression test
authorIan Rogers <irogers@google.com>
Wed, 31 Aug 2022 17:49:26 +0000 (10:49 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 4 Oct 2022 11:55:22 +0000 (08:55 -0300)
Add basic test for coverage, similar to #smt_on.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Ahmad Yasin <ahmad.yasin@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Miaoqian Lin <linmq006@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20220831174926.579643-8-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/expr.c

index db736ed49556f35f090965760227814cc3df4728..8bd7197668140087cbf7cb98586b972290149db9 100644 (file)
@@ -158,6 +158,9 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
        {
                struct cpu_topology *topology = cpu_topology__new();
                bool smton = smt_on(topology);
+               bool corewide = core_wide(/*system_wide=*/false,
+                                         /*user_requested_cpus=*/false,
+                                         topology);
 
                cpu_topology__delete(topology);
                expr__ctx_clear(ctx);
@@ -168,6 +171,16 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
                TEST_ASSERT_VAL("find ids", hashmap__find(ctx->ids,
                                                          smton ? "EVENT1" : "EVENT2",
                                                          (void **)&val_ptr));
+
+               expr__ctx_clear(ctx);
+               TEST_ASSERT_VAL("find ids",
+                               expr__find_ids("EVENT1 if #core_wide else EVENT2",
+                                       NULL, ctx) == 0);
+               TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 1);
+               TEST_ASSERT_VAL("find ids", hashmap__find(ctx->ids,
+                                                         corewide ? "EVENT1" : "EVENT2",
+                                                         (void **)&val_ptr));
+
        }
        /* The expression is a constant 1.0 without needing to evaluate EVENT1. */
        expr__ctx_clear(ctx);