rtla/tests: Add unit tests for -A/--aligned option

Add both parse_args() and opt_* tests for the newly added -A/--aligned
option.

Assisted-by: Claude:claude-4.5-opus-high-thinking
Link: https://lore.kernel.org/r/20260527144928.2944472-2-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
This commit is contained in:
Tomas Glozar
2026-05-27 16:49:27 +02:00
parent 03d745b984
commit 5daa3c4fa4
3 changed files with 52 additions and 0 deletions

View File

@@ -545,6 +545,17 @@ START_TEST(test_opt_nano_cb)
}
END_TEST
START_TEST(test_opt_timerlat_align_cb)
{
struct timerlat_params params = {0};
const struct option opt = TEST_CALLBACK(&params, opt_timerlat_align_cb);
ck_assert_int_eq(opt_timerlat_align_cb(&opt, "500", 0), 0);
ck_assert(params.timerlat_align);
ck_assert_int_eq(params.timerlat_align_us, 500);
}
END_TEST
START_TEST(test_opt_stack_format_cb)
{
int stack_format = 0;
@@ -689,6 +700,7 @@ Suite *cli_opt_callback_suite(void)
tcase_add_test(tc, test_opt_nano_cb);
tcase_add_test(tc, test_opt_stack_format_cb);
tcase_add_exit_test(tc, test_opt_stack_format_cb_invalid, EXIT_FAILURE);
tcase_add_test(tc, test_opt_timerlat_align_cb);
suite_add_tcase(s, tc);
tc = tcase_create("histogram");

View File

@@ -373,6 +373,24 @@ START_TEST(test_user_threads_long)
}
END_TEST
START_TEST(test_aligned_short)
{
PARSE_ARGS("timerlat", "hist", "-A", "500");
ck_assert(tlat_params->timerlat_align);
ck_assert_int_eq(tlat_params->timerlat_align_us, 500);
}
END_TEST
START_TEST(test_aligned_long)
{
PARSE_ARGS("timerlat", "hist", "--aligned", "500");
ck_assert(tlat_params->timerlat_align);
ck_assert_int_eq(tlat_params->timerlat_align_us, 500);
}
END_TEST
/* Histogram Options */
START_TEST(test_bucket_size_short)
@@ -654,6 +672,8 @@ Suite *timerlat_hist_cli_suite(void)
tcase_add_test(tc, test_user_load_long);
tcase_add_test(tc, test_user_threads_short);
tcase_add_test(tc, test_user_threads_long);
tcase_add_test(tc, test_aligned_short);
tcase_add_test(tc, test_aligned_long);
suite_add_tcase(s, tc);
tc = tcase_create("histogram_options");

View File

@@ -373,6 +373,24 @@ START_TEST(test_user_threads_long)
}
END_TEST
START_TEST(test_aligned_short)
{
PARSE_ARGS("timerlat", "top", "-A", "500");
ck_assert(tlat_params->timerlat_align);
ck_assert_int_eq(tlat_params->timerlat_align_us, 500);
}
END_TEST
START_TEST(test_aligned_long)
{
PARSE_ARGS("timerlat", "top", "--aligned", "500");
ck_assert(tlat_params->timerlat_align);
ck_assert_int_eq(tlat_params->timerlat_align_us, 500);
}
END_TEST
/* Output */
START_TEST(test_nano_short)
@@ -596,6 +614,8 @@ Suite *timerlat_top_cli_suite(void)
tcase_add_test(tc, test_user_load_long);
tcase_add_test(tc, test_user_threads_short);
tcase_add_test(tc, test_user_threads_long);
tcase_add_test(tc, test_aligned_short);
tcase_add_test(tc, test_aligned_long);
suite_add_tcase(s, tc);
tc = tcase_create("output");