All of lore.kernel.org
 help / color / mirror / Atom feed
From: sunliming <sunliming@kylinos.cn>
To: mhiramat@kernel.org, beaub@linux.microsoft.com,
	rostedt@goodmis.org, shuah@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com,
	sunliming <sunliming@kylinos.cn>
Subject: [PATCH v3 3/4] selftests/user_events: Clear the events after perf self-test
Date: Tue,  6 Jun 2023 14:20:26 +0800	[thread overview]
Message-ID: <20230606062027.1008398-4-sunliming@kylinos.cn> (raw)
In-Reply-To: <20230606062027.1008398-1-sunliming@kylinos.cn>

When the self test is completed, perf self-test left the user events not to
be cleared. Clear the events by unregister and delete the event.

Signed-off-by: sunliming <sunliming@kylinos.cn>
---
 .../testing/selftests/user_events/perf_test.c | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tools/testing/selftests/user_events/perf_test.c b/tools/testing/selftests/user_events/perf_test.c
index a070258d4449..e97f24ab6e2f 100644
--- a/tools/testing/selftests/user_events/perf_test.c
+++ b/tools/testing/selftests/user_events/perf_test.c
@@ -81,6 +81,32 @@ static int get_offset(void)
 	return offset;
 }
 
+static int clear(int *check)
+{
+	struct user_unreg unreg = {0};
+
+	unreg.size = sizeof(unreg);
+	unreg.disable_bit = 31;
+	unreg.disable_addr = (__u64)check;
+
+	int fd = open(data_file, O_RDWR);
+
+	if (fd == -1)
+		return -1;
+
+	if (ioctl(fd, DIAG_IOCSUNREG, &unreg) == -1)
+		if (errno != ENOENT)
+			return -1;
+
+	if (ioctl(fd, DIAG_IOCSDEL, "__test_event") == -1)
+		if (errno != ENOENT)
+			return -1;
+
+	close(fd);
+
+	return 0;
+}
+
 FIXTURE(user) {
 	int data_fd;
 	int check;
@@ -93,6 +119,9 @@ FIXTURE_SETUP(user) {
 
 FIXTURE_TEARDOWN(user) {
 	close(self->data_fd);
+
+	if (clear(&self->check) != 0)
+		printf("WARNING: Clear didn't work!\n");
 }
 
 TEST_F(user, perf_write) {
-- 
2.25.1


  parent reply	other threads:[~2023-06-06  6:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06  6:20 [PATCH v3 0/4] tracing/user_events: Add empty arguments events sunliming
2023-06-06  6:20 ` [PATCH v3 1/4] tracing/user_events: Fix the incorrect trace record for " sunliming
2023-06-06  6:20 ` [PATCH v3 2/4] selftests/user_events: Add ftrace self-test " sunliming
2023-06-06  6:20 ` sunliming [this message]
2023-06-06  6:20 ` [PATCH v3 4/4] selftests/user_events: Add perf " sunliming
2023-06-06 18:53 ` [PATCH v3 0/4] tracing/user_events: Add " Beau Belgrave
2023-06-07 14:10 ` Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230606062027.1008398-4-sunliming@kylinos.cn \
    --to=sunliming@kylinos.cn \
    --cc=beaub@linux.microsoft.com \
    --cc=kelulanainsley@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.