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))) |
42 |
48 |
43 /* logging function for tests |
49 /* logging function for tests |
44 * a test uses g_message() to log a debug line |
50 * a test uses g_message() to log a debug line |
45 * a gst unit test can be run with GST_TEST_DEBUG env var set to see the |
51 * a gst unit test can be run with GST_TEST_DEBUG env var set to see the |
46 * messages |
52 * messages |
147 GstStaticPadTemplate * template, GstCaps * caps); |
153 GstStaticPadTemplate * template, GstCaps * caps); |
148 #ifdef __SYMBIAN32__ |
154 #ifdef __SYMBIAN32__ |
149 IMPORT_C |
155 IMPORT_C |
150 #endif |
156 #endif |
151 |
157 |
|
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 |
152 void gst_check_teardown_src_pad (GstElement * element); |
175 void gst_check_teardown_src_pad (GstElement * element); |
153 #ifdef __SYMBIAN32__ |
176 #ifdef __SYMBIAN32__ |
154 IMPORT_C |
177 IMPORT_C |
155 #endif |
178 #endif |
156 |
179 |
205 /** |
228 /** |
206 * GST_END_TEST: |
229 * GST_END_TEST: |
207 * |
230 * |
208 * wrapper for checks END_TEST |
231 * wrapper for checks END_TEST |
209 */ |
232 */ |
210 |
|
211 /* |
233 /* |
212 #if CHECK_MAJOR_VERSION > 0 || \ |
234 #if __CHECK_VERSION_LATER_THAN(0,9,3) |
213 (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION > 9) || \ |
|
214 (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION > 3) |
|
215 #define GST_START_TEST(__testname) \ |
235 #define GST_START_TEST(__testname) \ |
216 static void __testname (int __i__)\ |
236 static void __testname (int __i__)\ |
217 {\ |
237 {\ |
218 GST_DEBUG ("test start"); \ |
238 GST_DEBUG ("test start"); \ |
219 tcase_fn_start (""# __testname, __FILE__, __LINE__); |
239 tcase_fn_start (""# __testname, __FILE__, __LINE__); |
228 //// tcase_fn_start (""# __testname, __FILE__, __LINE__); |
248 //// tcase_fn_start (""# __testname, __FILE__, __LINE__); |
229 // |
249 // |
230 //#define GST_END_TEST END_TEST |
250 //#define GST_END_TEST END_TEST |
231 //#endif |
251 //#endif |
232 |
252 |
233 //#define GST_END_TEST } |
|
234 |
253 |
235 /* additional fail macros */ |
254 /* additional fail macros */ |
236 /** |
255 /** |
237 * fail_unless_equals_int: |
256 * fail_unless_equals_int: |
238 * @a: a #gint value or expression |
257 * @a: a #gint value or expression |
365 |
384 |
366 #define MAIN_INIT() \ |
385 #define MAIN_INIT() \ |
367 G_STMT_START { \ |
386 G_STMT_START { \ |
368 _gst_check_threads_running = TRUE; \ |
387 _gst_check_threads_running = TRUE; \ |
369 \ |
388 \ |
370 mutex = g_mutex_new (); \ |
389 if (mutex == NULL) { \ |
371 start_cond = g_cond_new (); \ |
390 mutex = g_mutex_new (); \ |
372 sync_cond = g_cond_new (); \ |
391 start_cond = g_cond_new (); \ |
|
392 sync_cond = g_cond_new (); \ |
|
393 } \ |
373 } G_STMT_END; |
394 } G_STMT_END; |
374 |
395 |
375 #define MAIN_START_THREAD_FUNCTIONS(count, function, data) \ |
396 #define MAIN_START_THREAD_FUNCTIONS(count, function, data) \ |
376 G_STMT_START { \ |
397 G_STMT_START { \ |
377 int i; \ |
398 int i; \ |
408 _gst_check_threads_running = FALSE; \ |
429 _gst_check_threads_running = FALSE; \ |
409 \ |
430 \ |
410 /* join all threads */ \ |
431 /* join all threads */ \ |
411 GST_DEBUG ("MAIN: joining"); \ |
432 GST_DEBUG ("MAIN: joining"); \ |
412 g_list_foreach (thread_list, (GFunc) g_thread_join, NULL); \ |
433 g_list_foreach (thread_list, (GFunc) g_thread_join, NULL); \ |
|
434 g_list_free (thread_list); \ |
|
435 thread_list = NULL; \ |
413 GST_DEBUG ("MAIN: joined"); \ |
436 GST_DEBUG ("MAIN: joined"); \ |
414 } G_STMT_END; |
437 } G_STMT_END; |
415 |
438 |
416 #define THREAD_START() \ |
439 #define THREAD_START() \ |
417 THREAD_STARTED(); \ |
440 THREAD_STARTED(); \ |
509 |
532 |
510 /* |
533 /* |
511 #define GST_CHECK_MAIN(name) \ |
534 #define GST_CHECK_MAIN(name) \ |
512 int main (int argc, char **argv) \ |
535 int main (int argc, char **argv) \ |
513 { \ |
536 { \ |
514 int i, num_fun; \ |
537 Suite *s; \ |
515 gst_check_init (NULL, NULL); \ |
538 gst_check_init (&argc, &argv); \ |
516 i = sizeof(args); \ |
539 s = name ## _suite (); \ |
517 num_fun = i/sizeof(int); \ |
540 return gst_check_run_suite (s, # name, __FILE__); \ |
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; \ |
|
527 } |
541 } |
528 |
|
529 */ |
542 */ |
530 |
|
531 |
|
532 #define GST_CHECK_MAIN(name) \ |
543 #define GST_CHECK_MAIN(name) \ |
533 int main (int argc, char **argv) \ |
544 int main (int argc, char **argv) \ |
534 { \ |
545 { \ |
535 int i, num_fun; \ |
546 int i, num_fun; \ |
536 char filename[150]; \ |
547 char filename[150]; \ |
561 if(i == num_fun) \ |
572 if(i == num_fun) \ |
562 std_log(LOG_FILENAME_LINE, "%s is invalid args", argv[1]); \ |
573 std_log(LOG_FILENAME_LINE, "%s is invalid args", argv[1]); \ |
563 return 0; \ |
574 return 0; \ |
564 } |
575 } |
565 |
576 |
566 |
|
567 |
|
568 |
|
569 /* Hack to allow run-time selection of unit tests to run via the |
577 /* Hack to allow run-time selection of unit tests to run via the |
570 * GST_CHECKS environment variable (test function names, comma-separated) */ |
578 * GST_CHECKS environment variable (test function names, comma-separated) */ |
571 #ifdef __SYMBIAN32__ |
579 #ifdef __SYMBIAN32__ |
572 IMPORT_C |
580 IMPORT_C |
573 #endif |
581 #endif |
574 |
582 |
575 |
583 |
576 gboolean _gst_check_run_test_func (const gchar * func_name); |
584 gboolean _gst_check_run_test_func (const gchar * func_name); |
577 |
|
578 /* |
585 /* |
579 #if CHECK_MAJOR_VERSION > 0 || \ |
586 #if __CHECK_VERSION_LATER_THAN(0,9,6) |
580 (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION > 9) || \ |
587 static inline void |
581 (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION > 3) |
588 __gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal, |
|
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) |
582 static inline void |
596 static inline void |
583 __gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal, |
597 __gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal, |
584 int start, int end) |
598 int start, int end) |
585 { |
599 { |
586 if (_gst_check_run_test_func (fname)) { |
600 if (_gst_check_run_test_func (fname)) { |