diff options
Diffstat (limited to 'tools/perf/tests/event-times.c')
-rw-r--r-- | tools/perf/tests/event-times.c | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 1a2686f1fcf0..d824a726906c 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c @@ -1,20 +1,23 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/compiler.h> +#include <linux/string.h> #include <errno.h> #include <inttypes.h> #include <string.h> #include <sys/wait.h> +#include <perf/cpumap.h> #include "tests.h" #include "evlist.h" #include "evsel.h" #include "util.h" #include "debug.h" +#include "parse-events.h" #include "thread_map.h" #include "target.h" -static int attach__enable_on_exec(struct perf_evlist *evlist) +static int attach__enable_on_exec(struct evlist *evlist) { - struct perf_evsel *evsel = perf_evlist__last(evlist); + struct evsel *evsel = perf_evlist__last(evlist); struct target target = { .uid = UINT_MAX, }; @@ -36,9 +39,9 @@ static int attach__enable_on_exec(struct perf_evlist *evlist) return err; } - evsel->attr.enable_on_exec = 1; + evsel->core.attr.enable_on_exec = 1; - err = perf_evlist__open(evlist); + err = evlist__open(evlist); if (err < 0) { pr_debug("perf_evlist__open: %s\n", str_error_r(errno, sbuf, sizeof(sbuf))); @@ -48,16 +51,16 @@ static int attach__enable_on_exec(struct perf_evlist *evlist) return perf_evlist__start_workload(evlist) == 1 ? TEST_OK : TEST_FAIL; } -static int detach__enable_on_exec(struct perf_evlist *evlist) +static int detach__enable_on_exec(struct evlist *evlist) { waitpid(evlist->workload.pid, NULL, 0); return 0; } -static int attach__current_disabled(struct perf_evlist *evlist) +static int attach__current_disabled(struct evlist *evlist) { - struct perf_evsel *evsel = perf_evlist__last(evlist); - struct thread_map *threads; + struct evsel *evsel = perf_evlist__last(evlist); + struct perf_thread_map *threads; int err; pr_debug("attaching to current thread as disabled\n"); @@ -68,7 +71,7 @@ static int attach__current_disabled(struct perf_evlist *evlist) return -1; } - evsel->attr.disabled = 1; + evsel->core.attr.disabled = 1; err = perf_evsel__open_per_thread(evsel, threads); if (err) { @@ -76,14 +79,14 @@ static int attach__current_disabled(struct perf_evlist *evlist) return err; } - thread_map__put(threads); - return perf_evsel__enable(evsel) == 0 ? TEST_OK : TEST_FAIL; + perf_thread_map__put(threads); + return evsel__enable(evsel) == 0 ? TEST_OK : TEST_FAIL; } -static int attach__current_enabled(struct perf_evlist *evlist) +static int attach__current_enabled(struct evlist *evlist) { - struct perf_evsel *evsel = perf_evlist__last(evlist); - struct thread_map *threads; + struct evsel *evsel = perf_evlist__last(evlist); + struct perf_thread_map *threads; int err; pr_debug("attaching to current thread as enabled\n"); @@ -96,32 +99,32 @@ static int attach__current_enabled(struct perf_evlist *evlist) err = perf_evsel__open_per_thread(evsel, threads); - thread_map__put(threads); + perf_thread_map__put(threads); return err == 0 ? TEST_OK : TEST_FAIL; } -static int detach__disable(struct perf_evlist *evlist) +static int detach__disable(struct evlist *evlist) { - struct perf_evsel *evsel = perf_evlist__last(evlist); + struct evsel *evsel = perf_evlist__last(evlist); - return perf_evsel__enable(evsel); + return evsel__enable(evsel); } -static int attach__cpu_disabled(struct perf_evlist *evlist) +static int attach__cpu_disabled(struct evlist *evlist) { - struct perf_evsel *evsel = perf_evlist__last(evlist); - struct cpu_map *cpus; + struct evsel *evsel = perf_evlist__last(evlist); + struct perf_cpu_map *cpus; int err; pr_debug("attaching to CPU 0 as enabled\n"); - cpus = cpu_map__new("0"); + cpus = perf_cpu_map__new("0"); if (cpus == NULL) { - pr_debug("failed to call cpu_map__new\n"); + pr_debug("failed to call perf_cpu_map__new\n"); return -1; } - evsel->attr.disabled = 1; + evsel->core.attr.disabled = 1; err = perf_evsel__open_per_cpu(evsel, cpus); if (err) { @@ -132,21 +135,21 @@ static int attach__cpu_disabled(struct perf_evlist *evlist) return err; } - cpu_map__put(cpus); - return perf_evsel__enable(evsel); + perf_cpu_map__put(cpus); + return evsel__enable(evsel); } -static int attach__cpu_enabled(struct perf_evlist *evlist) +static int attach__cpu_enabled(struct evlist *evlist) { - struct perf_evsel *evsel = perf_evlist__last(evlist); - struct cpu_map *cpus; + struct evsel *evsel = perf_evlist__last(evlist); + struct perf_cpu_map *cpus; int err; pr_debug("attaching to CPU 0 as enabled\n"); - cpus = cpu_map__new("0"); + cpus = perf_cpu_map__new("0"); if (cpus == NULL) { - pr_debug("failed to call cpu_map__new\n"); + pr_debug("failed to call perf_cpu_map__new\n"); return -1; } @@ -154,19 +157,19 @@ static int attach__cpu_enabled(struct perf_evlist *evlist) if (err == -EACCES) return TEST_SKIP; - cpu_map__put(cpus); + perf_cpu_map__put(cpus); return err ? TEST_FAIL : TEST_OK; } -static int test_times(int (attach)(struct perf_evlist *), - int (detach)(struct perf_evlist *)) +static int test_times(int (attach)(struct evlist *), + int (detach)(struct evlist *)) { struct perf_counts_values count; - struct perf_evlist *evlist = NULL; - struct perf_evsel *evsel; + struct evlist *evlist = NULL; + struct evsel *evsel; int err = -1, i; - evlist = perf_evlist__new(); + evlist = evlist__new(); if (!evlist) { pr_debug("failed to create event list\n"); goto out_err; @@ -179,7 +182,7 @@ static int test_times(int (attach)(struct perf_evlist *), } evsel = perf_evlist__last(evlist); - evsel->attr.read_format |= + evsel->core.attr.read_format |= PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING; @@ -195,7 +198,7 @@ static int test_times(int (attach)(struct perf_evlist *), TEST_ASSERT_VAL("failed to detach", !detach(evlist)); - perf_evsel__read(evsel, 0, 0, &count); + perf_evsel__read(&evsel->core, 0, 0, &count); err = !(count.ena == count.run); @@ -204,7 +207,7 @@ static int test_times(int (attach)(struct perf_evlist *), count.ena, count.run); out_err: - perf_evlist__delete(evlist); + evlist__delete(evlist); return !err ? TEST_OK : TEST_FAIL; } |