[0.11] gst-plugins-bad: tests: remove temporary files when done in camerabin, camerabin2 and jifmux tests

Sebastian Dröge slomo at kemper.freedesktop.org
Tue Jan 10 06:50:49 PST 2012


Module: gst-plugins-bad
Branch: 0.11
Commit: 3c69286db9711db590670fbd9db2a4a9a19035b8
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=3c69286db9711db590670fbd9db2a4a9a19035b8

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Wed Jan  4 18:42:57 2012 +0000

tests: remove temporary files when done in camerabin, camerabin2 and jifmux tests

---

 tests/check/elements/camerabin.c  |   20 ++++++++++++++++++++
 tests/check/elements/camerabin2.c |   28 +++++++++++++++++++++++++++-
 tests/check/elements/jifmux.c     |    3 +++
 3 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/tests/check/elements/camerabin.c b/tests/check/elements/camerabin.c
index 53a82e9..ce17ac3 100644
--- a/tests/check/elements/camerabin.c
+++ b/tests/check/elements/camerabin.c
@@ -26,6 +26,7 @@
 
 #include <unistd.h>
 #include <glib.h>
+#include <glib/gstdio.h>
 #include <gst/gst.h>
 #include <gst/check/gstcheck.h>
 #include <gst/interfaces/photography.h>
@@ -501,6 +502,16 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist)
   return TRUE;
 }
 
+static void
+remove_file (const gchar * fn_template, guint num)
+{
+  const gchar *fn;
+
+  fn = make_test_file_name (fn_template, num);
+  GST_INFO ("removing %s", fn);
+  g_unlink (fn);
+}
+
 GST_START_TEST (test_single_image_capture)
 {
   gboolean ready = FALSE;
@@ -544,6 +555,7 @@ GST_START_TEST (test_single_image_capture)
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
 
   check_file_validity (SINGLE_IMAGE_FILENAME, 0, NULL);
+  remove_file (SINGLE_IMAGE_FILENAME, 0);
 }
 
 GST_END_TEST;
@@ -568,6 +580,7 @@ GST_START_TEST (test_single_image_capture_with_flags)
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
 
   check_file_validity (SINGLE_IMAGE_WITH_FLAGS_FILENAME, 0, NULL);
+  remove_file (SINGLE_IMAGE_WITH_FLAGS_FILENAME, 0);
 }
 
 GST_END_TEST;
@@ -617,6 +630,7 @@ GST_START_TEST (test_video_recording)
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
 
   check_file_validity (VIDEO_WITH_FLAGS_FILENAME, 0, NULL);
+  remove_file (VIDEO_WITH_FLAGS_FILENAME, 0);
 }
 
 GST_END_TEST;
@@ -653,6 +667,7 @@ GST_START_TEST (test_video_recording_with_flags)
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
 
   check_file_validity (VIDEO_FILENAME, 0, NULL);
+  remove_file (VIDEO_FILENAME, 0);
 }
 
 GST_END_TEST;
@@ -704,6 +719,7 @@ GST_START_TEST (test_video_recording_pause)
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
 
   check_file_validity (VIDEO_PAUSE_FILENAME, 0, NULL);
+  remove_file (VIDEO_PAUSE_FILENAME, 0);
 }
 
 GST_END_TEST;
@@ -740,6 +756,7 @@ GST_START_TEST (test_video_recording_no_audio)
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
 
   check_file_validity (VIDEO_NOAUDIO_FILENAME, 0, NULL);
+  remove_file (VIDEO_NOAUDIO_FILENAME, 0);
 }
 
 GST_END_TEST;
@@ -767,7 +784,9 @@ GST_START_TEST (test_image_video_cycle)
   /* validate all the files */
   for (i = 2; i > 0; i--) {
     check_file_validity (CYCLE_IMAGE_FILENAME, i, NULL);
+    remove_file (CYCLE_IMAGE_FILENAME, i);
     check_file_validity (CYCLE_VIDEO_FILENAME, i, NULL);
+    remove_file (CYCLE_VIDEO_FILENAME, i);
   }
 }
 
@@ -796,6 +815,7 @@ GST_START_TEST (test_image_tags_setting)
   for (i = 0; i < SEQUENTIAL_IMAGES_COUNT; i++) {
     check_file_validity (SEQUENTIAL_IMAGES_FILENAME, i,
         taglists[i % TAGLISTS_COUNT]);
+    remove_file (SEQUENTIAL_IMAGES_FILENAME, i);
   }
 }
 
diff --git a/tests/check/elements/camerabin2.c b/tests/check/elements/camerabin2.c
index f39e4aa..9ae219a 100644
--- a/tests/check/elements/camerabin2.c
+++ b/tests/check/elements/camerabin2.c
@@ -27,6 +27,7 @@
 
 #include <unistd.h>
 #include <glib.h>
+#include <glib/gstdio.h>
 #include <gst/gst.h>
 #include <gst/video/video.h>
 #include <gst/check/gstcheck.h>
@@ -434,8 +435,9 @@ teardown (void)
   tags_found = NULL;
 
   g_free (video_filename);
-  g_free (image_filename);
   video_filename = NULL;
