Skip to content

Commit 3990aaa

Browse files
captain5050intel-lab-lkp
authored andcommitted
perf pmu-events: Fix testing with JEVENTS_ARCH=all
The #slots literal will return NAN when not on ARM64 which causes a perf test failure when not on an ARM64 for a JEVENTS_ARCH=all build: .. 10.4: Parsing of PMU event table metrics with fake PMUs : FAILED! .. Add an is_test boolean so that the failure can be avoided when running as a test. Fixes: acef233 ("perf pmu: Add #slots literal support for arm64") Signed-off-by: Ian Rogers <irogers@google.com>
1 parent b5d58a0 commit 3990aaa

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

tools/perf/tests/pmu-events.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ static int metric_parse_fake(const char *metric_name, const char *str)
950950
pr_debug("expr__ctx_new failed");
951951
return TEST_FAIL;
952952
}
953+
ctx->sctx.is_test = true;
953954
if (expr__find_ids(str, NULL, ctx) < 0) {
954955
pr_err("expr__find_ids failed\n");
955956
return -1;

tools/perf/util/expr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ struct expr_scanner_ctx {
99
char *user_requested_cpu_list;
1010
int runtime;
1111
bool system_wide;
12+
bool is_test;
1213
};
1314

1415
struct expr_parse_ctx {

tools/perf/util/expr.l

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ static int literal(yyscan_t scanner, const struct expr_scanner_ctx *sctx)
8484
YYSTYPE *yylval = expr_get_lval(scanner);
8585

8686
yylval->num = expr__get_literal(expr_get_text(scanner), sctx);
87-
if (isnan(yylval->num))
88-
return EXPR_ERROR;
89-
87+
if (isnan(yylval->num)) {
88+
if (!sctx->is_test)
89+
return EXPR_ERROR;
90+
yylval->num = 1;
91+
}
9092
return LITERAL;
9193
}
9294
%}

0 commit comments

Comments
 (0)