I'm not sure about GStreamer 0.10, which is what I assume this question is about given its age. But for anyone writing a plugin for GStreamer 1.0, here is a very simple unit test suite that utilizes GStreamer's built-in Check framework and the GstCheck module:
// This header will include some GStreamer-specific test utilities, as well as
// the internal Check API
#include <gst/check/gstcheck.h>
// Surround your tests with the GST_START_TEST and GST_END_TEST macros, then
// use the GstCheck and Check APIs
GST_START_TEST(my_test)
{
ck_assert(0);
}
GST_END_TEST;
// This is a suite initialization function where you should register your tests.
// It must end with "_suite" and traditionally starts with your plugin's
// namespace.
Suite *gst_myplugin_suite(void) {
Suite *s = suite_create("GstMyPlugin");
TCase *tc = tcase_create("general");
tcase_add_test(tc, my_test);
// Add more tests with tcase_add_test(tc, test_function_name)
suite_add_tcase(s, tc);
return s;
}
// This generates an entry point that executes your test suite. The argument
// should be the name of your suite intialization function without "_suite".
GST_CHECK_MAIN(gst_myplugin);
When building your test, you need to link with your plugin* and the gstcheck-1.0
library. Using pkg-config
can make things easier:
gcc -o gstmyplugintests `pkg-config --cflags --libs gstreamer-check-1.0` gstmyplugin.so gstmyplugintests.c
When running your tests, remember to tell GStreamer where to look for your plugin:
GST_PLUGIN_PATH=. ./gstmyplugintests
That should be all there is to it!
* Edit: Actually, you only need to link with your plugin if your tests access its internal data structures and functions.