| .. | .. |
|---|
| 2 | 2 | #include <string.h> |
|---|
| 3 | 3 | #include <stdlib.h> |
|---|
| 4 | 4 | #include <stdio.h> |
|---|
| 5 | +#include <perf/cpumap.h> |
|---|
| 6 | +#include "cpumap.h" |
|---|
| 5 | 7 | #include "tests.h" |
|---|
| 6 | | -#include "util.h" |
|---|
| 7 | 8 | #include "session.h" |
|---|
| 8 | 9 | #include "evlist.h" |
|---|
| 9 | 10 | #include "debug.h" |
|---|
| 11 | +#include <linux/err.h> |
|---|
| 10 | 12 | |
|---|
| 11 | 13 | #define TEMPL "/tmp/perf-test-XXXXXX" |
|---|
| 12 | 14 | #define DATA_SIZE 10 |
|---|
| .. | .. |
|---|
| 31 | 33 | { |
|---|
| 32 | 34 | struct perf_session *session; |
|---|
| 33 | 35 | 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, |
|---|
| 38 | 38 | }; |
|---|
| 39 | 39 | |
|---|
| 40 | 40 | 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)); |
|---|
| 42 | 42 | |
|---|
| 43 | 43 | session->evlist = perf_evlist__new_default(); |
|---|
| 44 | 44 | TEST_ASSERT_VAL("can't get evlist", session->evlist); |
|---|
| .. | .. |
|---|
| 52 | 52 | TEST_ASSERT_VAL("failed to write header", |
|---|
| 53 | 53 | !perf_session__write_header(session, session->evlist, data.file.fd, true)); |
|---|
| 54 | 54 | |
|---|
| 55 | + evlist__delete(session->evlist); |
|---|
| 55 | 56 | perf_session__delete(session); |
|---|
| 56 | 57 | |
|---|
| 57 | 58 | return 0; |
|---|
| 58 | 59 | } |
|---|
| 59 | 60 | |
|---|
| 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) |
|---|
| 61 | 62 | { |
|---|
| 62 | 63 | struct perf_session *session; |
|---|
| 63 | 64 | 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, |
|---|
| 68 | 67 | }; |
|---|
| 69 | 68 | int i; |
|---|
| 70 | 69 | |
|---|
| 71 | 70 | 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)); |
|---|
| 73 | 72 | |
|---|
| 74 | 73 | /* On platforms with large numbers of CPUs process_cpu_topology() |
|---|
| 75 | 74 | * might issue an error while reading the perf.data file section |
|---|
| .. | .. |
|---|
| 116 | 115 | int test__session_topology(struct test *test __maybe_unused, int subtest __maybe_unused) |
|---|
| 117 | 116 | { |
|---|
| 118 | 117 | char path[PATH_MAX]; |
|---|
| 119 | | - struct cpu_map *map; |
|---|
| 118 | + struct perf_cpu_map *map; |
|---|
| 120 | 119 | int ret = TEST_FAIL; |
|---|
| 121 | 120 | |
|---|
| 122 | 121 | TEST_ASSERT_VAL("can't get templ file", !get_temp(path)); |
|---|
| .. | .. |
|---|
| 126 | 125 | if (session_write_header(path)) |
|---|
| 127 | 126 | goto free_path; |
|---|
| 128 | 127 | |
|---|
| 129 | | - map = cpu_map__new(NULL); |
|---|
| 128 | + map = perf_cpu_map__new(NULL); |
|---|
| 130 | 129 | if (map == NULL) { |
|---|
| 131 | 130 | pr_debug("failed to get system cpumap\n"); |
|---|
| 132 | 131 | goto free_path; |
|---|
| 133 | 132 | } |
|---|
| 134 | 133 | |
|---|
| 135 | 134 | ret = check_cpu_topology(path, map); |
|---|
| 136 | | - cpu_map__put(map); |
|---|
| 135 | + perf_cpu_map__put(map); |
|---|
| 137 | 136 | |
|---|
| 138 | 137 | free_path: |
|---|
| 139 | 138 | unlink(path); |
|---|