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.
This commit is contained in:
Дмитрий Левин 2016-01-21 23:46:43 +00:00
parent d44707d889
commit 3d54c92691
2 changed files with 14 additions and 0 deletions

View File

@ -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, ...)
{

View File

@ -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;