Skip to contentSkip to conversation

libtraceevent: Make sure unit test binary fails when tests fail

PATCH In review Paul Mars 2 participants 2 messages Mar 29, 2024 – Apr 12, 2024

lore
Share & tools
lore

Paul Mars

author
#0 lore raw

PATCH 1/1 libtraceevent: Make sure unit test binary fails when tests fail

If tests in the trace-utest binary fails, it returns 0 anyway.

So now make sure failing tests will be easily detected by returning 1.

---
 utest/trace-utest.c | 4 ++++
 1 file changed, 4 insertions(+)
utest/trace-utest.c +4 -0
index a26e42e..a0a45db 100644
@@ -82,6 +82,10 @@ int main(int argc, char **argv)
 
 	CU_basic_set_mode(verbose);
 	CU_basic_run_tests();
+	int failed_tests = CU_get_number_of_tests_failed();
 	CU_cleanup_registry();
+	if (failed_tests != 0){
+		return 1;
+	}
 	return 0;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · On Fri, 29 Mar 2024 14:53:32 +0100 Paul Mars <[email protected]> wrote:

If tests in the trace-utest binary fails, it returns 0 anyway.

So now make sure failing tests will be easily detected by returning 1.

Can you resend with your Signed-off-by?

Thanks,

-- Steve

Quoted 19 lines
---
 utest/trace-utest.c | 4 ++++
 1 file changed, 4 insertions(+)
utest/trace-utest.c +4 -0
index a26e42e..a0a45db 100644
@@ -82,6 +82,10 @@ int main(int argc, char **argv)
 
 	CU_basic_set_mode(verbose);
 	CU_basic_run_tests();
+	int failed_tests = CU_get_number_of_tests_failed();
 	CU_cleanup_registry();
+	if (failed_tests != 0){
+		return 1;
+	}
 	return 0;
 }