hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/tools/perf/tests/event_update.c
....@@ -1,8 +1,14 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <linux/compiler.h>
3
+#include <perf/cpumap.h>
4
+#include <string.h>
5
+#include "cpumap.h"
36 #include "evlist.h"
47 #include "evsel.h"
8
+#include "header.h"
59 #include "machine.h"
10
+#include "util/synthetic-events.h"
11
+#include "tool.h"
612 #include "tests.h"
713 #include "debug.h"
814
....@@ -11,7 +17,7 @@
1117 struct perf_sample *sample __maybe_unused,
1218 struct machine *machine __maybe_unused)
1319 {
14
- struct event_update_event *ev = (struct event_update_event *) event;
20
+ struct perf_record_event_update *ev = (struct perf_record_event_update *)event;
1521
1622 TEST_ASSERT_VAL("wrong id", ev->id == 123);
1723 TEST_ASSERT_VAL("wrong id", ev->type == PERF_EVENT_UPDATE__UNIT);
....@@ -24,10 +30,10 @@
2430 struct perf_sample *sample __maybe_unused,
2531 struct machine *machine __maybe_unused)
2632 {
27
- struct event_update_event *ev = (struct event_update_event *) event;
28
- struct event_update_event_scale *ev_data;
33
+ struct perf_record_event_update *ev = (struct perf_record_event_update *)event;
34
+ struct perf_record_event_update_scale *ev_data;
2935
30
- ev_data = (struct event_update_event_scale *) ev->data;
36
+ ev_data = (struct perf_record_event_update_scale *)ev->data;
3137
3238 TEST_ASSERT_VAL("wrong id", ev->id == 123);
3339 TEST_ASSERT_VAL("wrong id", ev->type == PERF_EVENT_UPDATE__SCALE);
....@@ -46,7 +52,7 @@
4652 struct machine *machine __maybe_unused)
4753 {
4854 struct event_name *tmp = container_of(tool, struct event_name, tool);
49
- struct event_update_event *ev = (struct event_update_event*) event;
55
+ struct perf_record_event_update *ev = (struct perf_record_event_update *)event;
5056
5157 TEST_ASSERT_VAL("wrong id", ev->id == 123);
5258 TEST_ASSERT_VAL("wrong id", ev->type == PERF_EVENT_UPDATE__NAME);
....@@ -59,11 +65,11 @@
5965 struct perf_sample *sample __maybe_unused,
6066 struct machine *machine __maybe_unused)
6167 {
62
- struct event_update_event *ev = (struct event_update_event*) event;
63
- struct event_update_event_cpus *ev_data;
64
- struct cpu_map *map;
68
+ struct perf_record_event_update *ev = (struct perf_record_event_update *)event;
69
+ struct perf_record_event_update_cpus *ev_data;
70
+ struct perf_cpu_map *map;
6571
66
- ev_data = (struct event_update_event_cpus*) ev->data;
72
+ ev_data = (struct perf_record_event_update_cpus *) ev->data;
6773
6874 map = cpu_map__new_data(&ev_data->cpus);
6975
....@@ -73,25 +79,25 @@
7379 TEST_ASSERT_VAL("wrong cpus", map->map[0] == 1);
7480 TEST_ASSERT_VAL("wrong cpus", map->map[1] == 2);
7581 TEST_ASSERT_VAL("wrong cpus", map->map[2] == 3);
76
- cpu_map__put(map);
82
+ perf_cpu_map__put(map);
7783 return 0;
7884 }
7985
8086 int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unused)
8187 {
82
- struct perf_evlist *evlist;
83
- struct perf_evsel *evsel;
88
+ struct evlist *evlist;
89
+ struct evsel *evsel;
8490 struct event_name tmp;
8591
8692 evlist = perf_evlist__new_default();
8793 TEST_ASSERT_VAL("failed to get evlist", evlist);
8894
89
- evsel = perf_evlist__first(evlist);
95
+ evsel = evlist__first(evlist);
9096
91
- TEST_ASSERT_VAL("failed to allos ids",
92
- !perf_evsel__alloc_id(evsel, 1, 1));
97
+ TEST_ASSERT_VAL("failed to allocate ids",
98
+ !perf_evsel__alloc_id(&evsel->core, 1, 1));
9399
94
- perf_evlist__id_add(evlist, evsel, 0, 0, 123);
100
+ perf_evlist__id_add(&evlist->core, &evsel->core, 0, 0, 123);
95101
96102 evsel->unit = strdup("KRAVA");
97103
....@@ -103,16 +109,16 @@
103109 TEST_ASSERT_VAL("failed to synthesize attr update scale",
104110 !perf_event__synthesize_event_update_scale(NULL, evsel, process_event_scale));
105111
106
- tmp.name = perf_evsel__name(evsel);
112
+ tmp.name = evsel__name(evsel);
107113
108114 TEST_ASSERT_VAL("failed to synthesize attr update name",
109115 !perf_event__synthesize_event_update_name(&tmp.tool, evsel, process_event_name));
110116
111
- evsel->own_cpus = cpu_map__new("1,2,3");
117
+ evsel->core.own_cpus = perf_cpu_map__new("1,2,3");
112118
113119 TEST_ASSERT_VAL("failed to synthesize attr update cpus",
114120 !perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus));
115121
116
- cpu_map__put(evsel->own_cpus);
122
+ evlist__delete(evlist);
117123 return 0;
118124 }