From 3d54c92691b3881b6b1d9a08c283417cdbb5ac0a Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 21 Jan 2016 23:46:43 +0000 Subject: [PATCH] tests: add error_msg_and_fail function to libtests * tests/tests.h (error_msg_and_fail): New prototype. * tests/error_msg.c (error_msg_and_fail): New function. --- tests/error_msg.c | 11 +++++++++++ tests/tests.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/tests/error_msg.c b/tests/error_msg.c index 3fd34113..498a8821 100644 --- a/tests/error_msg.c +++ b/tests/error_msg.c @@ -47,6 +47,17 @@ perror_msg_and_fail(const char *fmt, ...) exit(1); } +void +error_msg_and_fail(const char *fmt, ...) +{ + va_list p; + + va_start(p, fmt); + vfprintf(stderr, fmt, p); + putc('\n', stderr); + exit(1); +} + void error_msg_and_skip(const char *fmt, ...) { diff --git a/tests/tests.h b/tests/tests.h index c55b3296..513aa10c 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -41,6 +41,9 @@ size_t get_page_size(void); /* Print message and strerror(errno) to stderr, then exit(1). */ void perror_msg_and_fail(const char *, ...) ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN; +/* Print message to stderr, then exit(1). */ +void error_msg_and_fail(const char *, ...) + ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN; /* Print message to stderr, then exit(77). */ void error_msg_and_skip(const char *, ...) ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN; -- 2.40.0