mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 01:22:07 +00:00
ef503831d8
Most uses of the evsel constructor are followed by a call to perf_evlist__add with an idex of evlist->nr_entries, so make rename the current constructor to perf_evsel__new_idx and remove the need for passing the constructor for the common case. We still need the new_idx variant because the way groups are handled, with evsel->nr_members holding the number of entries in an evlist, partitioning the evlist into sublists inside a single linked list. This asks for a clarifying refactoring, but for now simplify the non parser cases, so that tool writers don't have to bother with evsel idx setting. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-zy9tskx6jqm2rmw7468zze2a@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
85 lines
1.9 KiB
C
85 lines
1.9 KiB
C
#include <traceevent/event-parse.h>
|
|
#include "evsel.h"
|
|
#include "tests.h"
|
|
|
|
static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
|
|
int size, bool should_be_signed)
|
|
{
|
|
struct format_field *field = perf_evsel__field(evsel, name);
|
|
int is_signed;
|
|
int ret = 0;
|
|
|
|
if (field == NULL) {
|
|
pr_debug("%s: \"%s\" field not found!\n", evsel->name, name);
|
|
return -1;
|
|
}
|
|
|
|
is_signed = !!(field->flags | FIELD_IS_SIGNED);
|
|
if (should_be_signed && !is_signed) {
|
|
pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
|
|
evsel->name, name, is_signed, should_be_signed);
|
|
ret = -1;
|
|
}
|
|
|
|
if (field->size != size) {
|
|
pr_debug("%s: \"%s\" size (%d) should be %d!\n",
|
|
evsel->name, name, field->size, size);
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int test__perf_evsel__tp_sched_test(void)
|
|
{
|
|
struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch");
|
|
int ret = 0;
|
|
|
|
if (evsel == NULL) {
|
|
pr_debug("perf_evsel__new\n");
|
|
return -1;
|
|
}
|
|
|
|
if (perf_evsel__test_field(evsel, "prev_comm", 16, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "prev_pid", 4, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "prev_prio", 4, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "prev_state", sizeof(long), true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "next_comm", 16, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "next_pid", 4, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "next_prio", 4, true))
|
|
ret = -1;
|
|
|
|
perf_evsel__delete(evsel);
|
|
|
|
evsel = perf_evsel__newtp("sched", "sched_wakeup");
|
|
|
|
if (perf_evsel__test_field(evsel, "comm", 16, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "pid", 4, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "prio", 4, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "success", 4, true))
|
|
ret = -1;
|
|
|
|
if (perf_evsel__test_field(evsel, "target_cpu", 4, true))
|
|
ret = -1;
|
|
|
|
return ret;
|
|
}
|