[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-02266a2d9cf7e04bf3d4b4457654839dc253f605@git.kernel.org>
Date: Tue, 30 Jul 2019 12:06:16 -0700
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
mpetlan@...hat.com, linux-kernel@...r.kernel.org,
peterz@...radead.org, hpa@...or.com, mingo@...nel.org,
acme@...hat.com, tglx@...utronix.de, ak@...ux.intel.com,
namhyung@...nel.org, alexey.budankov@...ux.intel.com
Subject: [tip:perf/core] libperf: Add perf_evsel__enable/disable test
Commit-ID: 02266a2d9cf7e04bf3d4b4457654839dc253f605
Gitweb: https://git.kernel.org/tip/02266a2d9cf7e04bf3d4b4457654839dc253f605
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Sun, 21 Jul 2019 13:25:05 +0200
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 29 Jul 2019 18:34:47 -0300
libperf: Add perf_evsel__enable/disable test
Add simple perf_evsel enable/disable test together with evsel counter
reading interface.
Committer testing:
# make -C tools/perf/lib tests
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK test-cpumap-a
LINK test-threadmap-a
LINK test-evlist-a
LINK test-evsel-a
LINK test-cpumap-so
LINK test-threadmap-so
LINK test-evlist-so
LINK test-evsel-so
running static:
- running test-cpumap.c...OK
- running test-threadmap.c...OK
- running test-evlist.c...OK
- running test-evsel.c...OK
running dynamic:
- running test-cpumap.c...OK
- running test-threadmap.c...OK
- running test-evlist.c...OK
- running test-evsel.c...OK
make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
#
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Alexey Budankov <alexey.budankov@...ux.intel.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Michael Petlan <mpetlan@...hat.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-79-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/lib/tests/test-evsel.c | 43 +++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/tools/perf/lib/tests/test-evsel.c b/tools/perf/lib/tests/test-evsel.c
index 268712292f60..2c648fe5617e 100644
--- a/tools/perf/lib/tests/test-evsel.c
+++ b/tools/perf/lib/tests/test-evsel.c
@@ -70,12 +70,55 @@ static int test_stat_thread(void)
return 0;
}
+static int test_stat_thread_enable(void)
+{
+ struct perf_counts_values counts = { .val = 0 };
+ struct perf_thread_map *threads;
+ struct perf_evsel *evsel;
+ struct perf_event_attr attr = {
+ .type = PERF_TYPE_SOFTWARE,
+ .config = PERF_COUNT_SW_TASK_CLOCK,
+ .disabled = 1,
+ };
+ int err;
+
+ threads = perf_thread_map__new_dummy();
+ __T("failed to create threads", threads);
+
+ perf_thread_map__set_pid(threads, 0, 0);
+
+ evsel = perf_evsel__new(&attr);
+ __T("failed to create evsel", evsel);
+
+ err = perf_evsel__open(evsel, NULL, threads);
+ __T("failed to open evsel", err == 0);
+
+ perf_evsel__read(evsel, 0, 0, &counts);
+ __T("failed to read value for evsel", counts.val == 0);
+
+ err = perf_evsel__enable(evsel);
+ __T("failed to enable evsel", err == 0);
+
+ perf_evsel__read(evsel, 0, 0, &counts);
+ __T("failed to read value for evsel", counts.val != 0);
+
+ err = perf_evsel__disable(evsel);
+ __T("failed to enable evsel", err == 0);
+
+ perf_evsel__close(evsel);
+ perf_evsel__delete(evsel);
+
+ perf_thread_map__put(threads);
+ return 0;
+}
+
int main(int argc, char **argv)
{
__T_START;
test_stat_cpu();
test_stat_thread();
+ test_stat_thread_enable();
__T_OK;
return 0;
Powered by blists - more mailing lists