From: Dmitry V. Levin Date: Thu, 21 Jan 2016 23:46:43 +0000 (+0000) Subject: tests: add error_msg_and_fail function to libtests X-Git-Tag: v4.12~619 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d54c92691b3881b6b1d9a08c283417cdbb5ac0a;p=strace 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. --- 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;