gstreamer_core/libs/gst/check/gstcheck.h
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    27 #include <signal.h>
    27 #include <signal.h>
    28 #include <string.h>
    28 #include <string.h>
    29 #include <stdlib.h>
    29 #include <stdlib.h>
    30 #include <math.h>
    30 #include <math.h>
    31 
    31 
    32 
    32 #include "check.h"
    33 
    33 
    34 #include "libgstreamer_wsd_solution.h" 
    34 #include "libgstreamer_wsd_solution.h" 
    35 #include <check.h>
    35 
    36 #include <gst/gst.h>
    36 #include <gst/gst.h>
    37 
    37 
    38 G_BEGIN_DECLS
    38 G_BEGIN_DECLS
    39 
    39 
    40 GST_DEBUG_CATEGORY_EXTERN (check_debug);
    40 GST_DEBUG_CATEGORY_EXTERN (check_debug);
    41 #define GST_CAT_DEFAULT check_debug
    41 #define GST_CAT_DEFAULT check_debug
    42 
       
    43 #define __CHECK_VERSION_LATER_THAN(major,minor,micro) \
       
    44     (CHECK_MAJOR_VERSION > major || \
       
    45      (CHECK_MAJOR_VERSION == (major) && CHECK_MINOR_VERSION > (minor)) || \
       
    46      (CHECK_MAJOR_VERSION == (major) && CHECK_MINOR_VERSION == (minor) && \
       
    47       CHECK_MICRO_VERSION > (micro)))
       
    48 
    42 
    49 /* logging function for tests
    43 /* logging function for tests
    50  * a test uses g_message() to log a debug line
    44  * a test uses g_message() to log a debug line
    51  * a gst unit test can be run with GST_TEST_DEBUG env var set to see the
    45  * a gst unit test can be run with GST_TEST_DEBUG env var set to see the
    52  * messages
    46  * messages
   153     GstStaticPadTemplate * template, GstCaps * caps);
   147     GstStaticPadTemplate * template, GstCaps * caps);
   154 #ifdef __SYMBIAN32__
   148 #ifdef __SYMBIAN32__
   155 IMPORT_C
   149 IMPORT_C
   156 #endif
   150 #endif
   157 
   151 
   158 GstPad * gst_check_setup_src_pad_by_name (GstElement * element,
       
   159           GstStaticPadTemplate * template, gchar *name);
       
   160 #ifdef __SYMBIAN32__
       
   161 IMPORT_C
       
   162 #endif
       
   163 
       
   164 GstPad * gst_check_setup_sink_pad_by_name (GstElement * element, 
       
   165           GstStaticPadTemplate * template, gchar *name);
       
   166 #ifdef __SYMBIAN32__
       
   167 IMPORT_C
       
   168 #endif
       
   169 
       
   170 void gst_check_teardown_pad_by_name (GstElement * element, gchar *name);
       
   171 #ifdef __SYMBIAN32__
       
   172 IMPORT_C
       
   173 #endif
       
   174 
       
   175 void gst_check_teardown_src_pad (GstElement * element);
   152 void gst_check_teardown_src_pad (GstElement * element);
   176 #ifdef __SYMBIAN32__
   153 #ifdef __SYMBIAN32__
   177 IMPORT_C
   154 IMPORT_C
   178 #endif
   155 #endif
   179 
   156 
   228 /**
   205 /**
   229  * GST_END_TEST:
   206  * GST_END_TEST:
   230  *
   207  *
   231  * wrapper for checks END_TEST
   208  * wrapper for checks END_TEST
   232  */
   209  */
       
   210 
   233 /*
   211 /*
   234 #if __CHECK_VERSION_LATER_THAN(0,9,3)
   212 #if CHECK_MAJOR_VERSION > 0 || \
       
   213     (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION > 9) || \
       
   214     (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION > 3)
   235 #define GST_START_TEST(__testname) \
   215 #define GST_START_TEST(__testname) \
   236 static void __testname (int __i__)\
   216 static void __testname (int __i__)\
   237 {\
   217 {\
   238   GST_DEBUG ("test start"); \
   218   GST_DEBUG ("test start"); \
   239   tcase_fn_start (""# __testname, __FILE__, __LINE__);
   219   tcase_fn_start (""# __testname, __FILE__, __LINE__);
   248 ////  tcase_fn_start (""# __testname, __FILE__, __LINE__);
   228 ////  tcase_fn_start (""# __testname, __FILE__, __LINE__);
   249 //
   229 //
   250 //#define GST_END_TEST END_TEST
   230 //#define GST_END_TEST END_TEST
   251 //#endif
   231 //#endif
   252 
   232 
       
   233 //#define GST_END_TEST }
   253 
   234 
   254 /* additional fail macros */
   235 /* additional fail macros */
   255 /**
   236 /**
   256  * fail_unless_equals_int:
   237  * fail_unless_equals_int:
   257  * @a: a #gint value or expression
   238  * @a: a #gint value or expression
   384 
   365 
   385 #define MAIN_INIT()			\
   366 #define MAIN_INIT()			\
   386 G_STMT_START {				\
   367 G_STMT_START {				\
   387   _gst_check_threads_running = TRUE;	\
   368   _gst_check_threads_running = TRUE;	\
   388 					\
   369 					\
   389   if (mutex == NULL) {			\
   370   mutex = g_mutex_new ();		\
   390     mutex = g_mutex_new ();		\
   371   start_cond = g_cond_new ();		\
   391     start_cond = g_cond_new ();		\
   372   sync_cond = g_cond_new ();		\
   392     sync_cond = g_cond_new ();		\
       
   393   }					\
       
   394 } G_STMT_END;
   373 } G_STMT_END;
   395 
   374 
   396 #define MAIN_START_THREAD_FUNCTIONS(count, function, data)	\
   375 #define MAIN_START_THREAD_FUNCTIONS(count, function, data)	\
   397 G_STMT_START {							\
   376 G_STMT_START {							\
   398   int i;							\
   377   int i;							\
   429   _gst_check_threads_running = FALSE;				\
   408   _gst_check_threads_running = FALSE;				\
   430 								\
   409 								\
   431   /* join all threads */					\
   410   /* join all threads */					\
   432   GST_DEBUG ("MAIN: joining");					\
   411   GST_DEBUG ("MAIN: joining");					\
   433   g_list_foreach (thread_list, (GFunc) g_thread_join, NULL);	\
   412   g_list_foreach (thread_list, (GFunc) g_thread_join, NULL);	\
   434   g_list_free (thread_list);					\
       
   435   thread_list = NULL;						\
       
   436   GST_DEBUG ("MAIN: joined");					\
   413   GST_DEBUG ("MAIN: joined");					\
   437 } G_STMT_END;
   414 } G_STMT_END;
   438 
   415 
   439 #define THREAD_START()						\
   416 #define THREAD_START()						\
   440 THREAD_STARTED();						\
   417 THREAD_STARTED();						\
   532 
   509 
   533 /*
   510 /*
   534 #define GST_CHECK_MAIN(name)					\
   511 #define GST_CHECK_MAIN(name)					\
   535 int main (int argc, char **argv)				\
   512 int main (int argc, char **argv)				\
   536 {								\
   513 {								\
   537   Suite *s;                                                     \
   514     int i, num_fun;                  \
   538   gst_check_init (&argc, &argv);				\
   515 gst_check_init (NULL, NULL);                    \
   539   s = name ## _suite ();					\
   516 i = sizeof(args);                           \
   540   return gst_check_run_suite (s, # name, __FILE__);		\
   517  num_fun = i/sizeof(int);                   \
       
   518   for(i=0;i<num_fun;i++)                    \
       
   519       if (!strcmp(args[i], argv[1]))                    \
       
   520       {                                     \
       
   521           fn[i]();                                  \
       
   522           break;                                        \
       
   523           }                     \
       
   524   if(i == num_fun)                      \
       
   525       std_log(LOG_FILENAME_LINE, "%s is invalid args", argv[1]);                      \
       
   526   return 0;                                         \
   541 }
   527 }
       
   528 
   542 */
   529 */
       
   530 
       
   531 
   543 #define GST_CHECK_MAIN(name)                    \
   532 #define GST_CHECK_MAIN(name)                    \
   544     int main (int argc, char **argv)        \
   533     int main (int argc, char **argv)        \
   545     {                                   \
   534     {                                   \
   546         int i, num_fun;                  \
   535         int i, num_fun;                  \
   547         char filename[150];       \
   536         char filename[150];       \
   572       if(i == num_fun)                      \
   561       if(i == num_fun)                      \
   573           std_log(LOG_FILENAME_LINE, "%s is invalid args", argv[1]);    \
   562           std_log(LOG_FILENAME_LINE, "%s is invalid args", argv[1]);    \
   574       return 0;                 \
   563       return 0;                 \
   575     }
   564     }
   576 
   565 
       
   566 
       
   567 
       
   568 
   577 /* Hack to allow run-time selection of unit tests to run via the
   569 /* Hack to allow run-time selection of unit tests to run via the
   578  * GST_CHECKS environment variable (test function names, comma-separated) */
   570  * GST_CHECKS environment variable (test function names, comma-separated) */
   579 #ifdef __SYMBIAN32__
   571 #ifdef __SYMBIAN32__
   580 IMPORT_C
   572 IMPORT_C
   581 #endif
   573 #endif
   582 
   574 
   583 
   575 
   584 gboolean _gst_check_run_test_func (const gchar * func_name);
   576 gboolean _gst_check_run_test_func (const gchar * func_name);
       
   577 
   585 /*
   578 /*
   586 #if __CHECK_VERSION_LATER_THAN(0,9,6)
   579 #if CHECK_MAJOR_VERSION > 0 || \
   587 static inline void
   580     (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION > 9) || \
   588 __gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal,
   581     (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION > 3)
   589     int allowed_exit_value, int start, int end)
       
   590 {
       
   591   if (_gst_check_run_test_func (fname)) {
       
   592     _tcase_add_test (tc, tf, fname, signal, allowed_exit_value, start, end);
       
   593   }
       
   594 }
       
   595 #elif __CHECK_VERSION_LATER_THAN(0,9,3)
       
   596 static inline void
   582 static inline void
   597 __gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal,
   583 __gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal,
   598     int start, int end)
   584     int start, int end)
   599 {
   585 {
   600   if (_gst_check_run_test_func (fname)) {
   586   if (_gst_check_run_test_func (fname)) {
   614 */
   600 */
   615 //#endif
   601 //#endif
   616 
   602 
   617 //#define _tcase_add_test __gst_tcase_add_test
   603 //#define _tcase_add_test __gst_tcase_add_test
   618 
   604 
   619 //#undef __CHECK_VERSION_LATER_THAN
       
   620 
       
   621 G_END_DECLS
   605 G_END_DECLS
   622 
   606 
   623 #endif /* __GST_CHECK_H__ */
   607 #endif /* __GST_CHECK_H__ */