Merge tag 'ntb-5.11' of git://github.com/jonmason/ntb
[linux/fpc-iii.git] / tools / perf / tests / evsel-tp-sched.c
blobf9e34bd26cf33536388265330400cddce0c87eef
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/err.h>
3 #include <traceevent/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 int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtest __maybe_unused)
37 struct evsel *evsel = evsel__newtp("sched", "sched_switch");
38 int ret = 0;
40 if (IS_ERR(evsel)) {
41 pr_debug("evsel__newtp failed with %ld\n", PTR_ERR(evsel));
42 return -1;
45 if (evsel__test_field(evsel, "prev_comm", 16, false))
46 ret = -1;
48 if (evsel__test_field(evsel, "prev_pid", 4, true))
49 ret = -1;
51 if (evsel__test_field(evsel, "prev_prio", 4, true))
52 ret = -1;
54 if (evsel__test_field(evsel, "prev_state", sizeof(long), true))
55 ret = -1;
57 if (evsel__test_field(evsel, "next_comm", 16, false))
58 ret = -1;
60 if (evsel__test_field(evsel, "next_pid", 4, true))
61 ret = -1;
63 if (evsel__test_field(evsel, "next_prio", 4, true))
64 ret = -1;
66 evsel__delete(evsel);
68 evsel = evsel__newtp("sched", "sched_wakeup");
70 if (IS_ERR(evsel)) {
71 pr_debug("evsel__newtp failed with %ld\n", PTR_ERR(evsel));
72 return -1;
75 if (evsel__test_field(evsel, "comm", 16, false))
76 ret = -1;
78 if (evsel__test_field(evsel, "pid", 4, true))
79 ret = -1;
81 if (evsel__test_field(evsel, "prio", 4, true))
82 ret = -1;
84 if (evsel__test_field(evsel, "target_cpu", 4, true))
85 ret = -1;
87 evsel__delete(evsel);
88 return ret;