Skip to content

Commit a93a620

Browse files
captain5050namhyung
authored andcommitted
perf test expr: Fix system_tsc_freq for only x86
The refactoring of tool PMU events to have a PMU then adding the expr literals to the tool PMU made it so that the literal system_tsc_freq was only supported on x86. Update the test expectations to match - namely the parsing is x86 specific and only yields a non-zero value on Intel. Fixes: 609aa26 ("perf tool_pmu: Switch to standard pmu functions and json descriptions") Reported-by: Athira Rajeev <[email protected]> Closes: https://lore.kernel.org/linux-perf-users/[email protected]/ Co-developed-by: Athira Rajeev <[email protected]> Tested-by: Namhyung Kim <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Cc: James Clark <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent d4e17a3 commit a93a620

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tools/perf/tests/expr.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
7575
double val, num_cpus_online, num_cpus, num_cores, num_dies, num_packages;
7676
int ret;
7777
struct expr_parse_ctx *ctx;
78-
bool is_intel = false;
7978
char strcmp_cpuid_buf[256];
8079
struct perf_cpu cpu = {-1};
8180
char *cpuid = get_cpuid_allow_env_override(cpu);
8281
char *escaped_cpuid1, *escaped_cpuid2;
8382

8483
TEST_ASSERT_VAL("get_cpuid", cpuid);
85-
is_intel = strstr(cpuid, "Intel") != NULL;
8684

8785
TEST_ASSERT_EQUAL("ids_union", test_ids_union(), 0);
8886

@@ -245,12 +243,19 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
245243
if (num_dies) // Some platforms do not have CPU die support, for example s390
246244
TEST_ASSERT_VAL("#num_dies >= #num_packages", num_dies >= num_packages);
247245

248-
TEST_ASSERT_VAL("#system_tsc_freq", expr__parse(&val, ctx, "#system_tsc_freq") == 0);
249-
if (is_intel)
250-
TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0);
251-
else
252-
TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO);
253246

247+
if (expr__parse(&val, ctx, "#system_tsc_freq") == 0) {
248+
bool is_intel = strstr(cpuid, "Intel") != NULL;
249+
250+
if (is_intel)
251+
TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0);
252+
else
253+
TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO);
254+
} else {
255+
#if defined(__i386__) || defined(__x86_64__)
256+
TEST_ASSERT_VAL("#system_tsc_freq unsupported", 0);
257+
#endif
258+
}
254259
/*
255260
* Source count returns the number of events aggregating in a leader
256261
* event including the leader. Check parsing yields an id.

0 commit comments

Comments
 (0)