vtest: move failure reporting macros to util

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
macos/master
Gurchetan Singh 6 years ago
parent 7313d89e93
commit f5f749def6
  1. 13
      vtest/util.c
  2. 10
      vtest/util.h
  3. 20
      vtest/vtest_renderer.c

@ -29,7 +29,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/select.h> #include <sys/select.h>
int vtest_wait_for_fd_read(int fd) int vtest_wait_for_fd_read(int fd)
{ {
fd_set read_fds; fd_set read_fds;
@ -49,3 +48,15 @@ int vtest_wait_for_fd_read(int fd)
return -1; 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;
}

@ -27,4 +27,14 @@
int vtest_wait_for_fd_read(int fd); 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 */ #endif /* VTEST_UTIL_H */

@ -65,26 +65,6 @@ struct vtest_renderer {
struct vtest_renderer 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 static unsigned
hash_func(void *key) hash_func(void *key)
{ {

Loading…
Cancel
Save