From 7e1249f089396de19c694e9cf7a2db5fc78e2ac0 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 5 Oct 2013 12:00:35 -0300 Subject: [PATCH] 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. --- validate/docs/validate-usage.txt | 2 ++ validate/gst/validate/gst-validate-runner.c | 4 ++-- validate/tools/gst-validate-transcoding.c | 25 ++++----------------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/validate/docs/validate-usage.txt b/validate/docs/validate-usage.txt index 5dabedb331..197b380071 100644 --- a/validate/docs/validate-usage.txt +++ b/validate/docs/validate-usage.txt @@ -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 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. diff --git a/validate/gst/validate/gst-validate-runner.c b/validate/gst/validate/gst-validate-runner.c index e2c1ff1350..a5599c76b3 100644 --- a/validate/gst/validate/gst-validate-runner.c +++ b/validate/gst/validate/gst-validate-runner.c @@ -128,9 +128,9 @@ gst_validate_runner_printf (GstValidateRunner * runner) gst_validate_report_printf (report); 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); - ret = -1; + ret = 18; } count++; } diff --git a/validate/tools/gst-validate-transcoding.c b/validate/tools/gst-validate-transcoding.c index 453f38dfaa..1fdf9018ad 100644 --- a/validate/tools/gst-validate-transcoding.c +++ b/validate/tools/gst-validate-transcoding.c @@ -329,18 +329,17 @@ int main (int argc, gchar ** argv) { guint i; - GSList *tmp; GstBus *bus; GstValidateRunner *runner; GstValidateMonitor *monitor; GOptionContext *ctx; + int rep_err; #ifdef G_OS_UNIX guint signal_watch_id; #endif GError *err = NULL; const gchar *scenario = NULL; - guint count = 0; gboolean want_help = FALSE; gboolean list_scenarios = FALSE; @@ -451,25 +450,9 @@ main (int argc, gchar ** argv) g_timeout_add (50, (GSourceFunc) print_position, NULL); g_main_loop_run (mainloop); - for (tmp = gst_validate_runner_get_reports (runner); tmp; tmp = tmp->next) { - if (ret == 0 && ((GstValidateReport *) (tmp->data))->level == - GST_VALIDATE_REPORT_LEVEL_CRITICAL) { - 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); - } - } + rep_err = gst_validate_runner_printf (runner); + if (ret == 0) + ret = rep_err; exit: gst_element_set_state (pipeline, GST_STATE_NULL);