[Tests] Fix tizen capi unit test
authorgichan-jang <gichan2.jang@samsung.com>
Fri, 17 Apr 2020 04:13:06 +0000 (13:13 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 17 Apr 2020 08:44:22 +0000 (17:44 +0900)
Test fails occasionally due to slow speed of arm.
The test was modified to only check if the switch is working.

Signed-off-by: gichan-jang <gichan2.jang@samsung.com>
tests/tizen_capi/unittest_tizen_capi.cc

index 9fe942b..494797e 100644 (file)
@@ -1038,7 +1038,7 @@ TEST (nnstreamer_capi_switch, dummy_01)
   ml_pipeline_switch_e type;
   ml_pipeline_state_e state;
   gchar *pipeline;
-  int status;
+  int status, timeout_count = 0;
   guint *count_sink;
   TestPipeState *pipe_state;
   gchar **node_list = NULL;
@@ -1093,7 +1093,19 @@ TEST (nnstreamer_capi_switch, dummy_01)
   EXPECT_EQ (status, ML_ERROR_NONE);
   wait_for_start (handle, state, status);
 
-  g_usleep (300000); /* 300ms. Let a few frames flow. */
+  /* Waiting for 3 frames to arrive */
+  while (*count_sink < 3) {
+    timeout_count++;
+    g_usleep (10000);
+    if (timeout_count > 100) {
+      EXPECT_TRUE (false);
+      break;
+    }
+  } 
+
+  g_usleep (300000); /* To check if more frames are coming in  */
+
+  EXPECT_EQ (*count_sink, 3U);
 
   status = ml_pipeline_stop (handle);
   EXPECT_EQ (status, ML_ERROR_NONE);
@@ -1107,8 +1119,6 @@ TEST (nnstreamer_capi_switch, dummy_01)
   status = ml_pipeline_destroy (handle);
   EXPECT_EQ (status, ML_ERROR_NONE);
 
-  EXPECT_EQ (*count_sink, 3U);
-
   EXPECT_TRUE (pipe_state->paused);
   EXPECT_TRUE (pipe_state->playing);