check: Apply GStreamer-specific patches
authorSebastian Rasmussen <sebras@hotmail.com>
Sat, 15 Nov 2014 12:26:47 +0000 (13:26 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 6 Dec 2014 16:48:25 +0000 (17:48 +0100)
Reintroduced patches:

 * Make sure that fail_if(1) actually fails
   from commit 9f99d056a263e71a5e6181224829def906cf0226

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

16 files changed:
configure.ac
libs/gst/check/gstcheck.h
libs/gst/check/libcheck/Makefile.am
libs/gst/check/libcheck/check.c
libs/gst/check/libcheck/check.h.in
libs/gst/check/libcheck/check_error.c
libs/gst/check/libcheck/check_error.h
libs/gst/check/libcheck/check_list.c
libs/gst/check/libcheck/check_log.c
libs/gst/check/libcheck/check_msg.c
libs/gst/check/libcheck/check_pack.c
libs/gst/check/libcheck/check_print.c
libs/gst/check/libcheck/check_run.c
libs/gst/check/libcheck/check_str.c
libs/gst/check/libcheck/libcompat.h
m4/check-checks.m4

index ab50a3a..24fac81 100644 (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])
index c2c34e1..487382d 100644 (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
 
index e814fc8..870007c 100644 (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)
 
index af2f45a..7b8df85 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <string.h>
 #include <stdio.h>
 #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) {
index e8de6a6..306bbee 100644 (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
index c4aebd0..9ee1dd1 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <stdarg.h>
 #include <stdlib.h>
index b3e8744..771a7fd 100644 (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;
index 1382cfa..bce19d8 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <stdlib.h>
 #include <string.h>
index cd1e5b5..9f90b9c 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <stdlib.h>
 #include <stdio.h>
index a55b0b8..acdd904 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <sys/types.h>
 #include <stdlib.h>
index a3f635d..9fdbc5b 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <stdlib.h>
 #include <string.h>
index c84e158..88bc16b 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <stdio.h>
 #include <string.h>
index bd0f637..17abf87 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <sys/types.h>
 #include <time.h>
index 972e29a..62b6723 100644 (file)
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../lib/libcompat.h"
+#include "libcompat.h"
 
 #include <stdio.h>
 #include <stdarg.h>
index f6afdf5..32f944c 100644 (file)
 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)
index 349a1b5..a90d585 100644 (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