Skip to content

Commit

Permalink
From patchwork series 435346
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed Dec 5, 2024
1 parent 1ecdccb commit 106732e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tools/perf/tests/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
double val, num_cpus_online, num_cpus, num_cores, num_dies, num_packages;
int ret;
struct expr_parse_ctx *ctx;
bool is_intel = false;
char strcmp_cpuid_buf[256];
struct perf_cpu cpu = {-1};
char *cpuid = get_cpuid_allow_env_override(cpu);
char *escaped_cpuid1, *escaped_cpuid2;

TEST_ASSERT_VAL("get_cpuid", cpuid);
is_intel = strstr(cpuid, "Intel") != NULL;

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

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

TEST_ASSERT_VAL("#system_tsc_freq", expr__parse(&val, ctx, "#system_tsc_freq") == 0);
if (is_intel)
TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0);
else
TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO);

if (expr__parse(&val, ctx, "#system_tsc_freq") == 0) {
bool is_intel = strstr(cpuid, "Intel") != NULL;

if (is_intel)
TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0);
else
TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO);
} else {
#if defined(__i386__) || defined(__x86_64__)
TEST_ASSERT_VAL("#system_tsc_freq unsupported", 0);
#endif
}
/*
* Source count returns the number of events aggregating in a leader
* event including the leader. Check parsing yields an id.
Expand Down

0 comments on commit 106732e

Please sign in to comment.