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