2015-09-07 11:38:06 +03:00
|
|
|
#include <linux/err.h>
|
2013-06-11 19:29:18 +04:00
|
|
|
#include <traceevent/event-parse.h>
|
2012-11-10 04:46:48 +04:00
|
|
|
#include "evsel.h"
|
|
|
|
#include "tests.h"
|
2014-07-15 01:46:48 +04:00
|
|
|
#include "debug.h"
|
2012-11-10 04:46:48 +04:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
perf tests: Pass the subtest index to each test routine
Some tests have sub-tests we want to run, so allow passing this.
Wang tried to avoid having to touch all tests, but then, having the
test.func in an anonymous union makes the build fail on older compilers,
like the one in RHEL6, where:
test a = {
.func = foo,
};
fails.
To fix it leave the func pointer in the main structure and pass the subtest
index to all tests, end result function is the same, but we have just one
function pointer, not two, with and without the subtest index as an argument.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-5genj0ficwdmelpoqlds0u4y@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-19 18:01:48 +03:00
|
|
|
int test__perf_evsel__tp_sched_test(int subtest __maybe_unused)
|
2012-11-10 04:46:48 +04:00
|
|
|
{
|
2013-11-07 23:41:19 +04:00
|
|
|
struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch");
|
2012-11-10 04:46:48 +04:00
|
|
|
int ret = 0;
|
|
|
|
|
2015-09-07 11:38:06 +03:00
|
|
|
if (IS_ERR(evsel)) {
|
|
|
|
pr_debug("perf_evsel__newtp failed with %ld\n", PTR_ERR(evsel));
|
2012-11-10 04:46:48 +04:00
|
|
|
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;
|
|
|
|
|
2013-07-12 18:29:06 +04:00
|
|
|
if (perf_evsel__test_field(evsel, "prev_state", sizeof(long), true))
|
2012-11-10 04:46:48 +04:00
|
|
|
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);
|
|
|
|
|
2013-11-07 23:41:19 +04:00
|
|
|
evsel = perf_evsel__newtp("sched", "sched_wakeup");
|
2012-11-10 04:46:48 +04:00
|
|
|
|
2015-09-07 11:38:06 +03:00
|
|
|
if (IS_ERR(evsel)) {
|
|
|
|
pr_debug("perf_evsel__newtp failed with %ld\n", PTR_ERR(evsel));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-11-10 04:46:48 +04:00
|
|
|
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, "target_cpu", 4, true))
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|