Thread (9 messages) flat view 9 messages, 3 authors, 5d ago
COOLING5d

[PATCH 5/5] rtla/tests: Add unit test for get_max_cpu_from_list()

From: Tomas Glozar <tglozar@redhat.com>
Date: 2026-08-14 13:55:56
Also in: lkml
Subsystem: real-time linux analysis (rtla) tools, the rest · Maintainers: Steven Rostedt, Tomas Glozar, Linus Torvalds

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.

Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
 tools/tracing/rtla/tests/unit/utils.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/tools/tracing/rtla/tests/unit/utils.c b/tools/tracing/rtla/tests/unit/utils.c
index 0cb5e217c56eb..cdd84ff895f86 100644
--- a/tools/tracing/rtla/tests/unit/utils.c
+++ b/tools/tracing/rtla/tests/unit/utils.c
@@ -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);
 
-- 
2.55.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help