1 #include <linux/types.h>
12 static int process_event(struct perf_evlist
**pevlist
, union perf_event
*event
)
14 struct perf_sample sample
;
16 if (event
->header
.type
== PERF_RECORD_HEADER_ATTR
) {
17 if (perf_event__process_attr(NULL
, event
, pevlist
)) {
18 pr_debug("perf_event__process_attr failed\n");
24 if (event
->header
.type
>= PERF_RECORD_USER_TYPE_START
)
30 if (perf_evlist__parse_sample(*pevlist
, event
, &sample
)) {
31 pr_debug("perf_evlist__parse_sample failed\n");
38 static int process_events(union perf_event
**events
, size_t count
)
40 struct perf_evlist
*evlist
= NULL
;
44 for (i
= 0; i
< count
&& !err
; i
++)
45 err
= process_event(&evlist
, events
[i
]);
48 perf_evlist__delete(evlist
);
53 struct test_attr_event
{
54 struct attr_event attr
;
59 * test__parse_no_sample_id_all - test parsing with no sample_id_all bit set.
61 * This function tests parsing data produced on kernel's that do not support the
62 * sample_id_all bit. Without the sample_id_all bit, non-sample events (such as
63 * mmap events) do not have an id sample appended, and consequently logic
64 * designed to determine the id will not work. That case happens when there is
65 * more than one selected event, so this test processes three events: 2
66 * attributes representing the selected events and one mmap event.
68 * Return: %0 on success, %-1 if the test fails.
70 int test__parse_no_sample_id_all(void)
74 struct test_attr_event event1
= {
77 .type
= PERF_RECORD_HEADER_ATTR
,
78 .size
= sizeof(struct test_attr_event
),
83 struct test_attr_event event2
= {
86 .type
= PERF_RECORD_HEADER_ATTR
,
87 .size
= sizeof(struct test_attr_event
),
92 struct mmap_event event3
= {
94 .type
= PERF_RECORD_MMAP
,
95 .size
= sizeof(struct mmap_event
),
98 union perf_event
*events
[] = {
99 (union perf_event
*)&event1
,
100 (union perf_event
*)&event2
,
101 (union perf_event
*)&event3
,
104 err
= process_events(events
, ARRAY_SIZE(events
));