[tip:perf/core] perf test: Add test for counting open syscalls

Previous thread: [tip:perf/core] perf evsel: Auto allocate resources needed for some methods by tip-bot for Arnaldo Carvalho de Melo on Tuesday, January 4, 2011 - 1:25 am. (1 message)

Next thread: [PATCH] rcu: call __rcu_read_unlock() in exit_rcu() by Lai Jiangshan on Tuesday, January 4, 2011 - 1:32 am. (1 message)
From: tip-bot for Arnaldo Carvalho de Melo
Date: Tuesday, January 4, 2011 - 1:26 am

Commit-ID:  d854861c4292a4e675a5d3bfd862c5f7421c81e8
Gitweb:     http://git.kernel.org/tip/d854861c4292a4e675a5d3bfd862c5f7421c81e8
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Tue, 4 Jan 2011 00:16:20 -0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 4 Jan 2011 00:32:06 -0200

perf test: Add test for counting open syscalls

To test the use of the perf_evsel class on something other than
the tools from where we refactored code to create it.

It calls open() N times and then checks if the event created to
monitor it returns N events.

[acme@felicio linux]$ perf test
 1: vmlinux symtab matches kallsyms: Ok
 2: detect open syscall event: Ok
[acme@felicio linux]$

It does.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Han Pingtian <phan@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-test.c |   83 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index e0c3f47..6c99152 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -234,6 +234,85 @@ out:
 	return err;
 }
 
+#include "util/evsel.h"
+#include <sys/types.h>
+
+static int trace_event__id(const char *event_name)
+{
+	char *filename;
+	int err = -1, fd;
+
+	if (asprintf(&filename,
+		     "/sys/kernel/debug/tracing/events/syscalls/%s/id",
+		     event_name) < 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;
+}
+
+static int test__open_syscall_event(void)
+{
+	int ...
Previous thread: [tip:perf/core] perf evsel: Auto allocate resources needed for some methods by tip-bot for Arnaldo Carvalho de Melo on Tuesday, January 4, 2011 - 1:25 am. (1 message)

Next thread: [PATCH] rcu: call __rcu_read_unlock() in exit_rcu() by Lai Jiangshan on Tuesday, January 4, 2011 - 1:32 am. (1 message)