runner: Use "18" as exit code in case of error

It is a random number, but it will in most cases give people a hint
that gst-validate reported a critical issue, and thus set the return
code, only by looking at it

Also make use of gst_validate_runner_print() in
gst-validate-transcoding.c as we were copy pasting that method there.
This commit is contained in:
Thibault Saunier 2013-10-05 12:00:35 -03:00
parent ae641d0353
commit 7e1249f089
3 changed files with 8 additions and 23 deletions

View File

@ -75,4 +75,6 @@ gst-validate will try to replace GstPipeline creating functions and configure
monitors automatically for you, reports will be printed to stderr when monitors automatically for you, reports will be printed to stderr when
they are found. You can also use GST_DEBUG to view the issues that were found they are found. You can also use GST_DEBUG to view the issues that were found
NOTS: The exit code will be "18" in case a critical issue has
been seen while running any of those tools.

View File

@ -128,9 +128,9 @@ gst_validate_runner_printf (GstValidateRunner * runner)
gst_validate_report_printf (report); gst_validate_report_printf (report);
if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) { if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) {
g_printerr ("Got critical error %s, setting return value to -1\n", g_printerr ("Got critical error %s, setting return value to 18\n",
((GstValidateReport *) (tmp->data))->message); ((GstValidateReport *) (tmp->data))->message);
ret = -1; ret = 18;
} }
count++; count++;
} }

View File

@ -329,18 +329,17 @@ int
main (int argc, gchar ** argv) main (int argc, gchar ** argv)
{ {
guint i; guint i;
GSList *tmp;
GstBus *bus; GstBus *bus;
GstValidateRunner *runner; GstValidateRunner *runner;
GstValidateMonitor *monitor; GstValidateMonitor *monitor;
GOptionContext *ctx; GOptionContext *ctx;
int rep_err;
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
guint signal_watch_id; guint signal_watch_id;
#endif #endif
GError *err = NULL; GError *err = NULL;
const gchar *scenario = NULL; const gchar *scenario = NULL;
guint count = 0;
gboolean want_help = FALSE; gboolean want_help = FALSE;
gboolean list_scenarios = FALSE; gboolean list_scenarios = FALSE;
@ -451,25 +450,9 @@ main (int argc, gchar ** argv)
g_timeout_add (50, (GSourceFunc) print_position, NULL); g_timeout_add (50, (GSourceFunc) print_position, NULL);
g_main_loop_run (mainloop); g_main_loop_run (mainloop);
for (tmp = gst_validate_runner_get_reports (runner); tmp; tmp = tmp->next) { rep_err = gst_validate_runner_printf (runner);
if (ret == 0 && ((GstValidateReport *) (tmp->data))->level == if (ret == 0)
GST_VALIDATE_REPORT_LEVEL_CRITICAL) { ret = rep_err;
g_printerr ("Got critical error %s, setting return value to -1\n",
((GstValidateReport *) (tmp->data))->message);
ret = -1;
}
count++;
}
g_print ("Pipeline finished, total issues found: %u\n", count);
if (count) {
GSList *iter;
GSList *issues = gst_validate_runner_get_reports (runner);
for (iter = issues; iter; iter = g_slist_next (iter)) {
GstValidateReport *report = iter->data;
gst_validate_report_printf (report);
}
}
exit: exit:
gst_element_set_state (pipeline, GST_STATE_NULL); gst_element_set_state (pipeline, GST_STATE_NULL);