[Spice-commits] 2 commits - server/tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jul 12 19:06:01 UTC 2020


 server/tests/test-gst.cpp |   30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

New commits:
commit 65d7d24f21f0f8c5c43c9bbdc359c5aed524c1af
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Thu Jun 25 09:09:45 2020 +0100

    test-gst: Handle better errors from callback
    
    Exit more cleanly, otherwise sometimes some strange failures
    occurs. This is due to the fact that a thread is cleaning up
    everything while the others are still working.
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Uri Lublin <ulublin at redhat.com>

diff --git a/server/tests/test-gst.cpp b/server/tests/test-gst.cpp
index a9b466f2..38a20889 100644
--- a/server/tests/test-gst.cpp
+++ b/server/tests/test-gst.cpp
@@ -120,7 +120,7 @@ gst_buffer_new_wrapped_full(int flags SPICE_GNUC_UNUSED, gpointer data, gsize ma
 #define BGRx_CAPS "caps=video/x-raw,format=BGRx"
 #endif
 
-typedef void (*SampleProc)(GstSample *sample, void *param);
+typedef GstFlowReturn (*SampleProc)(GstSample *sample, void *param);
 
 typedef struct {
     GstAppSrc *appsrc;
@@ -166,6 +166,9 @@ static pthread_cond_t eos_cond = PTHREAD_COND_INITIALIZER;
 static gdouble minimum_psnr = 25;
 static uint64_t starting_bit_rate = 3000000;
 
+// error to return from main()
+static int global_test_error = 0;
+
 static void compute_clipping_rect(GstSample *sample);
 static void parse_clipping(const char *clipping);
 static TestFrame *gst_to_spice_frame(GstSample *sample);
@@ -187,7 +190,7 @@ static double compute_psnr(SpiceBitmap *bitmap1, int32_t x1, int32_t y1,
                            int32_t w, int32_t h);
 
 // handle output frames from input pipeline
-static void
+static GstFlowReturn
 input_frames(GstSample *sample, void *param)
 {
     unsigned curr_frame_index = input_frame_index++;
@@ -251,10 +254,11 @@ input_frames(GstSample *sample, void *param)
     // TODO call client_stream_report to simulate this report from the client
 
     frame_unref(frame);
+    return GST_FLOW_OK;
 }
 
 // handle output frames from output pipeline
-static void
+static GstFlowReturn
 output_frames(GstSample *sample, void *param)
 {
     TestFrame *curr_frame = gst_to_spice_frame(sample);
@@ -266,7 +270,7 @@ output_frames(GstSample *sample, void *param)
     pthread_mutex_unlock(&frame_queue_mtx);
     if (!expected_frame) {
         g_printerr("Frame not present in the queue but arrived in output!\n");
-        exit(1);
+        return GST_FLOW_EOS;
     }
 
     // TODO try to understand if this is correct
@@ -287,11 +291,12 @@ output_frames(GstSample *sample, void *param)
     // check is more or less the same
     if (psnr < minimum_psnr) {
         g_printerr("Frame PSNR too low, got %g minimum %g\n", psnr, minimum_psnr);
-        exit(1);
+        return GST_FLOW_EOS;
     }
 
     frame_unref(expected_frame);
     frame_unref(curr_frame);
+    return GST_FLOW_OK;
 }
 
 static const EncoderInfo encoder_infos[] = {
@@ -448,7 +453,7 @@ int main(int argc, char *argv[])
     g_free(clipping);
     g_option_context_free(context);
 
-    return 0;
+    return global_test_error;
 }
 
 static void
@@ -559,13 +564,17 @@ static GstFlowReturn
 new_sample(GstAppSink *gstappsink, gpointer test_pipeline)
 {
     TestPipeline *pipeline = (TestPipeline*) test_pipeline;
+    GstFlowReturn res = GST_FLOW_OK;
 
     GstSample *sample = gst_app_sink_pull_sample(pipeline->appsink);
     if (sample) {
-        pipeline->sample_proc(sample, pipeline->sample_param);
+        res = pipeline->sample_proc(sample, pipeline->sample_param);
+        if (res != GST_FLOW_OK) {
+            global_test_error = 1;
+        }
         gst_sample_unref(sample);
     }
-    return GST_FLOW_OK;
+    return res;
 }
 
 static GstBusSyncReply
commit 1cd063d5fe4f9c86c6d80fe4b063f7646c95f2ef
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Apr 11 06:40:54 2017 +0100

    test-gst: Returns specific error if encoder is not supported
    
    This allows to detect missing required system packages.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <ulublin at redhat.com>

diff --git a/server/tests/test-gst.cpp b/server/tests/test-gst.cpp
index 3a2f667e..a9b466f2 100644
--- a/server/tests/test-gst.cpp
+++ b/server/tests/test-gst.cpp
@@ -739,8 +739,9 @@ create_video_encoder(const EncoderInfo *encoder)
 
     video_encoder = encoder->new_encoder(encoder->coded_type, starting_bit_rate, &rate_control_cbs,
                                          (bitmap_ref_t) frame_ref, (bitmap_unref_t) frame_unref);
-    // TODO return not supported error
-    spice_assert(video_encoder);
+    if (video_encoder == NULL) {
+        exit(123);
+    }
 }
 
 static void


More information about the Spice-commits mailing list