Add errno info when return error in make test

This commit is contained in:
Hui, Chunyang 2021-02-23 12:54:58 +00:00 committed by Zongmin.Gu
parent a2959c17df
commit f0fa35b004

@ -4,6 +4,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#include <string.h>
#define _STR(x) #x #define _STR(x) #x
#define STR(x) _STR(x) #define STR(x) _STR(x)
@ -21,8 +23,8 @@ typedef struct {
#define TEST_CASE(name) { STR(name), name } #define TEST_CASE(name) { STR(name), name }
#define THROW_ERROR(fmt, ...) do { \ #define THROW_ERROR(fmt, ...) do { \
printf("\t\tERROR:" fmt " in func %s at line %d of file %s\n", \ printf("\t\tERROR:" fmt " in func %s at line %d of file %s with errno %d: %s\n", \
##__VA_ARGS__, __func__, __LINE__, __FILE__); \ ##__VA_ARGS__, __func__, __LINE__, __FILE__, errno, strerror(errno)); \
return -1; \ return -1; \
} while (0) } while (0)