int main() { DBusError error; DBusConnection* connection; dbus_int32_t data_slot = -1; dbus_error_init(&error); connection = dbus_bus_get_private(DBUS_BUS_SESSION, &error); if(!CheckConnection(connection, &error)) { create_xml(1); return 1; } if(!dbus_connection_allocate_data_slot(&data_slot)) { std_log(LOG_FILENAME_LINE, "Out of Memory"); create_xml(1); return 1; } dbus_connection_free_data_slot(&data_slot); dbus_connection_close(connection); dbus_connection_unref(connection); dbus_shutdown(); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); return 0; }
int main() { DBusMessage* msg; char* path = "/"; msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL); if(!msg) { std_log(LOG_FILENAME_LINE,"Fail to create Message"); create_xml(1); return 1; } if(!dbus_message_set_path(msg, path)) { std_log(LOG_FILENAME_LINE,"Not enough Memory."); create_xml(1); return 1; } if(strcmp(path, dbus_message_get_path(msg))) { std_log(LOG_FILENAME_LINE,"Path is not correct"); create_xml(1); return 1; } std_log(LOG_FILENAME_LINE,"Test Successful"); create_xml(0); return 0; }
int main() { DBusMessage* msg; msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL); if(!msg) { std_log(LOG_FILENAME_LINE,"Fail to create Message"); create_xml(1); return 1; } if(DBUS_MESSAGE_TYPE_METHOD_CALL != dbus_message_get_type(msg)) { std_log(LOG_FILENAME_LINE,"Mismatch in Message type."); create_xml(1); return 1; } std_log(LOG_FILENAME_LINE,"Test Successful"); create_xml(0); return 0; }
int main() { DBusError src; DBusError dest; char err[] = "Sample Error0"; dbus_error_init(&src); dbus_error_init(&dest); dbus_set_error(&src, err, NULL); dbus_move_error(&src, &dest); if(!CheckMovedError(&src, &dest, err)) { std_log(LOG_FILENAME_LINE, "Test Fail"); dbus_error_free(&src); dbus_error_free(&dest); create_xml(1); return 1; } else { std_log(LOG_FILENAME_LINE, "Test Successful"); dbus_error_free(&dest); create_xml(0); return 0; } }
int main() { DBusGConnection* connection; DBusGProxy* proxy; GError* error = NULL; char* path = "/Test/Proxy/Path"; g_type_init(); connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (connection == NULL) { std_log(LOG_FILENAME_LINE, "Failed to open connection to bus: %s\n", error->message); g_error_free (error); create_xml(1); return 1; } proxy = dbus_g_proxy_new_for_name(connection, "Test.Glib.Proxy.Path", path, "Test.Proxy.Interface"); if(strcmp(path, dbus_g_proxy_get_path(proxy))) { std_log(LOG_FILENAME_LINE, "Fail to check interface %s", path); create_xml(1); return 1; } std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); return 0; }
int main() { DBusError error; char* err = "Sample Error0"; dbus_error_init(&error); dbus_set_error(&error, err, NULL); if(strcmp(err, error.name)) { std_log(LOG_FILENAME_LINE, "Mismatch in Error Name"); create_xml(1); return 1; } if(strcmp(err, error.message)) { std_log(LOG_FILENAME_LINE, "Message set to :: %s", error.message); std_log(LOG_FILENAME_LINE, "Message is not set to NULL"); create_xml(1); return 1; } dbus_error_free(&error); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); return 0; }
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) { switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: gst_element_set_state (pipeline, GST_STATE_NULL); g_main_loop_quit(loop); gst_object_unref (GST_OBJECT (pipeline)); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); break; case GST_MESSAGE_ERROR: { gchar *debug; GError *err; gst_message_parse_error (msg, &err, &debug); g_free (debug); g_print ("Error: %s\n", err->message); g_error_free (err); std_log(LOG_FILENAME_LINE, "Test Failed"); create_xml(1); break; } default: break; } return TRUE; }
int main (int argc, char *argv[]) { GstElement *filesrc, *audiosink, *decode, *queue; GstElement *pipeline; xmlfile = "queue_logs"; std_log(LOG_FILENAME_LINE, "Test Started queue"); gst_init (&argc, &argv); if (argc != 2) { g_print ("usage: %s <filename>\n", argv[0]); std_log(LOG_FILENAME_LINE, "Test Failed mp3 file need to be passed as an argument"); create_xml(1); exit (-1); } /* create a new pipeline to hold the elements */ pipeline = gst_pipeline_new ("pipeline"); g_assert (pipeline != NULL); /* create a disk reader */ filesrc = gst_element_factory_make ("filesrc", "disk_source"); g_assert (filesrc != NULL); g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); decode = gst_element_factory_make ("mad", "decode"); g_assert (decode != NULL); queue = gst_element_factory_make ("queue", "queue"); g_assert (queue != NULL); /* and an audio sink */ audiosink = gst_element_factory_make ("devsoundsink", "play_audio"); g_assert (audiosink != NULL); /* add objects to the main pipeline */ gst_bin_add_many (GST_BIN (pipeline), filesrc, decode, queue, audiosink, NULL); gst_element_link_many (filesrc, decode, queue, audiosink, NULL); /* start playing */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); /* Listen for EOS */ event_loop (pipeline); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); exit (0); }
int main() { DBusGConnection* connection; DBusGProxy* proxy; DBusGProxy* proxy1 ;//=NULL; GError* error = NULL; pthread_t thr_id; void* thrPtr; char* iface = "Test.Proxy.Interface"; char* iface1 = "Test.Proxy.Interface1"; g_type_init(); connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (connection == NULL) { std_log(LOG_FILENAME_LINE, "Failed to open connection to bus: %s\n", error->message); g_error_free (error); create_xml(1); return 1; } proxy = dbus_g_proxy_new_for_name(connection, "Test.Glib.Proxy.Interface", "/Test/Proxy/Interface", iface); proxy1 = dbus_g_proxy_new_for_name(connection, "Test.Glib.Proxy.Interface", "/Test/Proxy/Interface", iface1); if(strcmp(iface, dbus_g_proxy_get_interface(proxy))) { std_log(LOG_FILENAME_LINE, "Fail to check interface %s", iface); create_xml(1); return 1; } pthread_create(&thr_id, NULL, &set_iface, proxy); pthread_join(thr_id, &thrPtr); if(strcmp(iface1, dbus_g_proxy_get_interface(proxy))) { std_log(LOG_FILENAME_LINE, "Fail to check interface %s", iface1); create_xml(1); return 1; } if(!iface_flag) { std_log(LOG_FILENAME_LINE, "Something wrong happens in thread."); create_xml(1); return 1; } std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); return 0; }
int main() { char error_name[40]; char error_msg[40]; long outgoing_size = 0 ; DBusConnection* connection; DBusError error; DBusMessage* msg; DBusMessage* reply = NULL; dbus_error_init(&error); connection = dbus_bus_get_private(DBUS_BUS_SESSION, &error); if(!connection) { std_log(LOG_FILENAME_LINE, "ERROR_name:%s",error.name); std_log(LOG_FILENAME_LINE, "Error_msg:%s",error.message); create_xml(1); return 1; } msg = dbus_message_new_method_call("Test.Method.Call1", "/Test/Method/Object", "test.Method.Call", "dbus_connection_get_outgoing_size0"); if(msg == NULL) { std_log(LOG_FILENAME_LINE, "Message error"); create_xml(1); return 1; } outgoing_size = dbus_connection_get_outgoing_size( connection ) ; std_log(LOG_FILENAME_LINE, "outgoing message size before sent %d",outgoing_size); dbus_connection_send(connection, msg, NULL); std_log(LOG_FILENAME_LINE, "Message sent"); outgoing_size = dbus_connection_get_outgoing_size( connection ) ; std_log(LOG_FILENAME_LINE, "outgoing message size %d",outgoing_size); create_xml(0); dbus_message_unref(msg); dbus_connection_close(connection); dbus_connection_unref(connection); dbus_shutdown(); std_log(LOG_FILENAME_LINE, "success"); return 0; }
int main() { DBusConnection* connection; DBusError error; int cnt; int data_slot = -1; threadData1 thrData; pthread_t thread[MAX_THREAD]; int thrVal[MAX_THREAD]={0}; void* thrValPtr[MAX_THREAD]; for(cnt=0; cnt<MAX_THREAD; cnt++) thrValPtr[cnt] = (void*)&thrVal[cnt]; dbus_error_init(&error); connection = dbus_bus_get(DBUS_BUS_SESSION, &error); if(!connection || dbus_error_is_set(&error)) return handle_error(&error); pthread_mutex_init(&thrData.mutex, NULL); pthread_cond_init(&thrData.cond, NULL); thrData.ret = 0; dbus_connection_allocate_data_slot(&data_slot); dbus_connection_set_data(connection, data_slot, &thrData, NULL); dbus_threads_init_default(); for(cnt=0; cnt<MAX_THREAD; cnt++) pthread_create(&thread[cnt], NULL, &send_msg1, &data_slot); sleep(1); pthread_cond_broadcast(&thrData.cond); for(cnt=0; cnt<MAX_THREAD; cnt++) pthread_join(thread[cnt], &thrValPtr[cnt]); if(thrData.ret != MAX_THREAD) { std_log(LOG_FILENAME_LINE, "No. of threads crashed %d", (MAX_THREAD - thrData.ret)); create_xml(1); return 1; } dbus_connection_unref(connection); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); return 0; }
static void* send_msg1(void* data) { GError *error = NULL; static int cnt = 1; gint in_num = 5; gint out_num = 0; DBusGConnection *connection; DBusGProxy *proxy; threadData1* thrData = (threadData1*)data; if(!thrData) return; pthread_mutex_lock(&thrData->mutex); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (connection == NULL) { std_log(LOG_FILENAME_LINE, "Failed to open connection to bus: %s\n", error->message); g_error_free (error); create_xml(1); exit (1); } proxy = dbus_g_proxy_new_for_name (connection, "com.example.DBusGlibObject1", "/com/example/DBusGlibObject1", "com.example.DBusGlibObject1"); count++; //vasanth pthread_cond_wait(&thrData->cond, &thrData->mutex); // send message and get a handle for a reply if(!com_example_DBusGlibObject1_simple_method(proxy, in_num, &out_num, &error)) { create_xml(1); exit(1); } std_log(LOG_FILENAME_LINE, "%d\n", out_num); if(out_num == 9090) { thrData->ret++; } dbus_g_connection_unref(connection); pthread_mutex_unlock(&thrData->mutex); }
int main () { DBusError error; DBusConnection *connection; //_dbus_setenv("DBUS_VERBOSE","1"); dbus_error_init (&error); connection = dbus_bus_get (DBUS_BUS_SESSION, &error); if (connection == NULL) { fprintf (stderr, "*** Failed to open connection to system bus: %s\n", error.message); std_log(LOG_FILENAME_LINE, "*** Failed to open connection to system bus: %s\n", error.message); dbus_error_free (&error); create_xml(1); return 1; } /*con2 = dbus_bus_get_private (DBUS_BUS_SESSION, &error); if (con2 == NULL) { fprintf (stderr, "*** Failed to open connection to system bus: %s\n", error.message); dbus_error_free (&error); return 1; } */ /* loop = _dbus_loop_new (); if (loop == NULL) die ("No memory\n"); if (!test_connection_setup (loop, connection)) die ("No memory\n"); */ TestName(connection, "org.freedesktop.DBus.Test", TRUE); TestName(connection, "org.freedesktop.DBus.Test-2", TRUE); TestName(connection, "org.freedesktop.DBus.Test_2", TRUE); #if 0 TestName(connection, "Test_2", TRUE); #endif //ch=getchar(); _dbus_verbose ("*** Test service name exiting\n"); create_xml(0); return 0; }
int main() { DBusError src; DBusError dest; char str[] = "Sample Error No."; int no = 1; char err[] = "Sample Error0"; dbus_error_init(&src); dbus_error_init(&dest); dbus_set_error(&src, err, "This is %s :: %d", str, no); dbus_move_error(&src, &dest); if(!CheckMovedError(&src, &dest, err)) { std_log(LOG_FILENAME_LINE, "Test Fail"); dbus_error_free(&src); dbus_error_free(&dest); create_xml(1); return 1; } else { if(strcmp("This is Sample Error No. :: 1", dest.message)) { std_log(LOG_FILENAME_LINE, "Destination Message is not set Properly."); dbus_error_free(&src); dbus_error_free(&dest); create_xml(1); return 1; } if(src.message) { std_log(LOG_FILENAME_LINE, "Source Message is not NULL."); dbus_error_free(&src); dbus_error_free(&dest); create_xml(1); return 1; } dbus_error_free(&dest); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); return 0; } }
static void TestName(DBusConnection *connection, const char *name, int expectedSuccess) { DBusError error; dbus_error_init (&error); (void) dbus_bus_request_name (connection, name, 0, &error); if (dbus_error_is_set (&error)) { if (expectedSuccess) { fprintf (stderr, "Error acquiring name '%s': %s\n", name, error.message); std_log(LOG_FILENAME_LINE, "Error acquiring name '%s': %s\n", name, error.message); } else { fprintf (stdout, "Expected Error acquiring name '%s': %s\n", name, error.message); std_log(LOG_FILENAME_LINE, "Expected Error acquiring name '%s': %s\n", name, error.message); } _dbus_verbose ("*** Failed to acquire name '%s': %s\n", name, error.message); dbus_error_free (&error); if (expectedSuccess) { create_xml(1); exit (1); } } else { if (!expectedSuccess) { fprintf (stderr, "Unexpected Success acquiring name '%s'\n", name); std_log(LOG_FILENAME_LINE, "Unexpected Success acquiring name '%s'\n", name); } else { fprintf (stdout, "Successfully acquired name '%s'\n", name); std_log(LOG_FILENAME_LINE, "Successfully acquired name '%s'\n", name); } _dbus_verbose ("*** Managed to acquire name '%s'\n", name); if (!expectedSuccess) { create_xml(1); exit (1); } } }
void test_lock() { GstTask *t; gboolean ret; //xmlfile = "test_lock"; std_log(LOG_FILENAME_LINE, "Test Started test_lock"); t = gst_task_create (task_func, NULL); fail_if (t == NULL); TEST_ASSERT_FAIL gst_task_set_lock (t, &task_mutex); GST_DEBUG ("pause"); ret = gst_task_pause (t); fail_unless (ret == TRUE); TEST_ASSERT_FAIL g_usleep (1 * G_USEC_PER_SEC / 2); GST_DEBUG ("joining"); ret = gst_task_join (t); fail_unless (ret == TRUE); TEST_ASSERT_FAIL g_usleep (1 * G_USEC_PER_SEC / 2); gst_object_unref (t); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_lock_start() { GstTask *t; gboolean ret; //xmlfile = "test_lock_start"; std_log(LOG_FILENAME_LINE, "Test Started test_lock_start"); t = gst_task_create (task_func, NULL); fail_if (t == NULL); TEST_ASSERT_FAIL gst_task_set_lock (t, &task_mutex); task_cond = g_cond_new (); task_lock = g_mutex_new (); g_mutex_lock (task_lock); GST_DEBUG ("starting"); ret = gst_task_start (t); fail_unless (ret == TRUE); TEST_ASSERT_FAIL /* wait for it to spin up */ GST_DEBUG ("waiting"); g_cond_wait (task_cond, task_lock); GST_DEBUG ("done waiting"); g_mutex_unlock (task_lock); /* cannot set mutex now */ ASSERT_WARNING (gst_task_set_lock (t, &task_mutex));//b failing GST_DEBUG ("joining"); ret = gst_task_join (t); fail_unless (ret == TRUE); TEST_ASSERT_FAIL gst_object_unref (t); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_one_buffer() { GstElement *identity; GstBuffer *buffer; xmlfile = "identity_test_one_buffer"; std_log(LOG_FILENAME_LINE, "Test Started test_one_buffer"); identity = setup_identity (); fail_unless (gst_element_set_state (identity, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, "could not set to playing"); buffer = gst_buffer_new_and_alloc (4); ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); memcpy (GST_BUFFER_DATA (buffer), "data", 4); /* pushing gives away my reference ... */ fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK, "Failed pushing buffer to identity"); /* ... but it should end up being collected on the global buffer list */ fail_unless (g_list_length (buffers) == 1); fail_unless ((GstBuffer *) (g_list_first (buffers)->data) == buffer); ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); /* cleanup */ cleanup_identity (identity); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_gdouble_to_guint64() { gdouble from[] = { 0., 1., 100., 10000., 9223372036854775808., 9223372036854775809., 13835058055282163712. }; guint64 to[] = { 0, 1, 100, 10000, (guint64) (1) << 63, ((guint64) (1) << 63) + 1, ((guint64) (1) << 63) + (G_GINT64_CONSTANT (1) << 62) }; guint64 tolerance[] = { 0, 0, 0, 0, 0, 1, 1 }; gint i; gdouble result; guint64 delta; xmlfile = "gstutils_test_gdouble_to_guint64"; std_log(LOG_FILENAME_LINE, "Test Started gstutils_test_gdouble_to_guint64"); for (i = 0; i < G_N_ELEMENTS (from); ++i) { result = gst_util_gdouble_to_guint64 (from[i]); delta = ABS (to[i] - result); fail_unless (delta <= tolerance[i], "Could not convert %f: %" G_GUINT64_FORMAT " -> %d, got %d instead, delta of %e with tolerance of %e", i, from[i], to[i], result, delta, tolerance[i]); } std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_value_collection() { GstBuffer *buf = NULL; MyFoo *foo; xmlfile = "gstminiobject_test_value_collection"; std_log(LOG_FILENAME_LINE, "Test Started test_value_collection"); foo = (MyFoo *) g_object_new (my_foo_get_type (), NULL); /* test g_object_get() refcounting */ g_object_get (foo, "buffer", &buf, NULL); g_assert (GST_IS_BUFFER (buf)); g_assert (GST_MINI_OBJECT_REFCOUNT_VALUE (GST_MINI_OBJECT_CAST (buf)) == 1); gst_buffer_unref (buf); /* test g_object_set() refcounting */ buf = gst_buffer_new_and_alloc (1024); g_object_set (foo, "buffer", buf, NULL); g_assert (GST_MINI_OBJECT_REFCOUNT_VALUE (GST_MINI_OBJECT_CAST (buf)) == 1); gst_buffer_unref (buf); g_object_unref (foo); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
int main (int argc, char *argv[]) { GstElement *pipeline; GstElement *source, *filter, *sink; xmlfile = "test_elementlink"; std_log(LOG_FILENAME_LINE, "Test Started element link"); /* init */ gst_init (&argc, &argv); /* create pipeline */ pipeline = gst_pipeline_new ("my-pipeline"); /* create elements */ source = gst_element_factory_make ("fakesrc", "source"); filter = gst_element_factory_make ("identity", "filter"); sink = gst_element_factory_make ("fakesink", "sink"); /* must add elements to pipeline before linking them */ gst_bin_add_many (GST_BIN (pipeline), source, filter, sink, NULL); /* link */ if (!gst_element_link_many (source, filter, sink, NULL)) { g_warning ("Failed to link elements!"); } std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); /*** block b from ../../../docs/manual/basics-elements.xml ***/ return 0; /*** block c from ../../../docs/manual/basics-elements.xml ***/ }
void test_no_clients() { GstElement *sink; GstBuffer *buffer; GstCaps *caps; std_log(LOG_FILENAME_LINE, "Test Started test_no_clients"); sink = setup_multifdsink (); ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC); caps = gst_caps_from_string ("application/x-gst-check"); buffer = gst_buffer_new_and_alloc (4); gst_buffer_set_caps (buffer, caps); gst_caps_unref (caps); fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK); GST_DEBUG ("cleaning up multifdsink"); ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS); //commented bz..select() blocks indefinitly cleanup_multifdsink (sink); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_refcounts() { GstNetTimeProvider *ntp; GstClock *clock; xmlfile = "test_refcounts"; std_log(LOG_FILENAME_LINE, "Test Started test_refcounts"); clock = gst_system_clock_obtain (); fail_unless (clock != NULL, "failed to get system clock"); /* one for gstreamer, one for us */ ASSERT_OBJECT_REFCOUNT (clock, "system clock", 2); ntp = gst_net_time_provider_new (clock, NULL, 0); fail_unless (ntp != NULL, "failed to create net time provider"); /* one for ntp, one for gstreamer, one for us */ ASSERT_OBJECT_REFCOUNT (clock, "system clock", 3); /* one for us */ ASSERT_OBJECT_REFCOUNT (ntp, "net time provider", 1); gst_object_unref (ntp); ASSERT_OBJECT_REFCOUNT (clock, "net time provider", 2); gst_object_unref (clock); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_is_writable() { GstBuffer *buffer; GstMiniObject *mobj; xmlfile = "gstminiobject_test_is_writable"; std_log(LOG_FILENAME_LINE, "Test Started test_is_writable"); buffer = gst_buffer_new_and_alloc (4); mobj = GST_MINI_OBJECT (buffer); fail_unless (gst_mini_object_is_writable (mobj), "A buffer with one ref should be writable"); GST_MINI_OBJECT_FLAG_SET (mobj, GST_MINI_OBJECT_FLAG_READONLY); fail_if (gst_mini_object_is_writable (mobj), "A buffer with READONLY set should not be writable"); GST_MINI_OBJECT_FLAG_UNSET (mobj, GST_MINI_OBJECT_FLAG_READONLY); fail_unless (gst_mini_object_is_writable (mobj), "A buffer with one ref and READONLY not set should be writable"); fail_if (gst_mini_object_ref (mobj) == NULL, "Could not ref the mobj"); fail_if (gst_mini_object_is_writable (mobj), "A buffer with two refs should not be writable"); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_make_writable() { GstBuffer *buffer; GstMiniObject *mobj, *mobj2, *mobj3; xmlfile = "gstminiobject_test_make_writable"; std_log(LOG_FILENAME_LINE, "Test Started test_make_writable"); buffer = gst_buffer_new_and_alloc (4); mobj = GST_MINI_OBJECT (buffer); mobj2 = gst_mini_object_make_writable (mobj); fail_unless (GST_IS_BUFFER (mobj2), "make_writable did not return a buffer"); fail_unless (mobj == mobj2, "make_writable returned a copy for a buffer with refcount 1"); mobj2 = gst_mini_object_ref (mobj); mobj3 = gst_mini_object_make_writable (mobj); fail_unless (GST_IS_BUFFER (mobj3), "make_writable did not return a buffer"); fail_if (mobj == mobj3, "make_writable returned same object for a buffer with refcount > 1"); fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (mobj) == 1, "refcount of original mobj object should be back to 1"); mobj2 = gst_mini_object_make_writable (mobj); fail_unless (GST_IS_BUFFER (mobj2), "make_writable did not return a buffer"); fail_unless (mobj == mobj2, "make_writable returned a copy for a buffer with refcount 1"); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_no_lock() { GstTask *t; gboolean ret; //xmlfile = "test_no_lock"; std_log(LOG_FILENAME_LINE, "Test Started test_no_lock"); t = gst_task_create (task_func, NULL); fail_if (t == NULL); TEST_ASSERT_FAIL /* stop should be possible without lock */ gst_task_stop (t); /* pause should give a warning */ ASSERT_WARNING (ret = gst_task_pause (t)); //b failing fail_unless (ret == FALSE); TEST_ASSERT_FAIL /* start should give a warning */ ASSERT_WARNING (ret = gst_task_start (t)); fail_unless (ret == FALSE); TEST_ASSERT_FAIL /* stop should be possible without lock */ gst_task_stop (t); gst_object_unref (t); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_flags() { GstElement *element; GError *err = NULL; xmlfile = "test_flags"; std_log(LOG_FILENAME_LINE, "Test Started test_flags"); /* avoid misleading 'no such element' error debug messages when using cvs */ if (!g_getenv ("GST_DEBUG")) gst_debug_set_default_threshold (GST_LEVEL_NONE); /* default behaviour is to return any already constructed bins/elements */ element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL, 0, &err); fail_unless (err != NULL, "expected error"); fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); fail_unless (element != NULL, "expected partial pipeline/element"); g_error_free (err); err = NULL; gst_object_unref (element); /* test GST_PARSE_FLAG_FATAL_ERRORS */ element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL, GST_PARSE_FLAG_FATAL_ERRORS, &err); fail_unless (err != NULL, "expected error"); fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); g_error_free (err); err = NULL; std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_without_implements_interface() { GstElement *element; std_log(LOG_FILENAME_LINE, "Test Started test_without_implements_interface"); /* we shouldn't crash if someone tries to use * gst_element_implements_interface() on an element which doesn't implement * the GstImplementsInterface (neither if the element does implement the * requested interface, nor if it doesn't) */ element = gst_element_factory_make ("filesrc", "filesrc"); fail_unless (element != NULL, "Could not create filesrc element"); /* does not implement GstImplementsInterface, but does implement the * GstUriHandler interface, so should just return TRUE */ fail_if (!gst_element_implements_interface (element, GST_TYPE_URI_HANDLER)); fail_if (gst_element_implements_interface (element, GST_TYPE_IMPLEMENTS_INTERFACE)); gst_object_unref (element); element = gst_element_factory_make ("identity", "identity"); fail_unless (element != NULL, "Could not create identity element"); fail_if (gst_element_implements_interface (element, GST_TYPE_URI_HANDLER)); fail_if (gst_element_implements_interface (element, GST_TYPE_IMPLEMENTS_INTERFACE)); gst_object_unref (element); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_parse_launch_errors() { GstElement *pipe; GError *err; const gchar *arr[] = { "fakesrc", "fakesink", NULL }; std_log(LOG_FILENAME_LINE, "Test started test_parse_launch_errors"); err = NULL; pipe = gst_parse_launch ("fakesrc ! fakesink", &err); fail_unless (err != NULL, "expected an error, but did not get one"); fail_unless (pipe == NULL, "got pipeline, but expected NULL"); fail_unless (err->domain == GST_CORE_ERROR); fail_unless (err->code == GST_CORE_ERROR_DISABLED); g_error_free (err); err = NULL; pipe = gst_parse_bin_from_description ("fakesrc ! fakesink", TRUE, &err); fail_unless (err != NULL, "expected an error, but did not get one"); fail_unless (pipe == NULL, "got pipeline, but expected NULL"); fail_unless (err->domain == GST_CORE_ERROR); fail_unless (err->code == GST_CORE_ERROR_DISABLED); g_error_free (err); err = NULL; pipe = gst_parse_launchv (arr, &err); fail_unless (err != NULL, "expected an error, but did not get one"); fail_unless (pipe == NULL, "got pipeline, but expected NULL"); fail_unless (err->domain == GST_CORE_ERROR); fail_unless (err->code == GST_CORE_ERROR_DISABLED); g_error_free (err); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_unref_threaded() { GstBuffer *buffer; GstMiniObject *mobj; int i; xmlfile = "gstminiobject_test_unref_threaded"; std_log(LOG_FILENAME_LINE, "Test Started test_unref_threaded"); buffer = gst_buffer_new_and_alloc (4); mobj = GST_MINI_OBJECT (buffer); for (i = 0; i < num_threads * refs_per_thread; ++i) gst_mini_object_ref (mobj); MAIN_START_THREADS (num_threads, thread_unref, mobj); MAIN_STOP_THREADS (); ASSERT_MINI_OBJECT_REFCOUNT (mobj, "miniobject", 1); /* final unref */ gst_mini_object_unref (mobj); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }