.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
---|
2 | 2 | #include <stdlib.h> |
---|
| 3 | +#include <string.h> |
---|
3 | 4 | #include <sys/types.h> |
---|
4 | 5 | #include <unistd.h> |
---|
5 | 6 | #include <sys/prctl.h> |
---|
6 | 7 | #include "tests.h" |
---|
7 | 8 | #include "thread_map.h" |
---|
8 | 9 | #include "debug.h" |
---|
| 10 | +#include "event.h" |
---|
| 11 | +#include "util/synthetic-events.h" |
---|
| 12 | +#include <linux/zalloc.h> |
---|
| 13 | +#include <perf/event.h> |
---|
| 14 | + |
---|
| 15 | +struct perf_sample; |
---|
| 16 | +struct perf_tool; |
---|
| 17 | +struct machine; |
---|
9 | 18 | |
---|
10 | 19 | #define NAME (const char *) "perf" |
---|
11 | 20 | #define NAMEUL (unsigned long) NAME |
---|
12 | 21 | |
---|
13 | 22 | int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unused) |
---|
14 | 23 | { |
---|
15 | | - struct thread_map *map; |
---|
| 24 | + struct perf_thread_map *map; |
---|
16 | 25 | |
---|
17 | 26 | TEST_ASSERT_VAL("failed to set process name", |
---|
18 | 27 | !prctl(PR_SET_NAME, NAMEUL, 0, 0, 0)); |
---|
.. | .. |
---|
25 | 34 | |
---|
26 | 35 | TEST_ASSERT_VAL("wrong nr", map->nr == 1); |
---|
27 | 36 | TEST_ASSERT_VAL("wrong pid", |
---|
28 | | - thread_map__pid(map, 0) == getpid()); |
---|
| 37 | + perf_thread_map__pid(map, 0) == getpid()); |
---|
29 | 38 | TEST_ASSERT_VAL("wrong comm", |
---|
30 | | - thread_map__comm(map, 0) && |
---|
31 | | - !strcmp(thread_map__comm(map, 0), NAME)); |
---|
| 39 | + perf_thread_map__comm(map, 0) && |
---|
| 40 | + !strcmp(perf_thread_map__comm(map, 0), NAME)); |
---|
32 | 41 | TEST_ASSERT_VAL("wrong refcnt", |
---|
33 | 42 | refcount_read(&map->refcnt) == 1); |
---|
34 | | - thread_map__put(map); |
---|
| 43 | + perf_thread_map__put(map); |
---|
35 | 44 | |
---|
36 | 45 | /* test dummy pid */ |
---|
37 | | - map = thread_map__new_dummy(); |
---|
| 46 | + map = perf_thread_map__new_dummy(); |
---|
38 | 47 | TEST_ASSERT_VAL("failed to alloc map", map); |
---|
39 | 48 | |
---|
40 | 49 | thread_map__read_comms(map); |
---|
41 | 50 | |
---|
42 | 51 | TEST_ASSERT_VAL("wrong nr", map->nr == 1); |
---|
43 | | - TEST_ASSERT_VAL("wrong pid", thread_map__pid(map, 0) == -1); |
---|
| 52 | + TEST_ASSERT_VAL("wrong pid", perf_thread_map__pid(map, 0) == -1); |
---|
44 | 53 | TEST_ASSERT_VAL("wrong comm", |
---|
45 | | - thread_map__comm(map, 0) && |
---|
46 | | - !strcmp(thread_map__comm(map, 0), "dummy")); |
---|
| 54 | + perf_thread_map__comm(map, 0) && |
---|
| 55 | + !strcmp(perf_thread_map__comm(map, 0), "dummy")); |
---|
47 | 56 | TEST_ASSERT_VAL("wrong refcnt", |
---|
48 | 57 | refcount_read(&map->refcnt) == 1); |
---|
49 | | - thread_map__put(map); |
---|
| 58 | + perf_thread_map__put(map); |
---|
50 | 59 | return 0; |
---|
51 | 60 | } |
---|
52 | 61 | |
---|
.. | .. |
---|
55 | 64 | struct perf_sample *sample __maybe_unused, |
---|
56 | 65 | struct machine *machine __maybe_unused) |
---|
57 | 66 | { |
---|
58 | | - struct thread_map_event *map = &event->thread_map; |
---|
59 | | - struct thread_map *threads; |
---|
| 67 | + struct perf_record_thread_map *map = &event->thread_map; |
---|
| 68 | + struct perf_thread_map *threads; |
---|
60 | 69 | |
---|
61 | 70 | TEST_ASSERT_VAL("wrong nr", map->nr == 1); |
---|
62 | 71 | TEST_ASSERT_VAL("wrong pid", map->entries[0].pid == (u64) getpid()); |
---|
.. | .. |
---|
67 | 76 | |
---|
68 | 77 | TEST_ASSERT_VAL("wrong nr", threads->nr == 1); |
---|
69 | 78 | TEST_ASSERT_VAL("wrong pid", |
---|
70 | | - thread_map__pid(threads, 0) == getpid()); |
---|
| 79 | + perf_thread_map__pid(threads, 0) == getpid()); |
---|
71 | 80 | TEST_ASSERT_VAL("wrong comm", |
---|
72 | | - thread_map__comm(threads, 0) && |
---|
73 | | - !strcmp(thread_map__comm(threads, 0), NAME)); |
---|
| 81 | + perf_thread_map__comm(threads, 0) && |
---|
| 82 | + !strcmp(perf_thread_map__comm(threads, 0), NAME)); |
---|
74 | 83 | TEST_ASSERT_VAL("wrong refcnt", |
---|
75 | 84 | refcount_read(&threads->refcnt) == 1); |
---|
76 | | - thread_map__put(threads); |
---|
| 85 | + perf_thread_map__put(threads); |
---|
77 | 86 | return 0; |
---|
78 | 87 | } |
---|
79 | 88 | |
---|
80 | 89 | int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused) |
---|
81 | 90 | { |
---|
82 | | - struct thread_map *threads; |
---|
| 91 | + struct perf_thread_map *threads; |
---|
83 | 92 | |
---|
84 | 93 | TEST_ASSERT_VAL("failed to set process name", |
---|
85 | 94 | !prctl(PR_SET_NAME, NAMEUL, 0, 0, 0)); |
---|
.. | .. |
---|
98 | 107 | |
---|
99 | 108 | int test__thread_map_remove(struct test *test __maybe_unused, int subtest __maybe_unused) |
---|
100 | 109 | { |
---|
101 | | - struct thread_map *threads; |
---|
| 110 | + struct perf_thread_map *threads; |
---|
102 | 111 | char *str; |
---|
103 | 112 | int i; |
---|
104 | 113 | |
---|
.. | .. |
---|
133 | 142 | thread_map__remove(threads, 0)); |
---|
134 | 143 | |
---|
135 | 144 | for (i = 0; i < threads->nr; i++) |
---|
136 | | - free(threads->map[i].comm); |
---|
| 145 | + zfree(&threads->map[i].comm); |
---|
137 | 146 | |
---|
138 | 147 | free(threads); |
---|
139 | 148 | return 0; |
---|