bcma: claim only 14e4:4365 PCI Dell card with SoftMAC BCM43142
[linux/fpc-iii.git] / tools / perf / tests / cpumap.c
blob4cb6418a8ffc33d6c4b71c66c112420191c68956
1 #include "tests.h"
2 #include "cpumap.h"
4 static int process_event_mask(struct perf_tool *tool __maybe_unused,
5 union perf_event *event,
6 struct perf_sample *sample __maybe_unused,
7 struct machine *machine __maybe_unused)
9 struct cpu_map_event *map_event = &event->cpu_map;
10 struct cpu_map_mask *mask;
11 struct cpu_map_data *data;
12 struct cpu_map *map;
13 int i;
15 data = &map_event->data;
17 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__MASK);
19 mask = (struct cpu_map_mask *)data->data;
21 TEST_ASSERT_VAL("wrong nr", mask->nr == 1);
23 for (i = 0; i < 20; i++) {
24 TEST_ASSERT_VAL("wrong cpu", test_bit(i, mask->mask));
27 map = cpu_map__new_data(data);
28 TEST_ASSERT_VAL("wrong nr", map->nr == 20);
30 for (i = 0; i < 20; i++) {
31 TEST_ASSERT_VAL("wrong cpu", map->map[i] == i);
34 cpu_map__put(map);
35 return 0;
38 static int process_event_cpus(struct perf_tool *tool __maybe_unused,
39 union perf_event *event,
40 struct perf_sample *sample __maybe_unused,
41 struct machine *machine __maybe_unused)
43 struct cpu_map_event *map_event = &event->cpu_map;
44 struct cpu_map_entries *cpus;
45 struct cpu_map_data *data;
46 struct cpu_map *map;
48 data = &map_event->data;
50 TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__CPUS);
52 cpus = (struct cpu_map_entries *)data->data;
54 TEST_ASSERT_VAL("wrong nr", cpus->nr == 2);
55 TEST_ASSERT_VAL("wrong cpu", cpus->cpu[0] == 1);
56 TEST_ASSERT_VAL("wrong cpu", cpus->cpu[1] == 256);
58 map = cpu_map__new_data(data);
59 TEST_ASSERT_VAL("wrong nr", map->nr == 2);
60 TEST_ASSERT_VAL("wrong cpu", map->map[0] == 1);
61 TEST_ASSERT_VAL("wrong cpu", map->map[1] == 256);
62 TEST_ASSERT_VAL("wrong refcnt", atomic_read(&map->refcnt) == 1);
63 cpu_map__put(map);
64 return 0;
68 int test__cpu_map_synthesize(int subtest __maybe_unused)
70 struct cpu_map *cpus;
72 /* This one is better stores in mask. */
73 cpus = cpu_map__new("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19");
75 TEST_ASSERT_VAL("failed to synthesize map",
76 !perf_event__synthesize_cpu_map(NULL, cpus, process_event_mask, NULL));
78 cpu_map__put(cpus);
80 /* This one is better stores in cpu values. */
81 cpus = cpu_map__new("1,256");
83 TEST_ASSERT_VAL("failed to synthesize map",
84 !perf_event__synthesize_cpu_map(NULL, cpus, process_event_cpus, NULL));
86 cpu_map__put(cpus);
87 return 0;