File Index
Files and directories
Sign in
FILE

group_constraint_pmc_count_test.c

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_pmc_count_test.c C
 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/*
11 * Testcase for number of counters in use.
12 * The number of programmable counters is from
13 * performance monitor counter 1 to performance
14 * monitor counter 4 (PMC1-PMC4). If number of
15 * counters in use exceeds the limit, next event
16 * should fail to schedule.
17 */
18
19static int group_constraint_pmc_count(void)
20{
21	struct event *e, events[5];
22	int i;
23
24	/* Check for platform support for the test */
25	SKIP_IF(platform_check_for_tests());
26
27	/*
28	 * Test for number of counters in use.
29	 * Use PMC1 to PMC4 for leader and 3 sibling
30	 * events. Trying to open fourth event should
31	 * fail here.
32	 */
33	e = &events[0];
34	event_init(e, 0x1001a);
35
36	e = &events[1];
37	event_init(e, 0x200fc);
38
39	e = &events[2];
40	event_init(e, 0x30080);
41
42	e = &events[3];
43	event_init(e, 0x40054);
44
45	e = &events[4];
46	event_init(e, 0x0002c);
47
48	FAIL_IF(event_open(&events[0]));
49
50	/*
51	 * The event_open will fail on event 4 if constraint
52	 * check fails
53	 */
54	for (i = 1; i < 5; i++) {
55		if (i == 4)
56			FAIL_IF(!event_open_with_group(&events[i], events[0].fd));
57		else
58			FAIL_IF(event_open_with_group(&events[i], events[0].fd));
59	}
60
61	for (i = 1; i < 4; i++)
62		event_close(&events[i]);
63
64	return 0;
65}
66
67int main(void)
68{
69	return test_harness(group_constraint_pmc_count, "group_constraint_pmc_count");
70}
~/ Read-only file preview.