aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_repeat_test.c
blob: 371cd05bb3ed75a9a64d83e0360ab6d42d46f9fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2022, Athira Rajeev, IBM Corp.
 */

#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"

/* The processor's L1 data cache was reloaded */
#define EventCode1 0x21C040
#define EventCode2 0x22C040

/*
 * Testcase for group constraint check
 * when using events with same PMC.
 * Multiple events in a group shouldn't
 * ask for same PMC. If so it should fail.
 */

static int group_constraint_repeat(void)
{
	struct event event, leader;

	/* Check for platform support for the test */
	SKIP_IF(platform_check_for_tests());

	/*
	 * Two events in a group using same PMC
	 * should fail to get scheduled. Usei same PMC2
	 * for leader and sibling event which is expected
	 * to fail.
	 */
	event_init(&leader, EventCode1);
	FAIL_IF(event_open(&leader));

	event_init(&event, EventCode1);

	/* Expected to fail since sibling event is requesting same PMC as leader */
	FAIL_IF(!event_open_with_group(&event, leader.fd));

	event_init(&event, EventCode2);

	/* Expected to pass since sibling event is requesting different PMC */
	FAIL_IF(event_open_with_group(&event, leader.fd));

	event_close(&leader);
	event_close(&event);

	return 0;
}

int main(void)
{
	return test_harness(group_constraint_repeat, "group_constraint_repeat");
}