diff options
| author | Tomas Glozar <tglozar@redhat.com> | 2026-05-27 16:49:27 +0200 |
|---|---|---|
| committer | Tomas Glozar <tglozar@redhat.com> | 2026-05-28 13:02:48 +0200 |
| commit | 5daa3c4fa49474fc8935722b3bbc7181aefe7169 (patch) | |
| tree | eb408a20aa71d1edac8f535168ab2d774eaf09b2 | |
| parent | 03d745b9843560ab89a796d0d9311bed5c6df6d6 (diff) | |
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>
| -rw-r--r-- | tools/tracing/rtla/tests/unit/cli_opt_callback.c | 12 | ||||
| -rw-r--r-- | tools/tracing/rtla/tests/unit/timerlat_hist_cli.c | 20 | ||||
| -rw-r--r-- | tools/tracing/rtla/tests/unit/timerlat_top_cli.c | 20 |
3 files changed, 52 insertions, 0 deletions
diff --git a/tools/tracing/rtla/tests/unit/cli_opt_callback.c b/tools/tracing/rtla/tests/unit/cli_opt_callback.c index 01647f4227d1..4a406af42821 100644 --- a/tools/tracing/rtla/tests/unit/cli_opt_callback.c +++ b/tools/tracing/rtla/tests/unit/cli_opt_callback.c @@ -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(¶ms, 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"); diff --git a/tools/tracing/rtla/tests/unit/timerlat_hist_cli.c b/tools/tracing/rtla/tests/unit/timerlat_hist_cli.c index 81dc04596cd1..968bf962f53f 100644 --- a/tools/tracing/rtla/tests/unit/timerlat_hist_cli.c +++ b/tools/tracing/rtla/tests/unit/timerlat_hist_cli.c @@ -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"); diff --git a/tools/tracing/rtla/tests/unit/timerlat_top_cli.c b/tools/tracing/rtla/tests/unit/timerlat_top_cli.c index 1c39008564c5..33aa6588d503 100644 --- a/tools/tracing/rtla/tests/unit/timerlat_top_cli.c +++ b/tools/tracing/rtla/tests/unit/timerlat_top_cli.c @@ -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"); |
