Linux Trace Kernel
 help / color / mirror / Atom feed
From: Tomas Glozar <tglozar@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>, Tomas Glozar <tglozar@redhat.com>
Cc: John Kacur <jkacur@redhat.com>,
	Luis Goncalves <lgoncalv@redhat.com>,
	Crystal Wood <crwood@redhat.com>,
	Costa Shulyupin <costa.shul@redhat.com>,
	Wander Lairson Costa <wander@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-trace-kernel <linux-trace-kernel@vger.kernel.org>
Subject: [PATCH 3/4] rtla: Add unit tests for CLI with unset
Date: Mon, 29 Jun 2026 10:36:53 +0200	[thread overview]
Message-ID: <20260629083654.1548925-3-tglozar@redhat.com> (raw)
In-Reply-To: <20260629083654.1548925-1-tglozar@redhat.com>

Test parsing of command line that sets an option and then unsets it back
to the default value in all tools.

Only two CLI tests are added for each tool: short period option (-p ...
--no-period) and long period option (--period ... --no-period). The
logic specific for individual options is tested in opt callback tests
already.

Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
 .../tracing/rtla/tests/unit/osnoise_hist_cli.c | 18 ++++++++++++++++++
 .../tracing/rtla/tests/unit/osnoise_top_cli.c  | 18 ++++++++++++++++++
 .../rtla/tests/unit/timerlat_hist_cli.c        | 18 ++++++++++++++++++
 .../tracing/rtla/tests/unit/timerlat_top_cli.c | 18 ++++++++++++++++++
 4 files changed, 72 insertions(+)

diff --git a/tools/tracing/rtla/tests/unit/osnoise_hist_cli.c b/tools/tracing/rtla/tests/unit/osnoise_hist_cli.c
index 3661529f93dc9..221985e6759f0 100644
--- a/tools/tracing/rtla/tests/unit/osnoise_hist_cli.c
+++ b/tools/tracing/rtla/tests/unit/osnoise_hist_cli.c
@@ -37,6 +37,22 @@ START_TEST(test_period_long)
 }
 END_TEST
 
+START_TEST(test_period_unset_short)
+{
+	PARSE_ARGS("osnoise", "hist", "-p", "100000", "--no-period");
+
+	ck_assert_int_eq(osn_params->period, 0);
+}
+END_TEST
+
+START_TEST(test_period_unset_long)
+{
+	PARSE_ARGS("osnoise", "hist", "--period", "100000", "--no-period");
+
+	ck_assert_int_eq(osn_params->period, 0);
+}
+END_TEST
+
 START_TEST(test_runtime_short)
 {
 	PARSE_ARGS("osnoise", "hist", "-r", "95000");
@@ -481,6 +497,8 @@ Suite *osnoise_hist_cli_suite(void)
 	tc = tcase_create("tracing_options");
 	tcase_add_test(tc, test_period_short);
 	tcase_add_test(tc, test_period_long);
+	tcase_add_test(tc, test_period_unset_short);
+	tcase_add_test(tc, test_period_unset_long);
 	tcase_add_test(tc, test_runtime_short);
 	tcase_add_test(tc, test_runtime_long);
 	tcase_add_test(tc, test_stop_short);
diff --git a/tools/tracing/rtla/tests/unit/osnoise_top_cli.c b/tools/tracing/rtla/tests/unit/osnoise_top_cli.c
index f3a8633cc84e8..057dbe574b079 100644
--- a/tools/tracing/rtla/tests/unit/osnoise_top_cli.c
+++ b/tools/tracing/rtla/tests/unit/osnoise_top_cli.c
@@ -37,6 +37,22 @@ START_TEST(test_period_long)
 }
 END_TEST
 
