hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/perf/tests/topology.c
....@@ -2,11 +2,13 @@
22 #include <string.h>
33 #include <stdlib.h>
44 #include <stdio.h>
5
+#include <perf/cpumap.h>
6
+#include "cpumap.h"
57 #include "tests.h"
6
-#include "util.h"
78 #include "session.h"
89 #include "evlist.h"
910 #include "debug.h"
11
+#include <linux/err.h>
1012
1113 #define TEMPL "/tmp/perf-test-XXXXXX"
1214 #define DATA_SIZE 10
....@@ -31,14 +33,12 @@
3133 {
3234 struct perf_session *session;
3335 struct perf_data data = {
34
- .file = {
35
- .path = path,
36
- },
37
- .mode = PERF_DATA_MODE_WRITE,
36
+ .path = path,
37
+ .mode = PERF_DATA_MODE_WRITE,
3838 };
3939
4040 session = perf_session__new(&data, false, NULL);
41
- TEST_ASSERT_VAL("can't get session", session);
41
+ TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
4242
4343 session->evlist = perf_evlist__new_default();
4444 TEST_ASSERT_VAL("can't get evlist", session->evlist);
....@@ -52,24 +52,23 @@
5252 TEST_ASSERT_VAL("failed to write header",
5353 !perf_session__write_header(session, session->evlist, data.file.fd, true));
5454
55
+ evlist__delete(session->evlist);
5556 perf_session__delete(session);
5657
5758 return 0;
5859 }
5960
60
-static int check_cpu_topology(char *path, struct cpu_map *map)
61
+static int check_cpu_topology(char *path, struct perf_cpu_map *map)
6162 {
6263 struct perf_session *session;
6364 struct perf_data data = {
64
- .file = {
65
- .path = path,
66
- },
67
- .mode = PERF_DATA_MODE_READ,
65
+ .path = path,
66
+ .mode = PERF_DATA_MODE_READ,
6867 };
6968 int i;
7069
7170 session = perf_session__new(&data, false, NULL);
72
- TEST_ASSERT_VAL("can't get session", session);
71
+ TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
7372
7473 /* On platforms with large numbers of CPUs process_cpu_topology()
7574 * might issue an error while reading the perf.data file section
....@@ -116,7 +115,7 @@
116115 int test__session_topology(struct test *test __maybe_unused, int subtest __maybe_unused)
117116 {
118117 char path[PATH_MAX];
119
- struct cpu_map *map;
118
+ struct perf_cpu_map *map;
120119 int ret = TEST_FAIL;
121120
122121 TEST_ASSERT_VAL("can't get templ file", !get_temp(path));
....@@ -126,14 +125,14 @@
126125 if (session_write_header(path))
127126 goto free_path;
128127
129
- map = cpu_map__new(NULL);
128
+ map = perf_cpu_map__new(NULL);
130129 if (map == NULL) {
131130 pr_debug("failed to get system cpumap\n");
132131 goto free_path;
133132 }
134133
135134 ret = check_cpu_topology(path, map);
136
- cpu_map__put(map);
135
+ perf_cpu_map__put(map);
137136
138137 free_path:
139138 unlink(path);