summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-09-07 09:40:46 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-09-07 09:40:46 +0200
commit47627bcdb3b2464b6580618638d1c5d2b9aa5543 (patch)
tree55a2ec18f9316a5669fe5a43f32f936e7d6934d3
parentab3ec0da8c55a68bcd8b7dda9c0a475e93cb4ffb (diff)
downloadcmocka-47627bcdb3b2464b6580618638d1c5d2b9aa5543.tar.gz
cmocka-47627bcdb3b2464b6580618638d1c5d2b9aa5543.tar.bz2
cmocka-47627bcdb3b2464b6580618638d1c5d2b9aa5543.zip
src: Filter out invalid tests.
-rw-r--r--src/cmocka.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/cmocka.c b/src/cmocka.c
index fc83b57..9790449 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -2493,6 +2493,7 @@ int _cmocka_run_group_tests(const char *group_name,
struct CMUnitTestState *cm_tests;
const ListNode *group_check_point = check_point_allocated_blocks();
void *group_state = NULL;
+ size_t total_tests = 0;
size_t total_failed = 0;
size_t total_passed = 0;
size_t total_executed = 0;
@@ -2510,17 +2511,23 @@ int _cmocka_run_group_tests(const char *group_name,
return -1;
}
- cmprintf_group_start(num_tests);
-
/* Setup cmocka test array */
for (i = 0; i < num_tests; i++) {
- cm_tests[i] = (struct CMUnitTestState) {
- .test = &tests[i],
- .status = CM_TEST_NOT_STARTED,
- .state = NULL,
- };
+ if (tests[i].name != NULL &&
+ (tests[i].test_func != NULL
+ || tests[i].setup_func != NULL
+ || tests[i].teardown_func != NULL)) {
+ cm_tests[i] = (struct CMUnitTestState) {
+ .test = &tests[i],
+ .status = CM_TEST_NOT_STARTED,
+ .state = NULL,
+ };
+ total_tests++;
+ }
}
+ cmprintf_group_start(total_tests);
+
rc = 0;
/* Run group setup */
@@ -2534,7 +2541,7 @@ int _cmocka_run_group_tests(const char *group_name,
if (rc == 0) {
/* Execute tests */
- for (i = 0; i < num_tests; i++) {
+ for (i = 0; i < total_tests; i++) {
struct CMUnitTestState *cmtest = &cm_tests[i];
size_t test_number = i + 1;
@@ -2609,7 +2616,7 @@ int _cmocka_run_group_tests(const char *group_name,
total_runtime,
cm_tests);
- for (i = 0; i < num_tests; i++) {
+ for (i = 0; i < total_tests; i++) {
vcm_free_error(discard_const_p(char, cm_tests[i].error_message));
}
libc_free(cm_tests);