From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 6/6] libtracefs: Unit tests for enable / disable tracing APIs
Date: Thu, 7 Jan 2021 10:32:50 +0200 [thread overview]
Message-ID: <20210107083250.16295-7-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20210107083250.16295-1-tz.stoyanov@gmail.com>
New unit tests for these APIs:
tracefs_trace_is_on();
tracefs_trace_on();
tracefs_trace_off();
tracefs_trace_on_fd();
tracefs_trace_off_fd();
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
utest/tracefs-utest.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index a51d6fc..2a80cf7 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -412,6 +412,42 @@ static void test_instance_file_fd(void)
close(fd);
}
+static void test_tracing_onoff(void)
+{
+ long long res = -1;
+ int fd;
+
+ fd = tracefs_instance_file_open(test_instance, TRACE_ON, O_WRONLY);
+ CU_TEST(fd >= 0);
+ CU_TEST(tracefs_instance_file_read_int(test_instance, TRACE_ON, &res) == 0);
+ if (res == 1) {
+ CU_TEST(tracefs_trace_is_on(test_instance) == 1);
+ CU_TEST(tracefs_trace_off(test_instance) == 0);
+ CU_TEST(tracefs_trace_is_on(test_instance) == 0);
+ CU_TEST(tracefs_trace_on(test_instance) == 0);
+ CU_TEST(tracefs_trace_is_on(test_instance) == 1);
+
+ CU_TEST(tracefs_trace_off_fd(fd) == 0);
+ CU_TEST(tracefs_trace_is_on(test_instance) == 0);
+ CU_TEST(tracefs_trace_on_fd(fd) == 0);
+ CU_TEST(tracefs_trace_is_on(test_instance) == 1);
+ } else {
+ CU_TEST(tracefs_trace_is_on(test_instance) == 0);
+ CU_TEST(tracefs_trace_on(test_instance) == 0);
+ CU_TEST(tracefs_trace_is_on(test_instance) == 1);
+ CU_TEST(tracefs_trace_off(test_instance) == 0);
+ CU_TEST(tracefs_trace_is_on(test_instance) == 0);
+
+ CU_TEST(tracefs_trace_on_fd(fd) == 0);
+ CU_TEST(tracefs_trace_is_on(test_instance) == 1);
+ CU_TEST(tracefs_trace_off_fd(fd) == 0);
+ CU_TEST(tracefs_trace_is_on(test_instance) == 0);
+ }
+
+ if (fd >= 0)
+ close(fd);
+}
+
static void exclude_string(char **strings, char *name)
{
int i;
@@ -719,4 +755,7 @@ void test_tracefs_lib(void)
test_instances_walk);
CU_add_test(suite, "tracefs_get_clock API",
test_get_clock);
+ CU_add_test(suite, "tracing on / off",
+ test_tracing_onoff);
+
}
--
2.29.2
prev parent reply other threads:[~2021-01-07 8:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-07 8:32 [PATCH 0/6] New libtracefs APIs Tzvetomir Stoyanov (VMware)
2021-01-07 8:32 ` [PATCH 1/6] libtracefs: New APIs for opening and reading ftrace files Tzvetomir Stoyanov (VMware)
2021-01-07 15:58 ` Steven Rostedt
2021-01-07 8:32 ` [PATCH 2/6] libtracefs: New APIs for enable / disable tracing Tzvetomir Stoyanov (VMware)
2021-01-07 16:12 ` Steven Rostedt
2021-01-07 8:32 ` [PATCH 3/6] libtracefs: Documentation for the new APIs for opening and reading ftrace files Tzvetomir Stoyanov (VMware)
2021-01-07 8:32 ` [PATCH 4/6] libtracefs: Documentation for enable / disable tracing APIs Tzvetomir Stoyanov (VMware)
2021-01-07 16:37 ` Steven Rostedt
2021-01-07 8:32 ` [PATCH 5/6] libtracefs: Unit tests for the new APIs for opening and reading ftrace files Tzvetomir Stoyanov (VMware)
2021-01-07 8:32 ` Tzvetomir Stoyanov (VMware) [this message]
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=20210107083250.16295-7-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).