2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
13 * Test various attributes of the EBB event are enforced.
15 int event_attributes(void)
17 struct event event
, leader
;
19 SKIP_IF(!ebb_is_supported());
21 event_init(&event
, 0x1001e);
22 event_leader_ebb_init(&event
);
23 /* Expected to succeed */
24 FAIL_IF(event_open(&event
));
28 event_init(&event
, 0x001e); /* CYCLES - no PMC specified */
29 event_leader_ebb_init(&event
);
30 /* Expected to fail, no PMC specified */
31 FAIL_IF(event_open(&event
) == 0);
34 event_init(&event
, 0x2001e);
35 event_leader_ebb_init(&event
);
36 event
.attr
.exclusive
= 0;
37 /* Expected to fail, not exclusive */
38 FAIL_IF(event_open(&event
) == 0);
41 event_init(&event
, 0x3001e);
42 event_leader_ebb_init(&event
);
44 /* Expected to fail, sets freq */
45 FAIL_IF(event_open(&event
) == 0);
48 event_init(&event
, 0x4001e);
49 event_leader_ebb_init(&event
);
50 event
.attr
.sample_period
= 1;
51 /* Expected to fail, sets sample_period */
52 FAIL_IF(event_open(&event
) == 0);
55 event_init(&event
, 0x1001e);
56 event_leader_ebb_init(&event
);
57 event
.attr
.enable_on_exec
= 1;
58 /* Expected to fail, sets enable_on_exec */
59 FAIL_IF(event_open(&event
) == 0);
62 event_init(&event
, 0x1001e);
63 event_leader_ebb_init(&event
);
64 event
.attr
.inherit
= 1;
65 /* Expected to fail, sets inherit */
66 FAIL_IF(event_open(&event
) == 0);
69 event_init(&leader
, 0x1001e);
70 event_leader_ebb_init(&leader
);
71 FAIL_IF(event_open(&leader
));
73 event_init(&event
, 0x20002);
74 event_ebb_init(&event
);
76 /* Expected to succeed */
77 FAIL_IF(event_open_with_group(&event
, leader
.fd
));
82 event_init(&leader
, 0x1001e);
83 event_leader_ebb_init(&leader
);
84 FAIL_IF(event_open(&leader
));
86 event_init(&event
, 0x20002);
88 /* Expected to fail, event doesn't request EBB, leader does */
89 FAIL_IF(event_open_with_group(&event
, leader
.fd
) == 0);
93 event_init(&leader
, 0x1001e);
94 event_leader_ebb_init(&leader
);
95 /* Clear the EBB flag */
96 leader
.attr
.config
&= ~(1ull << 63);
98 FAIL_IF(event_open(&leader
));
100 event_init(&event
, 0x20002);
101 event_ebb_init(&event
);
103 /* Expected to fail, leader doesn't request EBB */
104 FAIL_IF(event_open_with_group(&event
, leader
.fd
) == 0);
105 event_close(&leader
);
108 event_init(&leader
, 0x1001e);
109 event_leader_ebb_init(&leader
);
110 leader
.attr
.exclusive
= 0;
111 /* Expected to fail, leader isn't exclusive */
112 FAIL_IF(event_open(&leader
) == 0);
115 event_init(&leader
, 0x1001e);
116 event_leader_ebb_init(&leader
);
117 leader
.attr
.pinned
= 0;
118 /* Expected to fail, leader isn't pinned */
119 FAIL_IF(event_open(&leader
) == 0);
121 event_init(&event
, 0x1001e);
122 event_leader_ebb_init(&event
);
123 /* Expected to fail, not a task event */
124 SKIP_IF(require_paranoia_below(1));
125 FAIL_IF(event_open_with_cpu(&event
, 0) == 0);
132 return test_harness(event_attributes
, "event_attributes");