aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_pmc56_test.c
blob: f5ee4796d46c433e20aef2c59fd4b329040e3db1 (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
57
58
59
60
61
62
63
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2022, Athira Rajeev, IBM Corp.
 */

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

/*
 * Testcase for checking constraint checks for
 * Performance Monitor Counter 5 (PMC5) and also
 * Performance Monitor Counter 6 (PMC6). Events using
 * PMC5/PMC6 shouldn't have other fields in event
 * code like cache bits, thresholding or marked bit.
 */

static int group_constraint_pmc56(void)
{
	struct event event;

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

	/*
	 * Events using PMC5 and PMC6 with cache bit
	 * set in event code is expected to fail.
	 */
	event_init(&event, 0x2500fa);
	FAIL_IF(!event_open(&event));

	event_init(&event, 0x2600f4);
	FAIL_IF(!event_open(&event));

	/*
	 * PMC5 and PMC6 only supports base events:
	 * ie 500fa and 600f4. Other combinations
	 * should fail.
	 */
	event_init(&event, 0x501e0);
	FAIL_IF(!event_open(&event));

	event_init(&event, 0x6001e);
	FAIL_IF(!event_open(&event));

	event_init(&event, 0x501fa);
	FAIL_IF(!event_open(&event));

	/*
	 * Events using PMC5 and PMC6 with random
	 * sampling bits set in event code should fail
	 * to schedule.
	 */
	event_init(&event, 0x35340500fa);
	FAIL_IF(!event_open(&event));

	return 0;
}

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