]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rtla/tests: Add unit tests for -A/--aligned option
authorTomas Glozar <tglozar@redhat.com>
Wed, 27 May 2026 14:49:27 +0000 (16:49 +0200)
committerTomas Glozar <tglozar@redhat.com>
Thu, 28 May 2026 11:02:48 +0000 (13:02 +0200)
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>
tools/tracing/rtla/tests/unit/cli_opt_callback.c
tools/tracing/rtla/tests/unit/timerlat_hist_cli.c
tools/tracing/rtla/tests/unit/timerlat_top_cli.c

index 01647f4227d1742541e5f41373e3643a1d1e4e93..4a406af42821b9ee75d0eb930c7afadab484410b 100644 (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");
index 81dc04596cd109274d04897736cc5b2c1fa49244..968bf962f53f074e099edc19d2005263be689189 100644 (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");
index 1c39008564c581d54a608271c1f8e1a645679730..33aa6588d503b95afa5bc8305c00349ee24abfa8 100644 (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");