Blame libtraceevent-Have-unit-test-fail-when-any-tests-fai.patch

Jerome Marchand 7cf8e2
From 340e2e673f8951f049e9250621e3a4d4e84f10dc Mon Sep 17 00:00:00 2001
Jerome Marchand 7cf8e2
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Jerome Marchand 7cf8e2
Date: Fri, 14 Jun 2024 15:34:21 -0400
Jerome Marchand 7cf8e2
Subject: [PATCH 6/7] libtraceevent: Have unit test fail when any tests fail
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
If any of the tests of the unit test fails, make sure it returns non-zero to
Jerome Marchand 7cf8e2
allow tools that use this know that a test failed.
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
Link: https://lore.kernel.org/linux-trace-devel/20240329135331.784707-1-paul.mars@canonical.com/
Jerome Marchand 7cf8e2
Link: https://lore.kernel.org/linux-trace-devel/20240614153421.2c934dc1@rorschach.local.home
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
Reported-by: Paul Mars <paul.mars@canonical.com>
Jerome Marchand 7cf8e2
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Jerome Marchand 7cf8e2
---
Jerome Marchand 7cf8e2
 utest/trace-utest.c | 4 +++-
Jerome Marchand 7cf8e2
 1 file changed, 3 insertions(+), 1 deletion(-)
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
diff --git a/utest/trace-utest.c b/utest/trace-utest.c
Jerome Marchand 7cf8e2
index a26e42e..7c4b9b6 100644
Jerome Marchand 7cf8e2
--- a/utest/trace-utest.c
Jerome Marchand 7cf8e2
+++ b/utest/trace-utest.c
Jerome Marchand 7cf8e2
@@ -37,6 +37,7 @@ int main(int argc, char **argv)
Jerome Marchand 7cf8e2
 {
Jerome Marchand 7cf8e2
 	CU_BasicRunMode verbose = CU_BRM_VERBOSE;
Jerome Marchand 7cf8e2
 	enum unit_tests tests = RUN_NONE;
Jerome Marchand 7cf8e2
+	int failed_tests;
Jerome Marchand 7cf8e2
 
Jerome Marchand 7cf8e2
 	for (;;) {
Jerome Marchand 7cf8e2
 		int c;
Jerome Marchand 7cf8e2
@@ -82,6 +83,7 @@ int main(int argc, char **argv)
Jerome Marchand 7cf8e2
 
Jerome Marchand 7cf8e2
 	CU_basic_set_mode(verbose);
Jerome Marchand 7cf8e2
 	CU_basic_run_tests();
Jerome Marchand 7cf8e2
+	failed_tests = CU_get_number_of_tests_failed();
Jerome Marchand 7cf8e2
 	CU_cleanup_registry();
Jerome Marchand 7cf8e2
-	return 0;
Jerome Marchand 7cf8e2
+	return failed_tests != 0;
Jerome Marchand 7cf8e2
 }
Jerome Marchand 7cf8e2
-- 
Jerome Marchand 7cf8e2
2.45.2
Jerome Marchand 7cf8e2