1 | // SPDX-License-Identifier: GPL-2.0-only |
---|---|
2 | /* |
3 | * Copyright 2022, Athira Rajeev, IBM Corp. |
4 | */ |
5 | |
6 | #include <stdio.h> |
7 | #include "../event.h" |
8 | #include "../sampling_tests/misc.h" |
9 | |
10 | /* The processor's L1 data cache was reloaded */ |
11 | #define EventCode1 0x21C040 |
12 | #define EventCode2 0x22C040 |
13 | |
14 | /* |
15 | * Testcase for group constraint check |
16 | * when using events with same PMC. |
17 | * Multiple events in a group shouldn't |
18 | * ask for same PMC. If so it should fail. |
19 | */ |
20 | |
21 | static int group_constraint_repeat(void) |
22 | { |
23 | struct event event, leader; |
24 | |
25 | /* Check for platform support for the test */ |
26 | SKIP_IF(platform_check_for_tests()); |
27 | |
28 | /* |
29 | * Two events in a group using same PMC |
30 | * should fail to get scheduled. Usei same PMC2 |
31 | * for leader and sibling event which is expected |
32 | * to fail. |
33 | */ |
34 | event_init(e: &leader, EventCode1); |
35 | FAIL_IF(event_open(e: &leader)); |
36 | |
37 | event_init(e: &event, EventCode1); |
38 | |
39 | /* Expected to fail since sibling event is requesting same PMC as leader */ |
40 | FAIL_IF(!event_open_with_group(e: &event, group_fd: leader.fd)); |
41 | |
42 | event_init(e: &event, EventCode2); |
43 | |
44 | /* Expected to pass since sibling event is requesting different PMC */ |
45 | FAIL_IF(event_open_with_group(e: &event, group_fd: leader.fd)); |
46 | |
47 | event_close(e: &leader); |
48 | event_close(e: &event); |
49 | |
50 | return 0; |
51 | } |
52 | |
53 | int main(void) |
54 | { |
55 | return test_harness(group_constraint_repeat, "group_constraint_repeat"); |
56 | } |
57 |