mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
85c8b5d2c4
Reintroduced patches:
* Make sure that fail_if(1) actually fails
from commit 9f99d056a2
New patches due to updated libcheck (based on 0.9.14):
* Checks in m4/check-checks.m4 to cater for new dependencies
* Conditional compile-time compat POSIX fallbacks for libcheck
* Avoid relative paths for libcheck header files
* Make timer_create() usage depend on posix timers, not librt
* Rely on default AX_PTHREAD behavior to allow HAVE_PTHREAD to be used
when checking for types and functions (like clock_gettime())
* Avoid double declaration of clock_gettime() when availabe outside of
librt by making compat clock_gettime() declaration conditional
* check 0.9.9 renamed _fail_unless() and 0.9.12 later renamed it again
to _ck_assert_failed(), so ASSERT_{CRITICAL,WARNING}() now calls this
function
* Remove libcheck fallback infrastructure for malloc(), realloc(),
gettimeofday() and snprintf() since either they appear to be
available or they introduce even more dependencies.
The result is an embedded check in gstreamer that has been tested by
running check tests in core, -base, -good, -bad, -ugly and rtsp-server
on Linux, OSX and Windows.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=727826
79 lines
1.9 KiB
C
79 lines
1.9 KiB
C
/*
|
|
* Check: a unit test framework for C
|
|
* Copyright (C) 2001, 2002 Arien Malec
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library 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
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include "libcompat.h"
|
|
|
|
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <setjmp.h>
|
|
|
|
#include "check_error.h"
|
|
|
|
/**
|
|
* Storage for setjmp/longjmp context information used in NOFORK mode
|
|
*/
|
|
jmp_buf error_jmp_buffer;
|
|
|
|
|
|
/* FIXME: including a colon at the end is a bad way to indicate an error */
|
|
void
|
|
eprintf (const char *fmt, const char *file, int line, ...)
|
|
{
|
|
va_list args;
|
|
|
|
fflush (stderr);
|
|
|
|
fprintf (stderr, "%s:%d: ", file, line);
|
|
va_start (args, line);
|
|
vfprintf (stderr, fmt, args);
|
|
va_end (args);
|
|
|
|
/*include system error information if format ends in colon */
|
|
if (fmt[0] != '\0' && fmt[strlen (fmt) - 1] == ':')
|
|
fprintf (stderr, " %s", strerror (errno));
|
|
fprintf (stderr, "\n");
|
|
|
|
exit (2);
|
|
}
|
|
|
|
void *
|
|
emalloc (size_t n)
|
|
{
|
|
void *p;
|
|
|
|
p = malloc (n);
|
|
if (p == NULL)
|
|
eprintf ("malloc of %u bytes failed:", __FILE__, __LINE__ - 2, n);
|
|
return p;
|
|
}
|
|
|
|
void *
|
|
erealloc (void *ptr, size_t n)
|
|
{
|
|
void *p;
|
|
|
|
p = realloc (ptr, n);
|
|
if (p == NULL)
|
|
eprintf ("realloc of %u bytes failed:", __FILE__, __LINE__ - 2, n);
|
|
return p;
|
|
}
|