I'm not sure if this is what you're looking for, but the CUnit example code does this:
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
I can't remember exactly what CU_get_error() returns right now, but it doesn't return a non-zero value if you've had tests fail. If you want to figure that out, you need to return the number of tests failed:
unsigned int num_failures;
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
num_failures = CU_get_number_of_failures();
CU_cleanup_registry();
return num_failures;
I'm not sure how Hudson/Jenkins deals with this, but the non-zero return value will have CMake/CTest not report passed tests.