+START_TEST(test_period_unset_short)
+{
+	PARSE_ARGS("osnoise", "top", "-p", "100000", "--no-period");
+
+	ck_assert_int_eq(osn_params->period, 0);
+}
+END_TEST
+
+START_TEST(test_period_unset_long)
+{
+	PARSE_ARGS("osnoise", "top", "--period", "100000", "--no-period");
+
+	ck_assert_int_eq(osn_params->period, 0);
+}
+END_TEST
+
 START_TEST(test_runtime_short)
 {
 	PARSE_ARGS("osnoise", "top", "-r", "95000");
@@ -433,6 +449,8 @@ Suite *osnoise_top_cli_suite(void)
 	tc = tcase_create("tracing_options");
 	tcase_add_test(tc, test_period_short);
 	tcase_add_test(tc, test_period_long);
+	tcase_add_test(tc, test_period_unset_short);
+	tcase_add_test(tc, test_period_unset_long);
 	tcase_add_test(tc, test_runtime_short);
 	tcase_add_test(tc, test_runtime_long);
 	tcase_add_test(tc, test_stop_short);
diff --git a/tools/tracing/rtla/tests/unit/timerlat_hist_cli.c b/tools/tracing/rtla/tests/unit/timerlat_hist_cli.c
index 968bf962f53f0..d8dd9d752636e 100644
--- a/tools/tracing/rtla/tests/unit/timerlat_hist_cli.c
+++ b/tools/tracing/rtla/tests/unit/timerlat_hist_cli.c
@@ -55,6 +55,22 @@ START_TEST(test_period_long)
 }
 END_TEST
 
+START_TEST(test_period_unset_short)
+{
+	PARSE_ARGS("timerlat", "hist", "-p", "200", "--no-period");
+
+	ck_assert_int_eq(tlat_params->timerlat_period_us, 0);
+}
+END_TEST
+
+START_TEST(test_period_unset_long)
+{
+	PARSE_ARGS("timerlat", "hist", "--period", "200", "--no-period");
+
+	ck_assert_int_eq(tlat_params->timerlat_period_us, 0);
+}
+END_TEST
+
 START_TEST(test_stack_short)
 {
 	PARSE_ARGS("timerlat", "hist", "-s", "20");
@@ -629,6 +645,8 @@ Suite *timerlat_hist_cli_suite(void)
 	tcase_add_test(tc, test_irq_long);
 	tcase_add_test(tc, test_period_short);
 	tcase_add_test(tc, test_period_long);
+	tcase_add_test(tc, test_period_unset_short);
+	tcase_add_test(tc, test_period_unset_long);
 	tcase_add_test(tc, test_stack_short);
 	tcase_add_test(tc, test_stack_long);
 	tcase_add_test(tc, test_thread_short);
diff --git a/tools/tracing/rtla/tests/unit/timerlat_top_cli.c b/tools/tracing/rtla/tests/unit/timerlat_top_cli.c
index 33aa6588d503b..e9fb1a86ab8c4 100644
--- a/tools/tracing/rtla/tests/unit/timerlat_top_cli.c
+++ b/tools/tracing/rtla/tests/unit/timerlat_top_cli.c
@@ -55,6 +55,22 @@ START_TEST(test_period_long)
 }
 END_TEST
 
+START_TEST(test_period_unset_short)
+{
+	PARSE_ARGS("timerlat", "top", "-p", "200", "--no-period");
+
+	ck_assert_int_eq(tlat_params->timerlat_period_us, 0);
+}
+END_TEST
+
+START_TEST(test_period_unset_long)
+{
+	PARSE_ARGS("timerlat", "top", "--period", "200", "--no-period");
+
+	ck_assert_int_eq(tlat_params->timerlat_period_us, 0);
+}
+END_TEST
+
 START_TEST(test_stack_short)
 {
 	PARSE_ARGS("timerlat", "top", "-s", "20");
@@ -571,6 +587,8 @@ Suite *timerlat_top_cli_suite(void)
 	tcase_add_test(tc, test_irq_long);
 	tcase_add_test(tc, test_period_short);
 	tcase_add_test(tc, test_period_long);
+	tcase_add_test(tc, test_period_unset_short);
+	tcase_add_test(tc, test_period_unset_long);
 	tcase_add_test(tc, test_stack_short);
 	tcase_add_test(tc, test_stack_long);
 	tcase_add_test(tc, test_thread_short);
-- 
2.54.0


  parent reply	other threads:[~2026-06-29  8:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  8:36 [PATCH 1/4] rtla: Allow unsetting non-list custom-callback CLI options Tomas Glozar
2026-06-29  8:36 ` [PATCH 2/4] rtla: Add unit tests for unset in opt callbacks Tomas Glozar
2026-06-29  8:36 ` Tomas Glozar [this message]
2026-06-29  8:36 ` [PATCH 4/4] Documentation/rtla: Document unsetting options Tomas Glozar

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=20260629083654.1548925-3-tglozar@redhat.com \
    --to=tglozar@redhat.com \
    --cc=costa.shul@redhat.com \
    --cc=crwood@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=wander@redhat.com \
    /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