1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
/*
* Copyright (c) 2016 Dmitry V. Levin <ldv@strace.io>
* Copyright (c) 2016-2021 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#define perror_msg_and_fail perror_msg_and_fail
#define error_msg_and_fail error_msg_and_fail
#include "tests.h"
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void
perror_msg_and_fail(const char *fmt, ...)
{
int err_no = errno;
va_list p;
va_start(p, fmt);
vfprintf(stderr, fmt, p);
if (err_no)
fprintf(stderr, ": %s\n", strerror(err_no));
else
putc('\n', stderr);
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, ...)
{
va_list p;
va_start(p, fmt);
vfprintf(stderr, fmt, p);
putc('\n', stderr);
exit(77);
}
void
perror_msg_and_skip(const char *fmt, ...)
{
int err_no = errno;
va_list p;
va_start(p, fmt);
vfprintf(stderr, fmt, p);
if (err_no)
fprintf(stderr, ": %s\n", strerror(err_no));
else
putc('\n', stderr);
exit(77);
}
|