summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2015-09-30 14:55:37 +0200
committerThibault Saunier <tsaunier@gnome.org>2015-09-30 14:56:24 +0200
commitf69b63e7491b2c06c9919063a4524c6717007dd3 (patch)
treed2e5530be48361a32c0491bb238b2b639f291ba5
parent67d53d6aad67c55fd71c18ac5fb3c31869b39d89 (diff)
validate:scenario: Add a way to define a timeout for actions execution
Reviewers: Mathieu_Du Differential Revision: https://phabricator.freedesktop.org/D271
-rw-r--r--validate/gst/validate/gst-validate-report.c2
-rw-r--r--validate/gst/validate/gst-validate-report.h1
-rw-r--r--validate/gst/validate/gst-validate-scenario.c34
3 files changed, 31 insertions, 6 deletions
diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c
index ae648d7..ac850a4 100644
--- a/validate/gst/validate/gst-validate-report.c
+++ b/validate/gst/validate/gst-validate-report.c
@@ -322,6 +322,8 @@ gst_validate_report_load_issues (void)
"segment"), NULL);
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_NOT_ENDED,
_("All the actions were not executed before the program stopped"), NULL);
+ REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_TIMEOUT,
+ _("The execution of an action timed out"), NULL);
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_FILE_MALFORMED,
_("The scenario file was malformed"), NULL);
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_EXECUTION_ERROR,
diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h
index d93b526..5a32e97 100644
--- a/validate/gst/validate/gst-validate-report.h
+++ b/validate/gst/validate/gst-validate-report.h
@@ -110,6 +110,7 @@ typedef enum {
#define SCENARIO_NOT_ENDED _QUARK("scenario::not-ended")
#define SCENARIO_FILE_MALFORMED _QUARK("scenario::malformed")
#define SCENARIO_ACTION_EXECUTION_ERROR _QUARK("scenario::execution-error")
+#define SCENARIO_ACTION_TIMEOUT _QUARK("scenario::action-timeout")
#define SCENARIO_ACTION_EXECUTION_ISSUE _QUARK("scenario::execution-issue")
#define G_LOG_ISSUE _QUARK("g-log::issue")
diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c
index 5d4e36f..5ff5d1b 100644
--- a/validate/gst/validate/gst-validate-scenario.c
+++ b/validate/gst/validate/gst-validate-scenario.c
@@ -190,6 +190,9 @@ struct _GstValidateActionPrivate
gboolean executing_last_subaction;
gboolean optional;
+ GstClockTime execution_time;
+ GstClockTime timeout;
+
GWeakRef scenario;
};
@@ -216,6 +219,7 @@ _action_copy (GstValidateAction * act)
copy->action_number = act->action_number;
copy->playback_time = act->playback_time;
+ copy->priv->timeout = act->priv->timeout;
return copy;
}
@@ -265,6 +269,7 @@ gst_validate_action_new (GstValidateScenario * scenario,
gst_validate_action_init (action);
action->playback_time = GST_CLOCK_TIME_NONE;
+ action->priv->timeout = GST_CLOCK_TIME_NONE;
action->type = action_type->name;
action->repeat = -1;
@@ -1163,6 +1168,7 @@ gst_validate_execute_action (GstValidateActionType * action_type,
gst_validate_print_action (action, NULL);
+ action->priv->execution_time = gst_util_get_timestamp ();
res = action_type->execute (action->scenario, action);
if (!gst_structure_has_field (action->structure, "sub-action")) {
@@ -1237,6 +1243,12 @@ _fill_action (GstValidateScenario * scenario, GstValidateAction * action,
GST_INFO_OBJECT (scenario,
"No playback time for action %" GST_PTR_FORMAT, structure);
+ if (!gst_validate_utils_get_clocktime (structure,
+ "timeout", &action->priv->timeout)) {
+ GST_INFO_OBJECT (scenario,
+ "No timeout time for action %" GST_PTR_FORMAT, structure);
+ }
+
if (!(action->name = gst_structure_get_string (structure, "name")))
action->name = "";
@@ -1378,12 +1390,6 @@ execute_next_action (GstValidateScenario * scenario)
return G_SOURCE_CONTINUE;
}
- /* TODO what about non flushing seeks? */
- if (priv->last_seek && priv->target_state > GST_STATE_READY) {
- GST_LOG_OBJECT (scenario, "Still seeking -- not executing action");
- return G_SOURCE_CONTINUE;
- }
-
if (scenario->priv->actions)
act = scenario->priv->actions->data;
@@ -1405,6 +1411,21 @@ execute_next_action (GstValidateScenario * scenario)
act = NULL;
}
} else if (act->priv->state == GST_VALIDATE_EXECUTE_ACTION_ASYNC) {
+ if (GST_CLOCK_TIME_IS_VALID (act->priv->timeout)) {
+ GstClockTime etime =
+ gst_util_get_timestamp () - act->priv->execution_time;
+
+ if (etime > act->priv->timeout) {
+ gchar *str = gst_structure_to_string (act->structure);
+
+ GST_VALIDATE_REPORT (scenario,
+ SCENARIO_ACTION_EXECUTION_ERROR,
+ "Action %s timed out after: %" GST_TIME_FORMAT, str,
+ GST_TIME_ARGS (etime));
+
+ g_free (str);
+ }
+ }
GST_LOG_OBJECT (scenario, "Action %" GST_PTR_FORMAT " still running",
act->structure);
@@ -2920,6 +2941,7 @@ _action_set_done (GstValidateAction * action)
if (action->scenario == NULL)
return G_SOURCE_REMOVE;
+ action->priv->execution_time = GST_CLOCK_TIME_NONE;
action->priv->state = _execute_sub_action_action (action);
if (action->priv->state != GST_VALIDATE_EXECUTE_ACTION_ASYNC) {
GST_DEBUG_OBJECT (action->scenario, "Sub action executed ASYNC");