From 05f4bcb2e2d9859de5d6bd2f35f909de9f8ee12f Mon Sep 17 00:00:00 2001 From: Tomas Glozar Date: Mon, 29 Jun 2026 10:36:53 +0200 Subject: [PATCH] rtla: Add unit tests for CLI with unset 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. Reviewed-by: Wander Lairson Costa Link: https://lore.kernel.org/r/20260629083654.1548925-3-tglozar@redhat.com Signed-off-by: Tomas Glozar --- .../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 3661529f93dc..221985e6759f 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 f3a8633cc84e..057dbe574b07 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 968bf962f53f..d8dd9d752636 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 33aa6588d503..e9fb1a86ab8c 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);