From 030fae537fea1bdc12bde4be51512c2c1e3e9d0a Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 23 Jan 2018 21:17:05 +0000 Subject: [PATCH] tests: add file:line to perror_msg_and_fail/error_msg_and_fail output * tests/tests.h [!perror_msg_and_fail] (perror_msg_and_fail): New macro wrapper around the homonymous function. [!error_msg_and_fail] (error_msg_and_fail): Likewise. * tests/error_msg.c (perror_msg_and_fail, error_msg_and_fail): New macros defined to themselves. --- tests/error_msg.c | 3 +++ tests/tests.h | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/tests/error_msg.c b/tests/error_msg.c index 498a8821..89724ea6 100644 --- a/tests/error_msg.c +++ b/tests/error_msg.c @@ -25,6 +25,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define perror_msg_and_fail perror_msg_and_fail +#define error_msg_and_fail error_msg_and_fail + #include "tests.h" #include #include diff --git a/tests/tests.h b/tests/tests.h index d453e3e0..8787d233 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -75,6 +75,15 @@ void error_msg_and_skip(const char *, ...) void perror_msg_and_skip(const char *, ...) ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN; +#ifndef perror_msg_and_fail +# define perror_msg_and_fail(fmt_, ...) \ + perror_msg_and_fail("%s:%d: " fmt_, __FILE__, __LINE__, ##__VA_ARGS__) +#endif +#ifndef perror_msg_and_fail +# define error_msg_and_fail(fmt_, ...) \ + error_msg_and_fail("%s:%d: " fmt_, __FILE__, __LINE__, ##__VA_ARGS__) +#endif + /* Stat the specified file and skip the test if the stat call failed. */ void skip_if_unavailable(const char *); -- 2.40.0