1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/regress/test.h
Jonas 'Sortie' Termansen 6454d4d215 Add regress(1).
2014-08-24 14:02:41 +02:00

53 lines
1.4 KiB
C

/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2014.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
test.h
Shared test utility functions.
*******************************************************************************/
#ifndef TEST_H
#define TEST_H
#undef NDEBUG
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define test_assert(x) assert(x)
__attribute__((noreturn))
void test_error(int errnum, const char* format, ...)
{
fprintf(stderr, "%s: ", program_invocation_name);
va_list list;
va_start(list, format);
vfprintf(stderr, format, list);
va_end(list);
if ( errnum )
fprintf(stderr, ": %s", strerror(errnum));
fprintf(stderr, "\n");
exit(1);
}
#endif