diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-11-10 01:46:42 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-11-14 16:49:17 -0300 |
commit | d3b59a38bcdab4248134023c2c5dfabee5a4878e (patch) | |
tree | ea7dad332d4fe0ecbf84ffc06cc9660df32effb8 /tools/perf/tests/util.c | |
parent | 0a4e1ae6808a28a92573550603121b146b11312e (diff) | |
download | linux-d3b59a38bcdab4248134023c2c5dfabee5a4878e.tar.gz linux-d3b59a38bcdab4248134023c2c5dfabee5a4878e.tar.bz2 linux-d3b59a38bcdab4248134023c2c5dfabee5a4878e.zip |
perf tests: Move test__open_syscall_event into separate object
Separating test__open_syscall_event test from the builtin-test into
open-syscall object.
Adding util object under tests directory to gather help functions common
to more tests.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1352508412-16914-3-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/util.c')
-rw-r--r-- | tools/perf/tests/util.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/perf/tests/util.c b/tools/perf/tests/util.c new file mode 100644 index 000000000000..748f2e8f6961 --- /dev/null +++ b/tools/perf/tests/util.c @@ -0,0 +1,30 @@ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include "tests.h" +#include "debugfs.h" + +int trace_event__id(const char *evname) +{ + char *filename; + int err = -1, fd; + + if (asprintf(&filename, + "%s/syscalls/%s/id", + tracing_events_path, evname) < 0) + return -1; + + fd = open(filename, O_RDONLY); + if (fd >= 0) { + char id[16]; + if (read(fd, id, sizeof(id)) > 0) + err = atoi(id); + close(fd); + } + + free(filename); + return err; +} |