diff options
Diffstat (limited to 'tools/perf/tests/keep-tracking.c')
-rw-r--r-- | tools/perf/tests/keep-tracking.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c index 17c46f3e6f1e..92c7d591bcac 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c @@ -1,14 +1,19 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/types.h> +#include <limits.h> #include <unistd.h> #include <sys/prctl.h> +#include <perf/cpumap.h> +#include <perf/evlist.h> +#include "debug.h" #include "parse-events.h" #include "evlist.h" #include "evsel.h" +#include "record.h" #include "thread_map.h" -#include "cpumap.h" #include "tests.h" +#include "util/mmap.h" #define CHECK__(x) { \ while ((x) < 0) { \ @@ -24,14 +29,14 @@ } \ } -static int find_comm(struct perf_evlist *evlist, const char *comm) +static int find_comm(struct evlist *evlist, const char *comm) { union perf_event *event; - struct perf_mmap *md; + struct mmap *md; int i, found; found = 0; - for (i = 0; i < evlist->nr_mmaps; i++) { + for (i = 0; i < evlist->core.nr_mmaps; i++) { md = &evlist->mmap[i]; if (perf_mmap__read_init(md) < 0) continue; @@ -65,54 +70,54 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un .uses_mmap = true, }, }; - struct thread_map *threads = NULL; - struct cpu_map *cpus = NULL; - struct perf_evlist *evlist = NULL; - struct perf_evsel *evsel = NULL; + struct perf_thread_map *threads = NULL; + struct perf_cpu_map *cpus = NULL; + struct evlist *evlist = NULL; + struct evsel *evsel = NULL; int found, err = -1; const char *comm; threads = thread_map__new(-1, getpid(), UINT_MAX); CHECK_NOT_NULL__(threads); - cpus = cpu_map__new(NULL); + cpus = perf_cpu_map__new(NULL); CHECK_NOT_NULL__(cpus); - evlist = perf_evlist__new(); + evlist = evlist__new(); CHECK_NOT_NULL__(evlist); - perf_evlist__set_maps(evlist, cpus, threads); + perf_evlist__set_maps(&evlist->core, cpus, threads); CHECK__(parse_events(evlist, "dummy:u", NULL)); CHECK__(parse_events(evlist, "cycles:u", NULL)); perf_evlist__config(evlist, &opts, NULL); - evsel = perf_evlist__first(evlist); + evsel = evlist__first(evlist); - evsel->attr.comm = 1; - evsel->attr.disabled = 1; - evsel->attr.enable_on_exec = 0; + evsel->core.attr.comm = 1; + evsel->core.attr.disabled = 1; + evsel->core.attr.enable_on_exec = 0; - if (perf_evlist__open(evlist) < 0) { + if (evlist__open(evlist) < 0) { pr_debug("Unable to open dummy and cycles event\n"); err = TEST_SKIP; goto out_err; } - CHECK__(perf_evlist__mmap(evlist, UINT_MAX)); + CHECK__(evlist__mmap(evlist, UINT_MAX)); /* * First, test that a 'comm' event can be found when the event is * enabled. */ - perf_evlist__enable(evlist); + evlist__enable(evlist); comm = "Test COMM 1"; CHECK__(prctl(PR_SET_NAME, (unsigned long)comm, 0, 0, 0)); - perf_evlist__disable(evlist); + evlist__disable(evlist); found = find_comm(evlist, comm); if (found != 1) { @@ -125,20 +130,20 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un * disabled with the dummy event still enabled. */ - perf_evlist__enable(evlist); + evlist__enable(evlist); - evsel = perf_evlist__last(evlist); + evsel = evlist__last(evlist); - CHECK__(perf_evsel__disable(evsel)); + CHECK__(evsel__disable(evsel)); comm = "Test COMM 2"; CHECK__(prctl(PR_SET_NAME, (unsigned long)comm, 0, 0, 0)); - perf_evlist__disable(evlist); + evlist__disable(evlist); found = find_comm(evlist, comm); if (found != 1) { - pr_debug("Seconf time, failed to find tracking event.\n"); + pr_debug("Second time, failed to find tracking event.\n"); goto out_err; } @@ -146,11 +151,11 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un out_err: if (evlist) { - perf_evlist__disable(evlist); - perf_evlist__delete(evlist); + evlist__disable(evlist); + evlist__delete(evlist); } else { - cpu_map__put(cpus); - thread_map__put(threads); + perf_cpu_map__put(cpus); + perf_thread_map__put(threads); } return err; |