Lines Matching +full:cpu +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0
6 #include "util/synthetic-events.h"
19 struct perf_record_cpu_map *map_event = &event->cpu_map; in process_event_mask()
21 struct perf_cpu_map *map; in process_event_mask() local
24 data = &map_event->data; in process_event_mask()
26 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__MASK); in process_event_mask()
28 long_size = data->mask32_data.long_size; in process_event_mask()
32 TEST_ASSERT_VAL("wrong nr", data->mask32_data.nr == 1); in process_event_mask()
34 TEST_ASSERT_VAL("wrong cpu", perf_record_cpu_map_data__test_bit(0, data)); in process_event_mask()
35 TEST_ASSERT_VAL("wrong cpu", !perf_record_cpu_map_data__test_bit(1, data)); in process_event_mask()
37 TEST_ASSERT_VAL("wrong cpu", perf_record_cpu_map_data__test_bit(i, data)); in process_event_mask()
39 map = cpu_map__new_data(data); in process_event_mask()
40 TEST_ASSERT_VAL("wrong nr", perf_cpu_map__nr(map) == 20); in process_event_mask()
42 TEST_ASSERT_VAL("wrong cpu", perf_cpu_map__cpu(map, 0).cpu == 0); in process_event_mask()
44 TEST_ASSERT_VAL("wrong cpu", perf_cpu_map__cpu(map, i - 1).cpu == i); in process_event_mask()
46 perf_cpu_map__put(map); in process_event_mask()
55 struct perf_record_cpu_map *map_event = &event->cpu_map; in process_event_cpus()
57 struct perf_cpu_map *map; in process_event_cpus() local
59 data = &map_event->data; in process_event_cpus()
61 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__CPUS); in process_event_cpus()
63 TEST_ASSERT_VAL("wrong nr", data->cpus_data.nr == 2); in process_event_cpus()
64 TEST_ASSERT_VAL("wrong cpu", data->cpus_data.cpu[0] == 1); in process_event_cpus()
65 TEST_ASSERT_VAL("wrong cpu", data->cpus_data.cpu[1] == 256); in process_event_cpus()
67 map = cpu_map__new_data(data); in process_event_cpus()
68 TEST_ASSERT_VAL("wrong nr", perf_cpu_map__nr(map) == 2); in process_event_cpus()
69 TEST_ASSERT_VAL("wrong cpu", perf_cpu_map__cpu(map, 0).cpu == 1); in process_event_cpus()
70 TEST_ASSERT_VAL("wrong cpu", perf_cpu_map__cpu(map, 1).cpu == 256); in process_event_cpus()
71 TEST_ASSERT_VAL("wrong refcnt", refcount_read(perf_cpu_map__refcnt(map)) == 1); in process_event_cpus()
72 perf_cpu_map__put(map); in process_event_cpus()
81 struct perf_record_cpu_map *map_event = &event->cpu_map; in process_event_range_cpus()
83 struct perf_cpu_map *map; in process_event_range_cpus() local
85 data = &map_event->data; in process_event_range_cpus()
87 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__RANGE_CPUS); in process_event_range_cpus()
89 TEST_ASSERT_VAL("wrong any_cpu", data->range_cpu_data.any_cpu == 0); in process_event_range_cpus()
90 TEST_ASSERT_VAL("wrong start_cpu", data->range_cpu_data.start_cpu == 1); in process_event_range_cpus()
91 TEST_ASSERT_VAL("wrong end_cpu", data->range_cpu_data.end_cpu == 256); in process_event_range_cpus()
93 map = cpu_map__new_data(data); in process_event_range_cpus()
94 TEST_ASSERT_VAL("wrong nr", perf_cpu_map__nr(map) == 256); in process_event_range_cpus()
95 TEST_ASSERT_VAL("wrong cpu", perf_cpu_map__cpu(map, 0).cpu == 1); in process_event_range_cpus()
96 TEST_ASSERT_VAL("wrong cpu", perf_cpu_map__max(map).cpu == 256); in process_event_range_cpus()
97 TEST_ASSERT_VAL("wrong refcnt", refcount_read(perf_cpu_map__refcnt(map)) == 1); in process_event_range_cpus()
98 perf_cpu_map__put(map); in process_event_range_cpus()
108 cpus = perf_cpu_map__new("0,2-20"); in test__cpu_map_synthesize()
110 TEST_ASSERT_VAL("failed to synthesize map", in test__cpu_map_synthesize()
115 /* This one is better stored in cpu values. */ in test__cpu_map_synthesize()
118 TEST_ASSERT_VAL("failed to synthesize map", in test__cpu_map_synthesize()
124 cpus = perf_cpu_map__new("1-256"); in test__cpu_map_synthesize()
126 TEST_ASSERT_VAL("failed to synthesize map", in test__cpu_map_synthesize()
135 struct perf_cpu_map *map = perf_cpu_map__new(str); in cpu_map_print() local
138 if (!map) in cpu_map_print()
139 return -1; in cpu_map_print()
141 cpu_map__snprint(map, buf, sizeof(buf)); in cpu_map_print()
142 perf_cpu_map__put(map); in cpu_map_print()
149 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1")); in test__cpu_map_print()
150 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,5")); in test__cpu_map_print()
151 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,3,5,7,9,11,13,15,17,19,21-40")); in test__cpu_map_print()
152 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("2-5")); in test__cpu_map_print()
153 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,3-6,8-10,24,35-37")); in test__cpu_map_print()
154 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,3-6,8-10,24,35-37")); in test__cpu_map_print()
155 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1-10,12-20,22-30,32-40")); in test__cpu_map_print()
166 TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(a) == nr); in __test__cpu_map_merge()
168 TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, expected)); in __test__cpu_map_merge()
172 * If 'b' is a superset of 'a', 'a' points to the same map with the in __test__cpu_map_merge()
173 * map 'b'. In this case, the owner 'b' has released the resource above in __test__cpu_map_merge()
188 ret = __test__cpu_map_merge("4,2,1", "4,5,7", 5, "1-2,4-5,7"); in test__cpu_map_merge()
191 ret = __test__cpu_map_merge("1-8", "6-9", 9, "1-9"); in test__cpu_map_merge()
194 ret = __test__cpu_map_merge("1-8,12-20", "6-9,15", 18, "1-9,12-20"); in test__cpu_map_merge()
197 ret = __test__cpu_map_merge("4,2,1", "1", 3, "1-2,4"); in test__cpu_map_merge()
200 ret = __test__cpu_map_merge("1", "4,2,1", 3, "1-2,4"); in test__cpu_map_merge()
214 TEST_ASSERT_EQUAL("failed to intersect map: bad nr", perf_cpu_map__nr(c), nr); in __test__cpu_map_intersect()
216 TEST_ASSERT_VAL("failed to intersect map: bad result", !strcmp(buf, expected)); in __test__cpu_map_intersect()
231 ret = __test__cpu_map_intersect("1-8", "6-9", 3, "6-8"); in test__cpu_map_intersect()
234 ret = __test__cpu_map_intersect("1-8,12-20", "6-9,15", 4, "6-8,15"); in test__cpu_map_intersect()
253 struct perf_cpu_map *pair = perf_cpu_map__new("1-2"); in test__cpu_map_equal()
283 TEST_CASE("Synthesize cpu map", cpu_map_synthesize),
284 TEST_CASE("Print cpu map", cpu_map_print),
285 TEST_CASE("Merge cpu map", cpu_map_merge),
286 TEST_CASE("Intersect cpu map", cpu_map_intersect),
287 TEST_CASE("Equal cpu map", cpu_map_equal),
292 .desc = "CPU map",