summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Gelas <arnaud.gelas@sensefly.com>2019-12-09 14:07:23 +0100
committerAndreas Schneider <asn@cryptomilk.org>2020-02-06 08:41:55 +0100
commit946c15126942c7ff5da92fd20bd82765828a505b (patch)
tree5d5d23f334c9ad36a09e8af6c91b6a31676be85e
parent1cc9cde3448cdd2e000886a26acf1caac2db7cf1 (diff)
downloadcmocka-946c15126942c7ff5da92fd20bd82765828a505b.tar.gz
cmocka-946c15126942c7ff5da92fd20bd82765828a505b.tar.xz
cmocka-946c15126942c7ff5da92fd20bd82765828a505b.zip
Add group_name in cmprintf_group_finish_standard.
When using cmocka_run_group_tests_name, group_name was not printed; which made it complicated to know when one failure occurs.
-rw-r--r--src/cmocka.c39
-rw-r--r--tests/CMakeLists.txt6
2 files changed, 28 insertions, 17 deletions
diff --git a/src/cmocka.c b/src/cmocka.c
index 6a31f77..6783b5d 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -2529,7 +2529,8 @@ static void cmprintf_group_start_standard(const size_t num_tests)
(unsigned)num_tests);
}
-static void cmprintf_group_finish_standard(size_t total_executed,
+static void cmprintf_group_finish_standard(const char *group_name,
+ size_t total_executed,
size_t total_passed,
size_t total_failed,
size_t total_errors,
@@ -2538,12 +2539,16 @@ static void cmprintf_group_finish_standard(size_t total_executed,
{
size_t i;
- print_message("[==========] %u test(s) run.\n", (unsigned)total_executed);
+ print_message("[==========] %s: %zu test(s) run.\n",
+ group_name,
+ total_executed);
print_error("[ PASSED ] %u test(s).\n",
(unsigned)(total_passed));
if (total_skipped) {
- print_error("[ SKIPPED ] %"PRIdS " test(s), listed below:\n", total_skipped);
+ print_error("[ SKIPPED ] %s: %zu test(s), listed below:\n",
+ group_name,
+ total_skipped);
for (i = 0; i < total_executed; i++) {
struct CMUnitTestState *cmtest = &cm_tests[i];
@@ -2551,11 +2556,13 @@ static void cmprintf_group_finish_standard(size_t total_executed,
print_error("[ SKIPPED ] %s\n", cmtest->test->name);
}
}
- print_error("\n %u SKIPPED TEST(S)\n", (unsigned)(total_skipped));
+ print_error("\n %zu SKIPPED TEST(S)\n", total_skipped);
}
if (total_failed) {
- print_error("[ FAILED ] %"PRIdS " test(s), listed below:\n", total_failed);
+ print_error("[ FAILED ] %s: %zu test(s), listed below:\n",
+ group_name,
+ total_failed);
for (i = 0; i < total_executed; i++) {
struct CMUnitTestState *cmtest = &cm_tests[i];
@@ -2563,8 +2570,8 @@ static void cmprintf_group_finish_standard(size_t total_executed,
print_error("[ FAILED ] %s\n", cmtest->test->name);
}
}
- print_error("\n %u FAILED TEST(S)\n",
- (unsigned)(total_failed + total_errors));
+ print_error("\n %zu FAILED TEST(S)\n",
+ (total_failed + total_errors));
}
}
@@ -2726,17 +2733,21 @@ static void cmprintf_group_finish(const char *group_name,
switch (output) {
case CM_OUTPUT_STDOUT:
- cmprintf_group_finish_standard(total_executed,
- total_passed,
- total_failed,
- total_errors,
- total_skipped,
- cm_tests);
+ cmprintf_group_finish_standard(group_name,
+ total_executed,
+ total_passed,
+ total_failed,
+ total_errors,
+ total_skipped,
+ cm_tests);
break;
case CM_OUTPUT_SUBUNIT:
break;
case CM_OUTPUT_TAP:
- cmprintf_group_finish_tap(group_name, total_executed, total_passed, total_skipped);
+ cmprintf_group_finish_tap(group_name,
+ total_executed,
+ total_passed,
+ total_skipped);
break;
case CM_OUTPUT_XML:
cmprintf_group_finish_xml(group_name,
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7487a9c..e016d6a 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -67,7 +67,7 @@ set_tests_properties(
test_assert_macros_fail
PROPERTIES
PASS_REGULAR_EXPRESSION
- "\\[ FAILED \\] 1 test"
+ "\\[ FAILED \\] tests: 1 test"
)
# test_ordering ensure proper failures
@@ -75,7 +75,7 @@ set_tests_properties(
test_ordering_fail
PROPERTIES
PASS_REGULAR_EXPRESSION
- "\\[ FAILED \\] 7 test"
+ "\\[ FAILED \\] tests: 7 test"
)
# test_returns_fail ensure proper failures
@@ -83,7 +83,7 @@ set_tests_properties(
test_returns_fail
PROPERTIES
PASS_REGULAR_EXPRESSION
- "\\[ FAILED \\] 3 test"
+ "\\[ FAILED \\] alloc_tests: 3 test"
)
# test_exception_handler