[Spice-commits] 3 commits - server/tests

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Sep 12 12:09:28 UTC 2017


 server/tests/test-gst.c |   56 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 17 deletions(-)

New commits:
commit 14828bfdfc5c93a10e04804546bd88666c9504e9
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Sep 10 17:03:11 2017 +0100

    test-gst: Free pipelines
    
    Pipelines are never freed.
    These are detected as leaks by leak detector tools like address sanitizer.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/tests/test-gst.c b/server/tests/test-gst.c
index 302158a2..69633e39 100644
--- a/server/tests/test-gst.c
+++ b/server/tests/test-gst.c
@@ -172,6 +172,7 @@ static TestFrame *gst_to_spice_frame(GstSample *sample);
 static void bitmap_free(SpiceBitmap *bitmap);
 static void frame_ref(TestFrame *frame);
 static void frame_unref(TestFrame *frame);
+static void pipeline_free(TestPipeline *pipeline);
 static void pipeline_send_raw_data(TestPipeline *pipeline, VideoBuffer *buffer);
 static void pipeline_wait_eos(TestPipeline *pipeline);
 static void create_input_pipeline(const char *input_pipeline,
@@ -438,6 +439,9 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
+    pipeline_free(input_pipeline);
+    pipeline_free(output_pipeline);
+
     g_free(encoder_name);
     g_free(image_format);
     g_free(input_pipeline_desc);
@@ -619,6 +623,17 @@ create_pipeline(const char *desc, SampleProc sample_proc, void *param)
 }
 
 static void
+pipeline_free(TestPipeline *pipeline)
+{
+    if (pipeline->appsrc) {
+        gst_object_unref(pipeline->appsrc);
+    }
+    gst_object_unref(pipeline->appsink);
+    gst_object_unref(pipeline->gst_pipeline);
+    free(pipeline);
+}
+
+static void
 create_output_pipeline(const EncoderInfo *encoder, SampleProc sample_proc, void *param)
 {
     gchar *desc =
commit 9bb2388f757a51a97eb3bb2f8bb096fe85c8fa4f
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Sep 1 07:04:37 2017 +0100

    test-gst: Remove options parsing leaks
    
    Command line options are not freed at the end of the program.
    These are detected as leaks by leak detector tools like address sanitizer.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/tests/test-gst.c b/server/tests/test-gst.c
index 40f738d7..302158a2 100644
--- a/server/tests/test-gst.c
+++ b/server/tests/test-gst.c
@@ -296,6 +296,7 @@ output_frames(GstSample *sample, void *param)
 static const EncoderInfo encoder_infos[] = {
     { "mjpeg", mjpeg_encoder_new, SPICE_VIDEO_CODEC_TYPE_MJPEG,
       "caps=image/jpeg", "jpegdec" },
+#define encoder_info_mjpeg (&encoder_infos[0])
     { "gstreamer:mjpeg", gstreamer_encoder_new, SPICE_VIDEO_CODEC_TYPE_MJPEG,
       "caps=image/jpeg", "jpegdec" },
     { "gstreamer:vp8",   gstreamer_encoder_new, SPICE_VIDEO_CODEC_TYPE_VP8,
@@ -314,11 +315,11 @@ static const EncoderInfo encoder_infos[] = {
 int main(int argc, char *argv[])
 {
     gchar *input_pipeline_desc = NULL;
-    const gchar *image_format = "32BIT";
-    const gchar *encoder_name = "mjpeg";
+    gchar *image_format = NULL;
+    gchar *encoder_name = NULL;
     gchar *file_report_name = NULL;
     gboolean use_hw_encoder = FALSE; // TODO use
-    const gchar *clipping = "(0,0)x(100%,100%)";
+    gchar *clipping = NULL;
 
     // - input pipeline
     // - top/down
@@ -368,19 +369,24 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
-    const EncoderInfo *encoder = get_encoder_info(encoder_name);
-    if (!encoder) {
-        g_printerr("Encoder name unsupported: %s\n", encoder_name);
-        exit(1);
+    const EncoderInfo *encoder = encoder_info_mjpeg;
+    if (encoder_name != NULL) {
+        encoder = get_encoder_info(encoder_name);
+        if (!encoder) {
+            g_printerr("Encoder name unsupported: %s\n", encoder_name);
+            exit(1);
+        }
     }
 
-    bitmap_format = get_bitmap_format(image_format);
-    if (bitmap_format == SPICE_BITMAP_FMT_INVALID) {
-        g_printerr("Invalid image format: %s\n", image_format);
-        exit(1);
+    if (image_format != NULL) {
+        bitmap_format = get_bitmap_format(image_format);
+        if (bitmap_format == SPICE_BITMAP_FMT_INVALID) {
+            g_printerr("Invalid image format: %s\n", image_format);
+            exit(1);
+        }
     }
 
-    parse_clipping(clipping);
+    parse_clipping(clipping ? clipping : "(0,0)x(100%,100%)");
 
     if (minimum_psnr < 0) {
         g_printerr("Invalid PSNR specified %f\n", minimum_psnr);
@@ -432,6 +438,12 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
+    g_free(encoder_name);
+    g_free(image_format);
+    g_free(input_pipeline_desc);
+    g_free(clipping);
+    g_option_context_free(context);
+
     return 0;
 }
 
commit f35843ee6f44518d07431e9507c2d26ef1cfd170
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Sep 1 07:04:16 2017 +0100

    test-gst: Remove useless check
    
    encoder_name is never NULL as already initialized with "mjpeg" value.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/tests/test-gst.c b/server/tests/test-gst.c
index d4ebaacf..40f738d7 100644
--- a/server/tests/test-gst.c
+++ b/server/tests/test-gst.c
@@ -368,11 +368,6 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
-    if (!encoder_name) {
-        g_printerr("Encoder name option missing\n");
-        exit(1);
-    }
-
     const EncoderInfo *encoder = get_encoder_info(encoder_name);
     if (!encoder) {
         g_printerr("Encoder name unsupported: %s\n", encoder_name);


More information about the Spice-commits mailing list