validate: Add a check-position action type
authorThibault Saunier <tsaunier@igalia.com>
Sat, 25 Apr 2020 03:33:16 +0000 (23:33 -0400)
committerThibault Saunier <tsaunier@igalia.com>
Mon, 27 Apr 2020 21:00:12 +0000 (17:00 -0400)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/182>

validate/gst/validate/gst-validate-scenario.c

index 0e0dba21140cf3404c046f5f3ca62f3e5d2249f1..c6a64bb27e94abf8dc2b31d3ddac052dd43611e0 100644 (file)
@@ -2610,6 +2610,43 @@ _find_elements_defined_in_action (GstValidateScenario * scenario,
   return targets;
 }
 
+static GstValidateExecuteActionReturn
+_execute_check_position (GstValidateScenario * scenario,
+    GstValidateAction * action)
+{
+  GstClockTime expected_pos, pos;
+
+  if (!gst_validate_action_get_clocktime (scenario, action,
+          "expected-position", &expected_pos)) {
+    GST_VALIDATE_REPORT_ACTION (scenario, action,
+        SCENARIO_ACTION_EXECUTION_ERROR,
+        "Could not retrieve expected position in: %" GST_PTR_FORMAT,
+        action->structure);
+
+    return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED;
+  }
+
+  if (!_get_position (scenario, NULL, &pos)) {
+    GST_VALIDATE_REPORT_ACTION (scenario, action,
+        SCENARIO_ACTION_EXECUTION_ERROR, "Could not get pipeline position");
+
+    return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED;
+  }
+
+  if (pos != expected_pos) {
+    GST_VALIDATE_REPORT_ACTION (scenario, action,
+        SCENARIO_ACTION_EXECUTION_ERROR,
+        "Pipeline position doesn't match expectations"
+        " got %" GST_TIME_FORMAT " instead of %" GST_TIME_FORMAT,
+        GST_TIME_ARGS (pos), GST_TIME_ARGS (expected_pos));
+
+    return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED;
+  }
+
+  return GST_VALIDATE_EXECUTE_ACTION_OK;
+
+}
+
 static GstValidateExecuteActionReturn
 _execute_set_or_check_property (GstValidateScenario * scenario,
     GstValidateAction * action)
@@ -6020,6 +6057,16 @@ register_action_types (void)
         {NULL}
       }),
       "Request a video key unit", FALSE);
+
+  REGISTER_ACTION_TYPE("check-position", _execute_check_position,
+      ((GstValidateActionParameter[]) {
+          { .name = "expected-position",
+              .description = "The expected pipeline position",
+              .mandatory = TRUE,
+              .types = "GstClockTime",
+              NULL },
+      }),
+      "Check current pipeline position.\n", GST_VALIDATE_ACTION_TYPE_NONE);
   /*  *INDENT-ON* */
 }