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

Tomas Glozar <[email protected]>
Newsgroups org.kernel.vger.linux-trace-kernel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.