gst-plugins-base: tests: add ogg test file and some proper unit tests for discoverer

Tim Müller tpm at kemper.freedesktop.org
Sat Jan 7 08:46:24 PST 2012


Module: gst-plugins-base
Branch: master
Commit: aa16155172c2c73b05bd6509010f1a52b5b81022
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=aa16155172c2c73b05bd6509010f1a52b5b81022

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Sat Jan  7 16:43:26 2012 +0000

tests: add ogg test file and some proper unit tests for discoverer

Leaks when re-used, so blacklisted for valgrind for now.

---

 tests/check/Makefile.am       |    1 +
 tests/check/libs/discoverer.c |   68 ++++++++++++++++++++++++++++++++++++++++-
 tests/files/Makefile.am       |    3 +-
 tests/files/theora-vorbis.ogg |  Bin 0 -> 20070 bytes
 4 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 3280ba3..ad9cafa 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -167,6 +167,7 @@ check_PROGRAMS = \
 # ffmpegcolorspace takes too long, so disabled for now
 VALGRIND_TO_FIX = \
 	elements/ffmpegcolorspace \
+	libs/discoverer \
 	libs/video
 
 # these tests don't even pass
diff --git a/tests/check/libs/discoverer.c b/tests/check/libs/discoverer.c
index 2d20576..a8de512 100644
--- a/tests/check/libs/discoverer.c
+++ b/tests/check/libs/discoverer.c
@@ -52,7 +52,8 @@ GST_START_TEST (test_disco_sync)
   GstDiscovererResult result;
   gchar *uri;
 
-  dc = gst_discoverer_new (GST_SECOND, &err);
+  /* high timeout, in case we're running under valgrind */
+  dc = gst_discoverer_new (5 * GST_SECOND, &err);
   fail_unless (dc != NULL);
   fail_unless (err == NULL);
 
@@ -78,6 +79,68 @@ GST_START_TEST (test_disco_sync)
 
 GST_END_TEST;
 
+static void
+test_disco_sync_reuse (const gchar * test_fn, guint num, GstClockTime timeout)
+{
+  GError *err = NULL;
+  GstDiscoverer *dc;
+  GstDiscovererInfo *info;
+  GstDiscovererResult result;
+  gchar *uri, *path;
+  int i;
+
+  dc = gst_discoverer_new (timeout, &err);
+  fail_unless (dc != NULL);
+  fail_unless (err == NULL);
+
+  /* GST_TEST_FILE comes from makefile CFLAGS */
+  path = g_build_filename (GST_TEST_FILES_PATH, test_fn, NULL);
+  uri = gst_filename_to_uri (path, &err);
+  g_free (path);
+  fail_unless (err == NULL);
+
+  for (i = 0; i < num; ++i) {
+    GST_INFO ("[%02d] discovering uri '%s'", i, uri);
+    info = gst_discoverer_discover_uri (dc, uri, &err);
+    if (info) {
+      result = gst_discoverer_info_get_result (info);
+      GST_INFO ("result: %d", result);
+      gst_discoverer_info_unref (info);
+    }
+    /* in case we don't have some of the elements needed */
+    if (err) {
+      g_error_free (err);
+      err = NULL;
+    }
+  }
+  g_free (uri);
+
+  g_object_unref (dc);
+}
+
+GST_START_TEST (test_disco_sync_reuse_ogg)
+{
+  test_disco_sync_reuse ("theora-vorbis.ogg", 2, 10 * GST_SECOND);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_disco_sync_reuse_mp3)
+{
+  /* this will cause errors because -base doesn't do mp3 parsing or decoding */
+  test_disco_sync_reuse ("test.mp3", 3, 10 * GST_SECOND);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_disco_sync_reuse_timeout)
+{
+  /* set minimum timeout to test that, esp. leakage under valgrind */
+  /* FIXME: should really be even shorter */
+  test_disco_sync_reuse ("theora-vorbis.ogg", 2, GST_SECOND);
+}
+
+GST_END_TEST;
 
 static Suite *
 discoverer_suite (void)
@@ -88,6 +151,9 @@ discoverer_suite (void)
   suite_add_tcase (s, tc_chain);
   tcase_add_test (tc_chain, test_disco_init);
   tcase_add_test (tc_chain, test_disco_sync);
+  tcase_add_test (tc_chain, test_disco_sync_reuse_ogg);
+  tcase_add_test (tc_chain, test_disco_sync_reuse_mp3);
+  tcase_add_test (tc_chain, test_disco_sync_reuse_timeout);
   return s;
 }
 
diff --git a/tests/files/Makefile.am b/tests/files/Makefile.am
index 9556f5e..99b043f 100644
--- a/tests/files/Makefile.am
+++ b/tests/files/Makefile.am
@@ -3,4 +3,5 @@ EXTRA_DIST = \
 	hls.m3u8 \
 	license-uris \
 	partialframe.mjpeg \
-	test.mp3
+	test.mp3 \
+	theora-vorbis.ogg
diff --git a/tests/files/theora-vorbis.ogg b/tests/files/theora-vorbis.ogg
new file mode 100644
index 0000000..ab635cc
Binary files /dev/null and b/tests/files/theora-vorbis.ogg differ



More information about the gstreamer-commits mailing list