+
+  g_free (image_filename);
   image_filename = NULL;
 
   GST_INFO ("done");
@@ -569,6 +571,16 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist,
   return TRUE;
 }
 
+static void
+remove_file (const gchar * fn_template, guint num)
+{
+  const gchar *fn;
+
+  fn = make_const_file_name (fn_template, num);
+  GST_INFO ("removing %s", fn);
+  g_unlink (fn);
+}
+
 static gboolean
 filter_buffer_count (GstPad * pad, GstMiniObject * obj, gpointer data)
 {
@@ -676,6 +688,7 @@ GST_START_TEST (test_single_image_capture)
   wait_for_idle_state ();
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
   check_file_validity (image_filename, 0, NULL, 0, 0, NO_AUDIO);
+  remove_file (image_filename, 0);
 }
 
 GST_END_TEST;
@@ -730,6 +743,7 @@ GST_START_TEST (test_multiple_image_captures)
   for (i = 0; i < 3; i++) {
     check_file_validity (image_filename, i, NULL, widths[i], heights[i],
         NO_AUDIO);
+    remove_file (image_filename, i);
   }
 }
 
@@ -779,6 +793,8 @@ GST_START_TEST (test_single_video_recording)
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
 
   check_file_validity (video_filename, 0, NULL, 0, 0, WITH_AUDIO);
+  remove_file (video_filename, 0);
+
 }
 
 GST_END_TEST;
@@ -850,6 +866,7 @@ GST_START_TEST (test_multiple_video_recordings)
   for (i = 0; i < 3; i++) {
     check_file_validity (video_filename, i, NULL, widths[i], heights[i],
         WITH_AUDIO);
+    remove_file (video_filename, i);
   }
 }
 
@@ -914,7 +931,9 @@ GST_START_TEST (test_image_video_cycle)
   /* validate all the files */
   for (i = 0; i < 2; i++) {
     check_file_validity (image_filename, i, NULL, 0, 0, NO_AUDIO);
+    remove_file (image_filename, i);
     check_file_validity (video_filename, i, NULL, 0, 0, WITH_AUDIO);
+    remove_file (video_filename, i);
   }
 }
 
@@ -961,6 +980,7 @@ GST_START_TEST (test_image_capture_previews)
     gst_message_unref (msg);
 
     check_preview_image (camera, image_filename, i);
+    remove_file (image_filename, i);
 
     if (preview_buffer)
       gst_buffer_unref (preview_buffer);
@@ -1040,6 +1060,7 @@ GST_START_TEST (test_image_capture_with_tags)
   for (i = 0; i < 3; i++) {
     check_file_validity (image_filename, i, taglists[i], 0, 0, NO_AUDIO);
     gst_tag_list_free (taglists[i]);
+    remove_file (image_filename, i);
   }
 }
 
@@ -1117,6 +1138,7 @@ GST_START_TEST (test_video_capture_with_tags)
   for (i = 0; i < 3; i++) {
     check_file_validity (video_filename, i, taglists[i], 0, 0, NO_AUDIO);
     gst_tag_list_free (taglists[i]);
+    remove_file (video_filename, i);
   }
 }
 
@@ -1218,6 +1240,7 @@ GST_START_TEST (test_idle_property)
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
 
   check_file_validity (video_filename, 0, NULL, 0, 0, WITH_AUDIO);
+  remove_file (video_filename, 0);
 }
 
 GST_END_TEST;
@@ -1284,6 +1307,7 @@ GST_START_TEST (test_image_custom_filter)
 
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
   check_file_validity (image_filename, 0, NULL, 0, 0, NO_AUDIO);
+  remove_file (image_filename, 0);
 
   fail_unless (vf_probe_counter > 0);
   fail_unless (image_probe_counter == 1);
@@ -1365,6 +1389,7 @@ GST_START_TEST (test_video_custom_filter)
 
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
   check_file_validity (video_filename, 0, NULL, 0, 0, WITH_AUDIO);
+  remove_file (video_filename, 0);
 
   fail_unless (vf_probe_counter > 0);
   fail_unless (video_probe_counter > 0);
@@ -1467,6 +1492,7 @@ GST_START_TEST (test_image_location_switching)
   }
 
   for (i = 0; i < LOCATION_SWITCHING_FILENAMES_COUNT; i++) {
+    g_unlink (filenames[i]);
     g_free (filenames[i]);
   }
   g_signal_handler_disconnect (src, notify_id);
diff --git a/tests/check/elements/jifmux.c b/tests/check/elements/jifmux.c
index 9e21d1a..05e6756 100644
--- a/tests/check/elements/jifmux.c
+++ b/tests/check/elements/jifmux.c
@@ -27,6 +27,8 @@
 #include <stdio.h>
 #include <unistd.h>
 
+#include <glib/gstdio.h>
+
 #include <gst/check/gstcheck.h>
 #include <gst/tag/tag.h>
 
@@ -1200,6 +1202,7 @@ GST_START_TEST (test_jifmux_tags)
       tmpfile);
   libexif_check_tags (FILE_SOURCE_TAG ("transparent-scanner"), tmpfile);
 
+  g_unlink (tmpfile);
   g_free (tmpfile);
 }
 



More information about the gstreamer-commits mailing list