Lines Matching +full:path +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0
14 #define TEMPL "/tmp/perf-test-XXXXXX"
17 static int get_temp(char *path) in get_temp() argument
21 strcpy(path, TEMPL); in get_temp()
23 fd = mkstemp(path); in get_temp()
26 return -1; in get_temp()
33 static int session_write_header(char *path) in session_write_header() argument
37 .path = path, in session_write_header()
44 session->evlist = evlist__new_default(); in session_write_header()
45 TEST_ASSERT_VAL("can't get evlist", session->evlist); in session_write_header()
47 perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY); in session_write_header()
48 perf_header__set_feat(&session->header, HEADER_NRCPUS); in session_write_header()
49 perf_header__set_feat(&session->header, HEADER_ARCH); in session_write_header()
51 session->header.data_size += DATA_SIZE; in session_write_header()
54 !perf_session__write_header(session, session->evlist, data.file.fd, true)); in session_write_header()
56 evlist__delete(session->evlist); in session_write_header()
62 static int check_cpu_topology(char *path, struct perf_cpu_map *map) in check_cpu_topology() argument
66 .path = path, in check_cpu_topology()
97 if (!session->header.env.cpu in check_cpu_topology()
98 && strncmp(session->header.env.arch, "s390", 4) in check_cpu_topology()
99 && strncmp(session->header.env.arch, "aarch64", 7)) in check_cpu_topology()
105 * physical_package_id will be set to -1. Hence skip this in check_cpu_topology()
106 * test if physical_package_id returns -1 for cpu from perf_cpu_map. in check_cpu_topology()
108 if (!strncmp(session->header.env.arch, "ppc64le", 7)) { in check_cpu_topology()
109 if (cpu__get_socket_id(perf_cpu_map__cpu(map, 0)) == -1) in check_cpu_topology()
113 TEST_ASSERT_VAL("Session header CPU map not set", session->header.env.cpu); in check_cpu_topology()
115 for (i = 0; i < session->header.env.nr_cpus_avail; i++) { in check_cpu_topology()
118 if (!perf_cpu_map__has(map, cpu)) in check_cpu_topology()
121 session->header.env.cpu[i].core_id, in check_cpu_topology()
122 session->header.env.cpu[i].socket_id); in check_cpu_topology()
126 for (i = 0; i < perf_cpu_map__nr(map); i++) { in check_cpu_topology()
127 id = aggr_cpu_id__cpu(perf_cpu_map__cpu(map, i), NULL); in check_cpu_topology()
128 TEST_ASSERT_VAL("Cpu map - CPU ID doesn't match", in check_cpu_topology()
129 perf_cpu_map__cpu(map, i).cpu == id.cpu.cpu); in check_cpu_topology()
131 TEST_ASSERT_VAL("Cpu map - Core ID doesn't match", in check_cpu_topology()
132 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].core_id == id.core); in check_cpu_topology()
133 TEST_ASSERT_VAL("Cpu map - Socket ID doesn't match", in check_cpu_topology()
134 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].socket_id == in check_cpu_topology()
137 TEST_ASSERT_VAL("Cpu map - Die ID doesn't match", in check_cpu_topology()
138 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].die_id == id.die); in check_cpu_topology()
139 TEST_ASSERT_VAL("Cpu map - Node ID is set", id.node == -1); in check_cpu_topology()
140 TEST_ASSERT_VAL("Cpu map - Thread IDX is set", id.thread_idx == -1); in check_cpu_topology()
144 for (i = 0; i < perf_cpu_map__nr(map); i++) { in check_cpu_topology()
145 id = aggr_cpu_id__core(perf_cpu_map__cpu(map, i), NULL); in check_cpu_topology()
146 TEST_ASSERT_VAL("Core map - Core ID doesn't match", in check_cpu_topology()
147 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].core_id == id.core); in check_cpu_topology()
149 TEST_ASSERT_VAL("Core map - Socket ID doesn't match", in check_cpu_topology()
150 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].socket_id == in check_cpu_topology()
153 TEST_ASSERT_VAL("Core map - Die ID doesn't match", in check_cpu_topology()
154 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].die_id == id.die); in check_cpu_topology()
155 TEST_ASSERT_VAL("Core map - Node ID is set", id.node == -1); in check_cpu_topology()
156 TEST_ASSERT_VAL("Core map - Thread IDX is set", id.thread_idx == -1); in check_cpu_topology()
160 for (i = 0; i < perf_cpu_map__nr(map); i++) { in check_cpu_topology()
161 id = aggr_cpu_id__die(perf_cpu_map__cpu(map, i), NULL); in check_cpu_topology()
162 TEST_ASSERT_VAL("Die map - Socket ID doesn't match", in check_cpu_topology()
163 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].socket_id == in check_cpu_topology()
166 TEST_ASSERT_VAL("Die map - Die ID doesn't match", in check_cpu_topology()
167 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].die_id == id.die); in check_cpu_topology()
169 TEST_ASSERT_VAL("Die map - Node ID is set", id.node == -1); in check_cpu_topology()
170 TEST_ASSERT_VAL("Die map - Core is set", id.core == -1); in check_cpu_topology()
171 TEST_ASSERT_VAL("Die map - CPU is set", id.cpu.cpu == -1); in check_cpu_topology()
172 TEST_ASSERT_VAL("Die map - Thread IDX is set", id.thread_idx == -1); in check_cpu_topology()
176 for (i = 0; i < perf_cpu_map__nr(map); i++) { in check_cpu_topology()
177 id = aggr_cpu_id__socket(perf_cpu_map__cpu(map, i), NULL); in check_cpu_topology()
178 TEST_ASSERT_VAL("Socket map - Socket ID doesn't match", in check_cpu_topology()
179 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].socket_id == in check_cpu_topology()
182 TEST_ASSERT_VAL("Socket map - Node ID is set", id.node == -1); in check_cpu_topology()
183 TEST_ASSERT_VAL("Socket map - Die ID is set", id.die == -1); in check_cpu_topology()
184 TEST_ASSERT_VAL("Socket map - Core is set", id.core == -1); in check_cpu_topology()
185 TEST_ASSERT_VAL("Socket map - CPU is set", id.cpu.cpu == -1); in check_cpu_topology()
186 TEST_ASSERT_VAL("Socket map - Thread IDX is set", id.thread_idx == -1); in check_cpu_topology()
190 for (i = 0; i < perf_cpu_map__nr(map); i++) { in check_cpu_topology()
191 id = aggr_cpu_id__node(perf_cpu_map__cpu(map, i), NULL); in check_cpu_topology()
192 TEST_ASSERT_VAL("Node map - Node ID doesn't match", in check_cpu_topology()
193 cpu__get_node(perf_cpu_map__cpu(map, i)) == id.node); in check_cpu_topology()
194 TEST_ASSERT_VAL("Node map - Socket is set", id.socket == -1); in check_cpu_topology()
195 TEST_ASSERT_VAL("Node map - Die ID is set", id.die == -1); in check_cpu_topology()
196 TEST_ASSERT_VAL("Node map - Core is set", id.core == -1); in check_cpu_topology()
197 TEST_ASSERT_VAL("Node map - CPU is set", id.cpu.cpu == -1); in check_cpu_topology()
198 TEST_ASSERT_VAL("Node map - Thread IDX is set", id.thread_idx == -1); in check_cpu_topology()
207 char path[PATH_MAX]; in test__session_topology() local
208 struct perf_cpu_map *map; in test__session_topology() local
211 TEST_ASSERT_VAL("can't get templ file", !get_temp(path)); in test__session_topology()
213 pr_debug("templ file: %s\n", path); in test__session_topology()
215 if (session_write_header(path)) in test__session_topology()
218 map = perf_cpu_map__new(NULL); in test__session_topology()
219 if (map == NULL) { in test__session_topology()
224 ret = check_cpu_topology(path, map); in test__session_topology()
225 perf_cpu_map__put(map); in test__session_topology()
228 unlink(path); in test__session_topology()