32 #include "std_log_result.h" |
32 #include "std_log_result.h" |
33 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
33 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
34 |
34 |
35 void create_xml(int result) |
35 void create_xml(int result) |
36 { |
36 { |
37 |
|
38 if(result) |
37 if(result) |
39 { |
|
40 assert_failed = 1; |
38 assert_failed = 1; |
41 } |
39 |
42 |
|
43 testResultXml(xmlfile); |
40 testResultXml(xmlfile); |
44 close_log_file(); |
41 close_log_file(); |
45 |
|
46 if(result) |
|
47 { |
|
48 exit (-1); |
|
49 } |
|
50 |
|
51 } |
42 } |
52 |
43 |
53 #include "libgstreamer_wsd_solution.h" |
44 #include "libgstreamer_wsd_solution.h" |
54 |
45 |
55 #if EMULATOR |
46 #if EMULATOR |
56 GET_GLOBAL_VAR_FROM_TLS(buffers,gstcheck,GList*) |
47 GET_GLOBAL_VAR_FROM_TLS(buffers,gstcheck,GList*) |
57 #define buffers (*GET_GSTREAMER_WSD_VAR_NAME(buffers,gstcheck,g)()) |
48 #define buffers (*GET_GSTREAMER_WSD_VAR_NAME(buffers,gstcheck,g)()) |
58 #else |
49 #else |
59 IMPORT_C extern GList *buffers; |
50 extern GList *buffers; |
60 #endif |
51 #endif |
61 |
52 |
62 |
53 |
63 #if EMULATOR |
54 #if EMULATOR |
64 static GET_GLOBAL_VAR_FROM_TLS(raised_critical,gstcheck,gboolean) |
55 static GET_GLOBAL_VAR_FROM_TLS(raised_critical,gstcheck,gboolean) |
65 #define _gst_check_raised_critical (*GET_GSTREAMER_WSD_VAR_NAME(raised_critical,gstcheck,g)()) |
56 #define _gst_check_raised_critical (*GET_GSTREAMER_WSD_VAR_NAME(raised_critical,gstcheck,g)()) |
66 #else |
57 #else |
67 IMPORT_C extern gboolean _gst_check_raised_critical; |
58 extern gboolean _gst_check_raised_critical; |
68 #endif |
59 #endif |
69 //gboolean _gst_check_raised_warning = FALSE; |
60 //gboolean _gst_check_raised_warning = FALSE; |
70 #if EMULATOR |
61 #if EMULATOR |
71 static GET_GLOBAL_VAR_FROM_TLS(raised_warning,gstcheck,gboolean) |
62 static GET_GLOBAL_VAR_FROM_TLS(raised_warning,gstcheck,gboolean) |
72 #define _gst_check_raised_warning (*GET_GSTREAMER_WSD_VAR_NAME(raised_warning,gstcheck,g)()) |
63 #define _gst_check_raised_warning (*GET_GSTREAMER_WSD_VAR_NAME(raised_warning,gstcheck,g)()) |
73 #else |
64 #else |
74 IMPORT_C extern gboolean _gst_check_raised_warning; |
65 extern gboolean _gst_check_raised_warning; |
75 #endif |
66 #endif |
76 //gboolean _gst_check_expecting_log = FALSE; |
67 //gboolean _gst_check_expecting_log = FALSE; |
77 #if EMULATOR |
68 #if EMULATOR |
78 static GET_GLOBAL_VAR_FROM_TLS(expecting_log,gstcheck,gboolean) |
69 static GET_GLOBAL_VAR_FROM_TLS(expecting_log,gstcheck,gboolean) |
79 #define _gst_check_expecting_log (*GET_GSTREAMER_WSD_VAR_NAME(expecting_log,gstcheck,g)()) |
70 #define _gst_check_expecting_log (*GET_GSTREAMER_WSD_VAR_NAME(expecting_log,gstcheck,g)()) |
80 #else |
71 #else |
81 IMPORT_C extern gboolean _gst_check_expecting_log; |
72 extern gboolean _gst_check_expecting_log; |
82 #endif |
73 #endif |
83 //gboolean _gst_check_threads_running = FALSE; |
74 //gboolean _gst_check_threads_running = FALSE; |
84 #if EMULATOR |
75 #if EMULATOR |
85 static GET_GLOBAL_VAR_FROM_TLS(threads_running,gstcheck,gboolean) |
76 static GET_GLOBAL_VAR_FROM_TLS(threads_running,gstcheck,gboolean) |
86 #define _gst_check_threads_running (*GET_GSTREAMER_WSD_VAR_NAME(threads_running,gstcheck,g)()) |
77 #define _gst_check_threads_running (*GET_GSTREAMER_WSD_VAR_NAME(threads_running,gstcheck,g)()) |
87 #else |
78 #else |
88 IMPORT_C extern gboolean _gst_check_threads_running; |
79 extern gboolean _gst_check_threads_running; |
89 #endif |
80 #endif |
90 |
81 |
91 #if EMULATOR |
82 #if EMULATOR |
92 GET_GLOBAL_VAR_FROM_TLS(thread_list,gstcheck,GList*) |
83 GET_GLOBAL_VAR_FROM_TLS(thread_list,gstcheck,GList*) |
93 #define thread_list (*GET_GSTREAMER_WSD_VAR_NAME(thread_list,gstcheck,g)()) |
84 #define thread_list (*GET_GSTREAMER_WSD_VAR_NAME(thread_list,gstcheck,g)()) |
408 |
399 |
409 /* each object is referenced by a message; |
400 /* each object is referenced by a message; |
410 * base_src is blocked in the push and has an extra refcount. |
401 * base_src is blocked in the push and has an extra refcount. |
411 * base_sink_chain has taken a refcount on the sink, and is blocked on |
402 * base_sink_chain has taken a refcount on the sink, and is blocked on |
412 * preroll */ |
403 * preroll */ |
413 ASSERT_OBJECT_REFCOUNT (src, "src", 4); |
404 ASSERT_OBJECT_REFCOUNT (src, "src", 2); |
414 /* refcount can be 4 if the bin is still processing the async_done message of |
405 /* refcount can be 4 if the bin is still processing the async_done message of |
415 * the sink. */ |
406 * the sink. */ |
416 ASSERT_OBJECT_REFCOUNT_BETWEEN (sink, "sink", 2, 3); |
407 ASSERT_OBJECT_REFCOUNT_BETWEEN (sink, "sink", 2, 3); |
417 /* 2 or 3 is valid, because the pipeline might still be posting |
408 /* 2 or 3 is valid, because the pipeline might still be posting |
418 * its state_change message */ |
409 * its state_change message */ |
460 GST_DEBUG ("setting pipeline to READY"); |
451 GST_DEBUG ("setting pipeline to READY"); |
461 ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY); |
452 ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY); |
462 fail_unless (ret == GST_STATE_CHANGE_SUCCESS); |
453 fail_unless (ret == GST_STATE_CHANGE_SUCCESS); |
463 |
454 |
464 /* each object is referenced by two messages */ |
455 /* each object is referenced by two messages */ |
465 ASSERT_OBJECT_REFCOUNT (src, "src", 4); |
456 ASSERT_OBJECT_REFCOUNT (src, "src", 3); |
466 ASSERT_OBJECT_REFCOUNT (sink, "sink", 3); |
457 ASSERT_OBJECT_REFCOUNT (sink, "sink", 3); |
467 ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 3); |
458 ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 3); |
468 |
459 |
469 pop_messages (bus, 6); |
460 pop_messages (bus, 6); |
470 fail_if ((gst_bus_pop (bus)) != NULL); |
461 fail_if ((gst_bus_pop (bus)) != NULL); |
1035 gst_object_unref (pipeline); |
1026 gst_object_unref (pipeline); |
1036 std_log(LOG_FILENAME_LINE, "Test Successful"); |
1027 std_log(LOG_FILENAME_LINE, "Test Successful"); |
1037 create_xml(0); |
1028 create_xml(0); |
1038 } |
1029 } |
1039 |
1030 |
1040 static void |
|
1041 test_link_structure_change_state_changed_sync_cb (GstBus * bus, |
|
1042 GstMessage * message, gpointer data) |
|
1043 { |
|
1044 GstPipeline *pipeline = GST_PIPELINE (data); |
|
1045 GstElement *src, *identity, *sink; |
|
1046 GstState old, snew, pending; |
|
1047 |
|
1048 sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); |
|
1049 fail_unless (sink != NULL, "Could not get sink"); |
|
1050 |
|
1051 gst_message_parse_state_changed (message, &old, &snew, &pending); |
|
1052 if (message->src != GST_OBJECT (sink) || snew != GST_STATE_READY) { |
|
1053 gst_object_unref (sink); |
|
1054 return; |
|
1055 } |
|
1056 |
|
1057 src = gst_bin_get_by_name (GST_BIN (pipeline), "src"); |
|
1058 fail_unless (src != NULL, "Could not get src"); |
|
1059 |
|
1060 identity = gst_bin_get_by_name (GST_BIN (pipeline), "identity"); |
|
1061 fail_unless (identity != NULL, "Could not get identity"); |
|
1062 |
|
1063 /* link src to identity, the pipeline should detect the new link and |
|
1064 * resync the state change */ |
|
1065 fail_unless (gst_element_link (src, identity) == TRUE); |
|
1066 |
|
1067 gst_object_unref (src); |
|
1068 gst_object_unref (identity); |
|
1069 gst_object_unref (sink); |
|
1070 } |
|
1071 |
|
1072 void test_link_structure_change() |
|
1073 { |
|
1074 GstElement *src, *identity, *sink, *pipeline; |
|
1075 GstBus *bus; |
|
1076 GstState state; |
|
1077 xmlfile = "test_link_structure_change"; |
|
1078 std_log(LOG_FILENAME_LINE, "Test Started test_link_structure_change"); |
|
1079 pipeline = gst_pipeline_new (NULL); |
|
1080 fail_unless (pipeline != NULL, "Could not create pipeline"); |
|
1081 |
|
1082 bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); |
|
1083 fail_unless (bus != NULL, "Could not get bus"); |
|
1084 |
|
1085 /* use the sync signal handler to link elements while the pipeline is still |
|
1086 * doing the state change */ |
|
1087 gst_bus_set_sync_handler (bus, gst_bus_sync_signal_handler, pipeline); |
|
1088 g_object_connect (bus, "signal::sync-message::state-changed", |
|
1089 G_CALLBACK (test_link_structure_change_state_changed_sync_cb), pipeline, |
|
1090 NULL); |
|
1091 |
|
1092 src = gst_element_factory_make ("fakesrc", "src"); |
|
1093 fail_if (src == NULL, "Could not create fakesrc"); |
|
1094 |
|
1095 identity = gst_element_factory_make ("identity", "identity"); |
|
1096 fail_if (identity == NULL, "Could not create identity"); |
|
1097 |
|
1098 sink = gst_element_factory_make ("fakesink", "sink"); |
|
1099 fail_if (sink == NULL, "Could not create fakesink1"); |
|
1100 |
|
1101 gst_bin_add_many (GST_BIN (pipeline), src, identity, sink, NULL); |
|
1102 |
|
1103 gst_element_set_state (pipeline, GST_STATE_READY); |
|
1104 gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); |
|
1105 |
|
1106 /* the state change will be done on src only if the pipeline correctly resyncs |
|
1107 * after that filesrc has been linked to identity */ |
|
1108 gst_element_get_state (src, &state, NULL, 0); |
|
1109 fail_unless_equals_int (state, GST_STATE_READY); |
|
1110 |
|
1111 gst_object_unref (bus); |
|
1112 gst_object_unref (pipeline); |
|
1113 |
|
1114 std_log(LOG_FILENAME_LINE, "Test test_link_structure_change Successful"); |
|
1115 create_xml(0); |
|
1116 } |
|
1117 |
|
1118 |
|
1119 void (*fn[]) (void) = { |
1031 void (*fn[]) (void) = { |
1120 test_message_state_changed, |
1032 test_message_state_changed, |
1121 test_interface, |
1033 test_interface, |
1122 test_message_state_changed_child, |
1034 test_message_state_changed_child, |
1123 test_message_state_changed_children, |
1035 test_message_state_changed_children, |