linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH v5 2/3] trace-cmd: Unit tests for new libtracefs APIs
Date: Tue, 14 Apr 2020 18:56:03 +0300	[thread overview]
Message-ID: <20200414155604.31401-3-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20200414155604.31401-1-tz.stoyanov@gmail.com>

Unit tests for tracefs APIs, checking for ftrace file / directory existence:
  bool tracefs_file_exist(struct tracefs_instance *instance, char *name);
  bool tracefs_dir_exist(struct tracefs_instance *instance, char *name);

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 utest/tracefs-utest.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 2473e893..3f57ecad 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -175,6 +175,7 @@ static void test_instance_file_read(struct tracefs_instance *inst, char *fname)
 
 #define ALL_TRACERS	"available_tracers"
 #define CUR_TRACER	"current_tracer"
+#define PER_CPU		"per_cpu"
 static void test_instance_file(void)
 {
 	struct tracefs_instance *instance = NULL;
@@ -251,6 +252,21 @@ static void test_instance_file(void)
 	tracefs_put_tracing_file(inst_file);
 	free(fname);
 
+	CU_TEST(tracefs_file_exist(NULL, (char *)name) == false);
+	CU_TEST(tracefs_dir_exist(NULL, (char *)name) == false);
+	CU_TEST(tracefs_file_exist(instance, (char *)name) == false);
+	CU_TEST(tracefs_dir_exist(instance, (char *)name) == false);
+
+	CU_TEST(tracefs_file_exist(NULL, CUR_TRACER) == true);
+	CU_TEST(tracefs_dir_exist(NULL, CUR_TRACER) == false);
+	CU_TEST(tracefs_file_exist(instance, CUR_TRACER) == true);
+	CU_TEST(tracefs_dir_exist(instance, CUR_TRACER) == false);
+
+	CU_TEST(tracefs_file_exist(NULL, PER_CPU) == false);
+	CU_TEST(tracefs_dir_exist(NULL, PER_CPU) == true);
+	CU_TEST(tracefs_file_exist(instance, PER_CPU) == false);
+	CU_TEST(tracefs_dir_exist(instance, PER_CPU) == true);
+
 	CU_TEST(tracefs_instance_destroy(NULL) != 0);
 	CU_TEST(tracefs_instance_destroy(instance) == 0);
 	CU_TEST(tracefs_instance_destroy(instance) != 0);
-- 
2.25.1


  parent reply	other threads:[~2020-04-14 15:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 15:56 [PATCH v5 0/3] Extend coverage of "trace-cmd reset" command Tzvetomir Stoyanov (VMware)
2020-04-14 15:56 ` [PATCH v5 1/3] trace-cmd: Add new tracefs APIs for checking if a ftrace file / directory exists Tzvetomir Stoyanov (VMware)
2020-04-14 15:56 ` Tzvetomir Stoyanov (VMware) [this message]
2020-04-14 15:56 ` [PATCH v5 3/3] trace-cmd: Clear error log on reset subcommand Tzvetomir Stoyanov (VMware)

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=20200414155604.31401-3-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).