summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-09-09 08:16:51 (GMT)
committerAndreas Schneider <asn@cryptomilk.org>2015-09-09 12:32:43 (GMT)
commit5d4229c8381fbbc09dd733ac9448a5d79fb98840 (patch)
tree709a77b43ee31c24f7e46bcee1e913ce75e62659
parent47627bcdb3b2464b6580618638d1c5d2b9aa5543 (diff)
downloadcmocka-5d4229c8381fbbc09dd733ac9448a5d79fb98840.zip
cmocka-5d4229c8381fbbc09dd733ac9448a5d79fb98840.tar.gz
cmocka-5d4229c8381fbbc09dd733ac9448a5d79fb98840.tar.bz2
src: Improve error reporting with cmocka default output
Reviewed-by: Jakub Hrozek <jakub.hrozek@posteo.se>
-rw-r--r--src/cmocka.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cmocka.c b/src/cmocka.c
index 9790449..284d55f 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -227,6 +227,8 @@ static void initialize_testing(const char *test_name);
/* This must be called at the end of a test to free() allocated structures. */
static void teardown_testing(const char *test_name);
+static enum cm_message_output cm_get_output(void);
+
static int cm_error_message_enabled = 1;
static CMOCKA_THREAD char *cm_error_message;
@@ -1765,7 +1767,16 @@ static void fail_if_blocks_allocated(const ListNode * const check_point,
void _fail(const char * const file, const int line) {
- cm_print_error(SOURCE_LOCATION_FORMAT ": error: Failure!\n", file, line);
+ enum cm_message_output output = cm_get_output();
+
+ switch(output) {
+ case CM_OUTPUT_STDOUT:
+ cm_print_error("[ LINE ] --- " SOURCE_LOCATION_FORMAT ": error: Failure!", file, line);
+ break;
+ default:
+ cm_print_error(SOURCE_LOCATION_FORMAT ": error: Failure!", file, line);
+ break;
+ }
exit_test(1);
}
@@ -2034,7 +2045,7 @@ static void cmprintf_standard(enum cm_printf_type type,
break;
case PRINTF_TEST_FAILURE:
if (error_message != NULL) {
- print_error("%s\n", error_message);
+ print_error("[ ERROR ] --- %s\n", error_message);
}
print_message("[ FAILED ] %s\n", test_name);
break;