diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2015-10-25 10:51:25 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-12-17 12:38:18 -0500 |
| commit | f77b57ad4fc42a074eae564bbb6660f0a3ff5503 (patch) | |
| tree | 9c33eec565c48c35e34dc95ae53921244611cca6 /tools/perf/tests | |
| parent | 6c872901af07c41745f1abf5ceac9b3b4d9cdbb6 (diff) | |
perf cpu_map: Add cpu_map__new_event function
Introducing the cpu_map__new_event function to create a struct cpu_map
object from a cpu_map event.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1445784728-21732-10-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests')
| -rw-r--r-- | tools/perf/tests/cpumap.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index 715480558088..4cb6418a8ffc 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c | |||
| @@ -6,12 +6,13 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused, | |||
| 6 | struct perf_sample *sample __maybe_unused, | 6 | struct perf_sample *sample __maybe_unused, |
| 7 | struct machine *machine __maybe_unused) | 7 | struct machine *machine __maybe_unused) |
| 8 | { | 8 | { |
| 9 | struct cpu_map_event *map = &event->cpu_map; | 9 | struct cpu_map_event *map_event = &event->cpu_map; |
| 10 | struct cpu_map_mask *mask; | 10 | struct cpu_map_mask *mask; |
| 11 | struct cpu_map_data *data; | 11 | struct cpu_map_data *data; |
| 12 | struct cpu_map *map; | ||
| 12 | int i; | 13 | int i; |
| 13 | 14 | ||
| 14 | data = &map->data; | 15 | data = &map_event->data; |
| 15 | 16 | ||
| 16 | TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__MASK); | 17 | TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__MASK); |
| 17 | 18 | ||
| @@ -23,6 +24,14 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused, | |||
| 23 | TEST_ASSERT_VAL("wrong cpu", test_bit(i, mask->mask)); | 24 | TEST_ASSERT_VAL("wrong cpu", test_bit(i, mask->mask)); |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 27 | map = cpu_map__new_data(data); | ||
| 28 | TEST_ASSERT_VAL("wrong nr", map->nr == 20); | ||
| 29 | |||
| 30 | for (i = 0; i < 20; i++) { | ||
| 31 | TEST_ASSERT_VAL("wrong cpu", map->map[i] == i); | ||
| 32 | } | ||
| 33 | |||
| 34 | cpu_map__put(map); | ||
| 26 | return 0; | 35 | return 0; |
| 27 | } | 36 | } |
| 28 | 37 | ||
| @@ -31,11 +40,12 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused, | |||
| 31 | struct perf_sample *sample __maybe_unused, | 40 | struct perf_sample *sample __maybe_unused, |
| 32 | struct machine *machine __maybe_unused) | 41 | struct machine *machine __maybe_unused) |
| 33 | { | 42 | { |
| 34 | struct cpu_map_event *map = &event->cpu_map; | 43 | struct cpu_map_event *map_event = &event->cpu_map; |
| 35 | struct cpu_map_entries *cpus; | 44 | struct cpu_map_entries *cpus; |
| 36 | struct cpu_map_data *data; | 45 | struct cpu_map_data *data; |
| 46 | struct cpu_map *map; | ||
| 37 | 47 | ||
| 38 | data = &map->data; | 48 | data = &map_event->data; |
| 39 | 49 | ||
| 40 | TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__CPUS); | 50 | TEST_ASSERT_VAL("wrong type", data->type == PERF_CPU_MAP__CPUS); |
| 41 | 51 | ||
| @@ -44,6 +54,13 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused, | |||
| 44 | TEST_ASSERT_VAL("wrong nr", cpus->nr == 2); | 54 | TEST_ASSERT_VAL("wrong nr", cpus->nr == 2); |
| 45 | TEST_ASSERT_VAL("wrong cpu", cpus->cpu[0] == 1); | 55 | TEST_ASSERT_VAL("wrong cpu", cpus->cpu[0] == 1); |
| 46 | TEST_ASSERT_VAL("wrong cpu", cpus->cpu[1] == 256); | 56 | TEST_ASSERT_VAL("wrong cpu", cpus->cpu[1] == 256); |
| 57 | |||
| 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); | ||
| 47 | return 0; | 64 | return 0; |
| 48 | } | 65 | } |
| 49 | 66 | ||
