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 <wander@redhat.com>
Link: https://lore.kernel.org/r/20260629083654.1548925-3-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
This commit is contained in:
Tomas Glozar 2026-06-29 10:36:53 +02:00
parent 082b1c2c22
commit 05f4bcb2e2
4 changed files with 72 additions and 0 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);