rtla/tests: Add unit test for get_max_cpu_from_list()

The get_max_cpu_from_list() function is used when parsing osnoise cpus
"all" value. Furthermore, the callback used by it is also used in
get_possible_cpus().

Add unit test to cover it.

Link: https://lore.kernel.org/r/20260814135511.2207190-6-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
This commit is contained in:
Tomas Glozar 2026-08-14 15:55:11 +02:00
parent a506a3de56
commit 74be338dd7

View File

@ -95,6 +95,14 @@ START_TEST(test_cpu_list_iterate)
}
END_TEST
START_TEST(test_get_max_cpu_from_list)
{
ck_assert_int_eq(get_max_cpu_from_list("1,2,3,4-60"), 60);
ck_assert_int_eq(get_max_cpu_from_list("2,1-7,4"), 7);
ck_assert_int_eq(get_max_cpu_from_list("invalid"), -1);
}
END_TEST
START_TEST(test_parse_cpu_set)
{
cpu_set_t set;
@ -160,6 +168,7 @@ Suite *utils_suite(void)
tcase_add_test(tc, test_strtoi);
tcase_add_test(tc, test_cpu_list_iterate);
tcase_add_test(tc, test_get_max_cpu_from_list);
tcase_add_test(tc, test_parse_cpu_set);
tcase_add_test(tc, test_parse_prio);