~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/evsel-tp-sched.c

Version: ~ [ linux-6.2-rc3 ] ~ [ linux-6.1.5 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.87 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.162 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.228 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.269 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.302 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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"
  7 
  8 static int evsel__test_field(struct evsel *evsel, const char *name, int size, bool should_be_signed)
  9 {
 10         struct tep_format_field *field = evsel__field(evsel, name);
 11         int is_signed;
 12         int ret = 0;
 13 
 14         if (field == NULL) {
 15                 pr_debug("%s: \"%s\" field not found!\n", evsel->name, name);
 16                 return -1;
 17         }
 18 
 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;
 24         }
 25 
 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;
 30         }
 31 
 32         return ret;
 33 }
 34 
 35 static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unused,
 36                                            int subtest __maybe_unused)
 37 {
 38         struct evsel *evsel = evsel__newtp("sched", "sched_switch");
 39         int ret = 0;
 40 
 41         if (IS_ERR(evsel)) {
 42                 pr_debug("evsel__newtp failed with %ld\n", PTR_ERR(evsel));
 43                 return -1;
 44         }
 45 
 46         if (evsel__test_field(evsel, "prev_comm", 16, false))
 47                 ret = -1;
 48 
 49         if (evsel__test_field(evsel, "prev_pid", 4, true))
 50                 ret = -1;
 51 
 52         if (evsel__test_field(evsel, "prev_prio", 4, true))
 53                 ret = -1;
 54 
 55         if (evsel__test_field(evsel, "prev_state", sizeof(long), true))
 56                 ret = -1;
 57 
 58         if (evsel__test_field(evsel, "next_comm", 16, false))
 59                 ret = -1;
 60 
 61         if (evsel__test_field(evsel, "next_pid", 4, true))
 62                 ret = -1;
 63 
 64         if (evsel__test_field(evsel, "next_prio", 4, true))
 65                 ret = -1;
 66 
 67         evsel__delete(evsel);
 68 
 69         evsel = evsel__newtp("sched", "sched_wakeup");
 70 
 71         if (IS_ERR(evsel)) {
 72                 pr_debug("evsel__newtp failed with %ld\n", PTR_ERR(evsel));
 73                 return -1;
 74         }
 75 
 76         if (evsel__test_field(evsel, "comm", 16, false))
 77                 ret = -1;
 78 
 79         if (evsel__test_field(evsel, "pid", 4, true))
 80                 ret = -1;
 81 
 82         if (evsel__test_field(evsel, "prio", 4, true))
 83                 ret = -1;
 84 
 85         if (evsel__test_field(evsel, "target_cpu", 4, true))
 86                 ret = -1;
 87 
 88         evsel__delete(evsel);
 89         return ret;
 90 }
 91 
 92 DEFINE_SUITE("Parse sched tracepoints fields", perf_evsel__tp_sched_test);
 93 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp