accel/amdxdna: Return error when setting clock failed for npu1
[drm/drm-misc.git] / tools / perf / tests / evsel-tp-sched.c
blob226196fb967795a31091187ae59a22577c58c8ca
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/err.h>
3 #include <event-parse.h>
4 #include "evsel.h"
5 #include "tests.h"
6 #include "debug.h"
8 static int evsel__test_field(struct evsel *evsel, const char *name, int size, bool should_be_signed)
10 struct tep_format_field *field = evsel__field(evsel, name);
11 int is_signed;
12 int ret = 0;
14 if (field == NULL) {
15 pr_debug("%s: \"%s\" field not found!\n", evsel->name, name);
16 return -1;
19 is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
20 if (should_be_signed && !is_signed) {
21 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
22 evsel->name, name, is_signed, should_be_signed);
23 ret = -1;
26 if (field->size != size) {
27 pr_debug("%s: \"%s\" size (%d) should be %d!\n",
28 evsel->name, name, field->size, size);
29 ret = -1;
32 return ret;
35 static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unused,
36 int subtest __maybe_unused)
38 struct evsel *evsel = evsel__newtp("sched", "sched_switch");
39 int ret = TEST_OK;
41 if (IS_ERR(evsel)) {
42 pr_debug("evsel__newtp failed with %ld\n", PTR_ERR(evsel));
43 return PTR_ERR(evsel) == -EACCES ? TEST_SKIP : TEST_FAIL;
46 if (evsel__test_field(evsel, "prev_comm", 16, false))
47 ret = TEST_FAIL;
49 if (evsel__test_field(evsel, "prev_pid", 4, true))
50 ret = TEST_FAIL;
52 if (evsel__test_field(evsel, "prev_prio", 4, true))
53 ret = TEST_FAIL;
55 if (evsel__test_field(evsel, "prev_state", sizeof(long), true))
56 ret = TEST_FAIL;
58 if (evsel__test_field(evsel, "next_comm", 16, false))
59 ret = TEST_FAIL;
61 if (evsel__test_field(evsel, "next_pid", 4, true))
62 ret = TEST_FAIL;
64 if (evsel__test_field(evsel, "next_prio", 4, true))
65 ret = TEST_FAIL;
67 evsel__delete(evsel);
69 evsel = evsel__newtp("sched", "sched_wakeup");
71 if (IS_ERR(evsel)) {
72 pr_debug("evsel__newtp failed with %ld\n", PTR_ERR(evsel));
73 return TEST_FAIL;
76 if (evsel__test_field(evsel, "comm", 16, false))
77 ret = TEST_FAIL;
79 if (evsel__test_field(evsel, "pid", 4, true))
80 ret = TEST_FAIL;
82 if (evsel__test_field(evsel, "prio", 4, true))
83 ret = TEST_FAIL;
85 if (evsel__test_field(evsel, "target_cpu", 4, true))
86 ret = TEST_FAIL;
88 evsel__delete(evsel);
89 return ret;
92 static struct test_case tests__perf_evsel__tp_sched_test[] = {
93 TEST_CASE_REASON("Parse sched tracepoints fields",
94 perf_evsel__tp_sched_test,
95 "permissions"),
96 { .name = NULL, }
99 struct test_suite suite__perf_evsel__tp_sched_test = {
100 .desc = "Parse sched tracepoints fields",
101 .test_cases = tests__perf_evsel__tp_sched_test,