libsemanage/tests: make "make test" fail when a CUnit test fails
When modifications to libsemanage functions break the test cases tested
with the CUnit framework, "make test" currently succeeds, even though it
prints an output similar to:
Suite: semanage_store
Test: semanage_store_access_check ...passed
Test: semanage_get_lock ...passed
Test: semanage_nc_sort ...passed
Suite: semanage_utilities
Test: semanage_is_prefix ...passed
Test: semanage_split_on_space ...FAILED
1. test_utilities.c:150 - CU_ASSERT_STRING_EQUAL(temp,"baz")
Test: semanage_split ...passed
Test: semanage_list ...passed
Test: semanage_str_count ...passed
Test: semanage_rtrim ...passed
Test: semanage_str_replace ...passed
Test: semanage_findval ...passed
Test: slurp_file_filter ...passed
Like commit 2489b50a91
("libsepol: make "make test" fails when a CUnit
test fails") did for libsepol tests, modify the logic of function
do_tests() to return an error value when there has been at least one
failure. This makes "make test" fail as expected.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
bec41c4ff6
commit
e51b233831
1 changed files with 6 additions and 3 deletions
|
@ -26,6 +26,7 @@
|
|||
#include <CUnit/Console.h>
|
||||
#include <CUnit/TestDB.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -47,9 +48,10 @@ static void usage(char *progname)
|
|||
printf("\t-i, --interactive\t\tinteractive console\n");
|
||||
}
|
||||
|
||||
static int do_tests(int interactive, int verbose)
|
||||
static bool do_tests(int interactive, int verbose)
|
||||
{
|
||||
CU_pSuite suite = NULL;
|
||||
unsigned int num_failures;
|
||||
|
||||
/* Initialize the CUnit test registry. */
|
||||
if (CUE_SUCCESS != CU_initialize_registry())
|
||||
|
@ -67,8 +69,9 @@ static int do_tests(int interactive, int verbose)
|
|||
CU_console_run_tests();
|
||||
else
|
||||
CU_basic_run_tests();
|
||||
num_failures = CU_get_number_of_tests_failed();
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
return CU_get_error() == CUE_SUCCESS && num_failures == 0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -101,7 +104,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (do_tests(interactive, verbose))
|
||||
if (!do_tests(interactive, verbose))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue