Lines Matching +full:int +full:- +full:map +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0
6 #include "util/synthetic-events.h"
14 static int process_event_mask(struct perf_tool *tool __maybe_unused, in process_event_mask()
19 struct perf_record_cpu_map *map_event = &event->cpu_map; in process_event_mask()
20 struct perf_record_record_cpu_map *mask; in process_event_mask() local
22 struct perf_cpu_map *map; in process_event_mask() local
23 int i; in process_event_mask()
25 data = &map_event->data; in process_event_mask()
27 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__MASK); in process_event_mask()
29 mask = (struct perf_record_record_cpu_map *)data->data; in process_event_mask()
31 TEST_ASSERT_VAL("wrong nr", mask->nr == 1); in process_event_mask()
34 TEST_ASSERT_VAL("wrong cpu", test_bit(i, mask->mask)); in process_event_mask()
37 map = cpu_map__new_data(data); in process_event_mask()
38 TEST_ASSERT_VAL("wrong nr", map->nr == 20); in process_event_mask()
41 TEST_ASSERT_VAL("wrong cpu", map->map[i] == i); in process_event_mask()
44 perf_cpu_map__put(map); in process_event_mask()
48 static int process_event_cpus(struct perf_tool *tool __maybe_unused, in process_event_cpus()
53 struct perf_record_cpu_map *map_event = &event->cpu_map; in process_event_cpus()
56 struct perf_cpu_map *map; in process_event_cpus() local
58 data = &map_event->data; in process_event_cpus()
60 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__CPUS); in process_event_cpus()
62 cpus = (struct cpu_map_entries *)data->data; in process_event_cpus()
64 TEST_ASSERT_VAL("wrong nr", cpus->nr == 2); in process_event_cpus()
65 TEST_ASSERT_VAL("wrong cpu", cpus->cpu[0] == 1); in process_event_cpus()
66 TEST_ASSERT_VAL("wrong cpu", cpus->cpu[1] == 256); in process_event_cpus()
68 map = cpu_map__new_data(data); in process_event_cpus()
69 TEST_ASSERT_VAL("wrong nr", map->nr == 2); in process_event_cpus()
70 TEST_ASSERT_VAL("wrong cpu", map->map[0] == 1); in process_event_cpus()
71 TEST_ASSERT_VAL("wrong cpu", map->map[1] == 256); in process_event_cpus()
72 TEST_ASSERT_VAL("wrong refcnt", refcount_read(&map->refcnt) == 1); in process_event_cpus()
73 perf_cpu_map__put(map); in process_event_cpus()
78 int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused) in test__cpu_map_synthesize()
82 /* This one is better stores in mask. */ in test__cpu_map_synthesize()
85 TEST_ASSERT_VAL("failed to synthesize map", in test__cpu_map_synthesize()
93 TEST_ASSERT_VAL("failed to synthesize map", in test__cpu_map_synthesize()
100 static int cpu_map_print(const char *str) in cpu_map_print()
102 struct perf_cpu_map *map = perf_cpu_map__new(str); in cpu_map_print() local
105 if (!map) in cpu_map_print()
106 return -1; in cpu_map_print()
108 cpu_map__snprint(map, buf, sizeof(buf)); in cpu_map_print()
112 int test__cpu_map_print(struct test *test __maybe_unused, int subtest __maybe_unused) in test__cpu_map_print()
114 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1")); in test__cpu_map_print()
115 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,5")); in test__cpu_map_print()
116 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()
117 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("2-5")); in test__cpu_map_print()
118 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,3-6,8-10,24,35-37")); in test__cpu_map_print()
119 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,3-6,8-10,24,35-37")); in test__cpu_map_print()
120 TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1-10,12-20,22-30,32-40")); in test__cpu_map_print()
124 int test__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_unused) in test__cpu_map_merge()
131 TEST_ASSERT_VAL("failed to merge map: bad nr", c->nr == 5); in test__cpu_map_merge()
133 TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7")); in test__cpu_map_merge()