aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/perf/tests/hists_filter.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/tests/hists_filter.c')
-rw-r--r--tools/perf/tests/hists_filter.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index 123e07d35b55..4b2e4f2fbe48 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -8,6 +8,7 @@
#include "util/evlist.h"
#include "util/machine.h"
#include "util/parse-events.h"
+#include "util/thread.h"
#include "tests/tests.h"
#include "tests/hists_common.h"
#include <linux/kernel.h>
@@ -53,6 +54,7 @@ static int add_hist_entries(struct evlist *evlist,
struct perf_sample sample = { .period = 100, };
size_t i;
+ addr_location__init(&al);
/*
* each evsel will have 10 samples but the 4th sample
* (perf [perf] main) will be collapsed to an existing entry
@@ -84,24 +86,34 @@ static int add_hist_entries(struct evlist *evlist,
al.socket = fake_samples[i].socket;
if (hist_entry_iter__add(&iter, &al,
sysctl_perf_event_max_stack, NULL) < 0) {
- addr_location__put(&al);
goto out;
}
- fake_samples[i].thread = al.thread;
- fake_samples[i].map = al.map;
+ thread__put(fake_samples[i].thread);
+ fake_samples[i].thread = thread__get(al.thread);
+ map__put(fake_samples[i].map);
+ fake_samples[i].map = map__get(al.map);
fake_samples[i].sym = al.sym;
}
}
-
+ addr_location__exit(&al);
return 0;
out:
pr_debug("Not enough memory for adding a hist entry\n");
+ addr_location__exit(&al);
return TEST_FAIL;
}
-int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unused)
+static void put_fake_samples(void)
+{
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(fake_samples); i++)
+ map__put(fake_samples[i].map);
+}
+
+static int test__hists_filter(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct machines machines;
@@ -111,10 +123,10 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
TEST_ASSERT_VAL("No memory", evlist);
- err = parse_events(evlist, "cpu-clock", NULL);
+ err = parse_event(evlist, "cpu-clock");
if (err)
goto out;
- err = parse_events(evlist, "task-clock", NULL);
+ err = parse_event(evlist, "task-clock");
if (err)
goto out;
err = TEST_FAIL;
@@ -150,13 +162,13 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
}
TEST_ASSERT_VAL("Invalid nr samples",
- hists->stats.nr_events[PERF_RECORD_SAMPLE] == 10);
+ hists->stats.nr_samples == 10);
TEST_ASSERT_VAL("Invalid nr hist entries",
hists->nr_entries == 9);
TEST_ASSERT_VAL("Invalid total period",
hists->stats.total_period == 1000);
TEST_ASSERT_VAL("Unmatched nr samples",
- hists->stats.nr_events[PERF_RECORD_SAMPLE] ==
+ hists->stats.nr_samples ==
hists->stats.nr_non_filtered_samples);
TEST_ASSERT_VAL("Unmatched nr hist entries",
hists->nr_entries == hists->nr_non_filtered_entries);
@@ -175,7 +187,7 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
/* normal stats should be invariant */
TEST_ASSERT_VAL("Invalid nr samples",
- hists->stats.nr_events[PERF_RECORD_SAMPLE] == 10);
+ hists->stats.nr_samples == 10);
TEST_ASSERT_VAL("Invalid nr hist entries",
hists->nr_entries == 9);
TEST_ASSERT_VAL("Invalid total period",
@@ -194,7 +206,7 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
hists__filter_by_thread(hists);
/* now applying dso filter for 'kernel' */
- hists->dso_filter = fake_samples[0].map->dso;
+ hists->dso_filter = map__dso(fake_samples[0].map);
hists__filter_by_dso(hists);
if (verbose > 2) {
@@ -204,7 +216,7 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
/* normal stats should be invariant */
TEST_ASSERT_VAL("Invalid nr samples",
- hists->stats.nr_events[PERF_RECORD_SAMPLE] == 10);
+ hists->stats.nr_samples == 10);
TEST_ASSERT_VAL("Invalid nr hist entries",
hists->nr_entries == 9);
TEST_ASSERT_VAL("Invalid total period",
@@ -239,7 +251,7 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
/* normal stats should be invariant */
TEST_ASSERT_VAL("Invalid nr samples",
- hists->stats.nr_events[PERF_RECORD_SAMPLE] == 10);
+ hists->stats.nr_samples == 10);
TEST_ASSERT_VAL("Invalid nr hist entries",
hists->nr_entries == 9);
TEST_ASSERT_VAL("Invalid total period",
@@ -268,7 +280,7 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
/* normal stats should be invariant */
TEST_ASSERT_VAL("Invalid nr samples",
- hists->stats.nr_events[PERF_RECORD_SAMPLE] == 10);
+ hists->stats.nr_samples == 10);
TEST_ASSERT_VAL("Invalid nr hist entries",
hists->nr_entries == 9);
TEST_ASSERT_VAL("Invalid total period",
@@ -288,7 +300,7 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
/* now applying all filters at once. */
hists->thread_filter = fake_samples[1].thread;
- hists->dso_filter = fake_samples[1].map->dso;
+ hists->dso_filter = map__dso(fake_samples[1].map);
hists__filter_by_thread(hists);
hists__filter_by_dso(hists);
@@ -299,7 +311,7 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu
/* normal stats should be invariant */
TEST_ASSERT_VAL("Invalid nr samples",
- hists->stats.nr_events[PERF_RECORD_SAMPLE] == 10);
+ hists->stats.nr_samples == 10);
TEST_ASSERT_VAL("Invalid nr hist entries",
hists->nr_entries == 9);
TEST_ASSERT_VAL("Invalid total period",
@@ -322,6 +334,9 @@ out:
evlist__delete(evlist);
reset_output_field();
machines__exit(&machines);
+ put_fake_samples();
return err;
}
+
+DEFINE_SUITE("Filter hist entries", hists_filter);