From f5f749def6aaead109d22fcce50c554cd84665b2 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Tue, 11 Dec 2018 10:08:32 -0800 Subject: [PATCH] vtest: move failure reporting macros to util Signed-off-by: Gurchetan Singh Reviewed-By: Gert Wollny --- vtest/util.c | 13 ++++++++++++- vtest/util.h | 10 ++++++++++ vtest/vtest_renderer.c | 20 -------------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/vtest/util.c b/vtest/util.c index f389497..0ae37de 100644 --- a/vtest/util.c +++ b/vtest/util.c @@ -29,7 +29,6 @@ #include #include - int vtest_wait_for_fd_read(int fd) { fd_set read_fds; @@ -49,3 +48,15 @@ int vtest_wait_for_fd_read(int fd) return -1; } + +int __failed_call(const char* func, const char *called, int ret) +{ + fprintf(stderr, "%s called %s which failed (%d)\n", func, called, ret); + return ret; +} + +int __failure(const char* func, const char *reason, int ret) +{ + fprintf(stderr, "%s %s (%d)\n", func, reason, ret); + return ret; +} diff --git a/vtest/util.h b/vtest/util.h index 2c60bc5..c73f277 100644 --- a/vtest/util.h +++ b/vtest/util.h @@ -27,4 +27,14 @@ int vtest_wait_for_fd_read(int fd); +int __failed_call(const char* func, const char *called, int ret); + +int __failure(const char* func, const char *reason, int ret); + +#define report_failure(reason, ret) \ + __failure(__FUNCTION__, reason, ret) + +#define report_failed_call(called, ret) \ + __failed_call(__FUNCTION__, called, ret) + #endif /* VTEST_UTIL_H */ diff --git a/vtest/vtest_renderer.c b/vtest/vtest_renderer.c index f78d6e5..84f8d09 100644 --- a/vtest/vtest_renderer.c +++ b/vtest/vtest_renderer.c @@ -65,26 +65,6 @@ struct vtest_renderer { struct vtest_renderer renderer; -static int -__failed_call(const char* func, const char *called, int ret) -{ - fprintf(stderr, "%s called %s which failed (%d)\n", func, called, ret); - return ret; -} - -#define report_failed_call(called, ret) \ - __failed_call(__FUNCTION__, called, ret) - -static int -__failure(const char* func, const char *reason, int ret) -{ - fprintf(stderr, "%s %s (%d)\n", func, reason, ret); - return ret; -} - -#define report_failure(reason, ret) \ - __failure(__FUNCTION__, reason, ret) - static unsigned hash_func(void *key) {