check: Apply GStreamer-specific patches

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
This commit is contained in:
Sebastian Rasmussen 2014-11-15 13:26:47 +01:00 committed by Sebastian Dröge
parent f1df7aba8f
commit 85c8b5d2c4
16 changed files with 124 additions and 59 deletions

View file

@ -338,8 +338,10 @@ dnl Check for stdio_ext.f for __fbufsize
AC_CHECK_HEADERS([stdio_ext.h], [], [], [AC_INCLUDES_DEFAULT])
dnl check for pthreads
AX_PTHREAD([HAVE_PTHREAD=yes], [HAVE_PTHREAD=no])
AM_CONDITIONAL(HAVE_PTHREAD, test "x$HAVE_PTHREAD" = "xyes")
dnl without arguments AX_PTHREAD() will do AC_DEFINE(HAVE_PTHREAD)
dnl which later checks use in their test code
AX_PTHREAD()
AM_CONDITIONAL(HAVE_PTHREAD, test "x$ax_pthread_ok" = "xyes")
dnl check for sys/prctl for setting thread name on Linux
AC_CHECK_HEADERS([sys/prctl.h], [], [], [AC_INCLUDES_DEFAULT])

View file

@ -508,8 +508,9 @@ G_STMT_START { \
_gst_check_expecting_log = TRUE; \
_gst_check_raised_critical = FALSE; \
code; \
_fail_unless (_gst_check_raised_critical, __FILE__, __LINE__, \
"Expected g_critical, got nothing", NULL); \
if (!_gst_check_raised_critical) \
_ck_assert_failed (__FILE__, __LINE__, \
"Expected g_critical, got nothing", NULL); \
_gst_check_expecting_log = FALSE; \
} G_STMT_END
@ -518,8 +519,9 @@ G_STMT_START { \
_gst_check_expecting_log = TRUE; \
_gst_check_raised_warning = FALSE; \
code; \
_fail_unless (_gst_check_raised_warning, __FILE__, __LINE__, \
"Expected g_warning, got nothing", NULL); \
if (!_gst_check_raised_warning) \
_ck_assert_failed (__FILE__, __LINE__, \
"Expected g_warning, got nothing", NULL); \
_gst_check_expecting_log = FALSE; \
} G_STMT_END

View file

@ -11,7 +11,27 @@ CFILES =\
check_pack.c \
check_print.c \
check_run.c \
check_str.c
check_str.c \
libcompat.c
if !HAVE_ALARM
CFILES += alarm.c
endif
if !HAVE_CLOCK_GETTIME
CFILES += clock_gettime.c
endif
if !HAVE_STRSIGNAL
CFILES += strsignal.c
endif
if !HAVE_TIMER_CREATE_SETTIME_DELETE
CFILES +=\
timer_create.c \
timer_settime.c \
timer_delete.c
endif
HFILES =\
check.h \
@ -22,7 +42,8 @@ HFILES =\
check_msg.h \
check_pack.h \
check_print.h \
check_str.h
check_str.h \
libcompat.h
noinst_HEADERS = $(HFILES)

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <string.h>
#include <stdio.h>
@ -32,6 +32,10 @@
#include "check_impl.h"
#include "check_msg.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* for _POSIX_VERSION */
#endif
#ifndef DEFAULT_TIMEOUT
#define DEFAULT_TIMEOUT 4
#endif
@ -536,7 +540,7 @@ check_get_clockid ()
* Worse, if librt and alarm() are unavailable, this check
* will result in an assert(0).
*/
#ifdef HAVE_LIBRT
#if defined(HAVE_POSIX_TIMERS) && defined(HAVE_MONOTONIC_CLOCK)
timer_t timerid;
if (timer_create (CLOCK_MONOTONIC, NULL, &timerid) == 0) {

View file

@ -25,7 +25,7 @@
#include <stddef.h>
#include <string.h>
#include <check_stdint.h>
#include "_stdint.h"
/*
Macros and functions starting with _ (underscore) are internal and

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <stdarg.h>
#include <stdlib.h>

View file

@ -21,7 +21,7 @@
#ifndef ERROR_H
#define ERROR_H
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <setjmp.h>
extern jmp_buf error_jmp_buffer;

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <stdlib.h>
#include <string.h>

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <stdlib.h>
#include <stdio.h>

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <sys/types.h>
#include <stdlib.h>

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <stdlib.h>
#include <string.h>

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <stdio.h>
#include <string.h>

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <sys/types.h>
#include <time.h>

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "../lib/libcompat.h"
#include "libcompat.h"
#include <stdio.h>
#include <stdarg.h>

View file

@ -84,22 +84,10 @@
CK_DLL_EXP unsigned int alarm (unsigned int seconds);
#endif /* !HAVE_DECL_ALARM */
#if !HAVE_MALLOC
CK_DLL_EXP void *rpl_malloc (size_t n);
#endif /* !HAVE_MALLOC */
#if !HAVE_REALLOC
CK_DLL_EXP void *rpl_realloc (void *p, size_t n);
#endif /* !HAVE_REALLOC */
#if !HAVE_GETPID && HAVE__GETPID
#define getpid _getpid
#endif /* !HAVE_GETPID && HAVE__GETPID */
#if !HAVE_GETTIMEOFDAY
CK_DLL_EXP int gettimeofday (struct timeval *tv, void *tz);
#endif /* !HAVE_GETTIMEOFDAY */
#if !HAVE_DECL_LOCALTIME_R
#if !defined(localtime_r)
CK_DLL_EXP struct tm *localtime_r (const time_t * clock, struct tm *result);
@ -170,7 +158,9 @@ struct itimerspec
*/
struct sigevent;
#ifndef HAVE_CLOCK_GETTIME
CK_DLL_EXP int clock_gettime (clockid_t clk_id, struct timespec *ts);
#endif
CK_DLL_EXP int timer_create (clockid_t clockid, struct sigevent *sevp,
timer_t * timerid);
CK_DLL_EXP int timer_settime (timer_t timerid, int flags,
@ -178,33 +168,6 @@ CK_DLL_EXP int timer_settime (timer_t timerid, int flags,
CK_DLL_EXP int timer_delete (timer_t timerid);
#endif /* HAVE_LIBRT */
/*
* The following checks are to determine if the system's
* snprintf (or its variants) should be replaced with
* the C99 compliant version in libcompat.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#if HAVE_STDARG_H
#include <stdarg.h>
#if !HAVE_VSNPRINTF
CK_DLL_EXP int rpl_vsnprintf (char *, size_t, const char *, va_list);
#define vsnprintf rpl_vsnprintf
#endif
#if !HAVE_SNPRINTF
CK_DLL_EXP int rpl_snprintf (char *, size_t, const char *, ...);
#define snprintf rpl_snprintf
#endif
#endif /* HAVE_STDARG_H */
#if !HAVE_GETLINE
CK_DLL_EXP ssize_t getline (char **lineptr, size_t * n, FILE * stream);
#endif
/* silence warnings about an empty library */
CK_DLL_EXP void
ck_do_nothing (void)

View file

@ -20,6 +20,79 @@ AC_CHECK_HEADERS([unistd.h sys/wait.h sys/time.h], [], [], [AC_INCLUDES_DEFAULT]
AC_CHECK_FUNCS([localtime_r])
dnl Check for getpid() and _getpid()
AC_CHECK_FUNCS([getpid _getpid])
dnl Check for strdup() and _strdup()
AC_CHECK_DECLS([strdup])
AC_CHECK_FUNCS([_strdup])
dnl Check for fork
AC_CHECK_FUNCS([fork], HAVE_FORK=1, HAVE_FORK=0)
AC_SUBST(HAVE_FORK)
dnl Check for alarm, localtime_r and strsignal
dnl First check for time.h as it might be used by localtime_r
AC_CHECK_HEADERS([time.h])
AC_CHECK_DECLS([alarm, localtime_r, strsignal], [], [], [
AC_INCLUDES_DEFAULT
#if HAVE_TIME_H
#include <time.h>
#endif /* HAVE_TIME_H */
])
AC_CHECK_FUNCS([alarm setitimer strsignal])
AM_CONDITIONAL(HAVE_ALARM, test "x$ac_cv_func_alarm" = "xyes")
AM_CONDITIONAL(HAVE_LOCALTIME_R, test "x$ac_cv_func_localtime_r" = "xyes")
AM_CONDITIONAL(HAVE_STRSIGNAL, test "x$ac_cv_func_strsignal" = "xyes")
dnl Check if struct timespec/itimerspec are defined in time.h. If not, we need
dnl to define it in libs/gst/check/libcheck/libcompat.h. Note the optional
dnl inclusion of pthread.h. On MinGW(-w64), the pthread.h file contains the
dnl timespec/itimerspec definitions.
AC_CHECK_MEMBERS([struct timespec.tv_sec, struct timespec.tv_nsec], [],
[AC_DEFINE_UNQUOTED(STRUCT_TIMESPEC_DEFINITION_MISSING, 1,
[Need to define the timespec structure])], [
#include <time.h>
#if HAVE_PTHREAD
#include <pthread.h>
#endif /* HAVE_PTHREAD */
])
AC_CHECK_MEMBERS([struct itimerspec.it_interval, struct itimerspec.it_value],
[], [AC_DEFINE_UNQUOTED(STRUCT_ITIMERSPEC_DEFINITION_MISSING, 1,
[Need to define the itimerspec structure])], [
#include <time.h>
#if HAVE_PTHREAD
#include <pthread.h>
#endif /* HAVE_PTHREAD */
])
dnl Check if types timer_t/clockid_t are defined. If not, we need to define
dnl it in libs/gst/check/libcheck/ibcompat.h. Note the optional inclusion of
dnl pthread.h. On MinGW(-w64), the pthread.h file contains the
dnl timer_t/clockid_t definitions.
AC_CHECK_TYPE(timer_t, [], [
AC_DEFINE([timer_t], [int], [timer_t])
], [
AC_INCLUDES_DEFAULT
#if HAVE_PTHREAD
#include <pthread.h>
#endif /* HAVE_PTHREAD */
])
AC_CHECK_TYPE(clockid_t, [], [
AC_DEFINE([clockid_t], [int], [clockid_t])
], [
AC_INCLUDES_DEFAULT
#if HAVE_PTHREAD
#include <pthread.h>
#endif /* HAVE_PTHREAD */
])
dnl Check for POSIX timer functions in librt
AC_CHECK_LIB([rt], [timer_create, timer_settime, timer_delete])
AM_CONDITIONAL(HAVE_TIMER_CREATE_SETTIME_DELETE, test "x$ac_cv_lib_rt_timer_create__timer_settime__timer_delete" = "xyes")
dnl Allow for checking HAVE_CLOCK_GETTIME in automake files
AM_CONDITIONAL(HAVE_CLOCK_GETTIME, test "x$ac_cv_func_clock_gettime" = "xyes")
dnl Create _stdint.h in the top-level directory
AX_CREATE_STDINT_H