validate: Set return value of apps to -1 only if a critical issues was reported

Conflicts:

	gst/validate/gst-validate-transcoding.c
	gst/validate/gst-validate.c
This commit is contained in:
Thibault Saunier 2013-08-19 14:13:10 -04:00 committed by Thiago Santos
parent 375a47aa0d
commit 96ca875c56
2 changed files with 32 additions and 18 deletions

View file

@ -19,6 +19,7 @@
#include "gst-validate-scenario.h" #include "gst-validate-scenario.h"
static gint ret = 0;
static GMainLoop *mainloop; static GMainLoop *mainloop;
static GstElement *pipeline; static GstElement *pipeline;
static GstEncodingProfile *encoding_profile = NULL; static GstEncodingProfile *encoding_profile = NULL;
@ -67,8 +68,10 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{ {
GError *err; GError *err;
gchar *debug; gchar *debug;
ret = -1;
gst_message_parse_error (message, &err, &debug); gst_message_parse_error (message, &err, &debug);
g_print ("Error: %s\n", err->message); g_print ("Error: %s %s\n", GST_OBJECT_NAME (GST_MESSAGE_SRC (message)),
err->message);
g_error_free (err); g_error_free (err);
g_free (debug); g_free (debug);
g_main_loop_quit (loop); g_main_loop_quit (loop);
@ -271,6 +274,7 @@ 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;
@ -281,7 +285,7 @@ main (int argc, gchar ** argv)
GError *err = NULL; GError *err = NULL;
const gchar *scenario = NULL; const gchar *scenario = NULL;
guint count = -1; guint count = 0;
gboolean want_help = FALSE; gboolean want_help = FALSE;
gboolean list_scenarios = FALSE; gboolean list_scenarios = FALSE;
@ -391,7 +395,15 @@ main (int argc, gchar ** argv)
goto exit; goto exit;
g_main_loop_run (mainloop); g_main_loop_run (mainloop);
count = gst_validate_runner_get_reports_count (runner); 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); g_print ("Pipeline finished, total issues found: %u\n", count);
if (count) { if (count) {
GSList *iter; GSList *iter;
@ -413,7 +425,6 @@ exit:
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
g_source_remove (signal_watch_id); g_source_remove (signal_watch_id);
#endif #endif
if (count)
return -1; return ret;
return 0;
} }

View file

@ -17,6 +17,7 @@
#include <glib-unix.h> #include <glib-unix.h>
#endif #endif
static gint ret = 0;
static GMainLoop *mainloop; static GMainLoop *mainloop;
static GstElement *pipeline; static GstElement *pipeline;
@ -43,6 +44,7 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{ {
GError *err; GError *err;
gchar *debug; gchar *debug;
ret = -1;
gst_message_parse_error (message, &err, &debug); gst_message_parse_error (message, &err, &debug);
g_print ("Error: %s\n", err->message); g_print ("Error: %s\n", err->message);
g_error_free (err); g_error_free (err);
@ -63,13 +65,14 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
int int
main (int argc, gchar ** argv) main (int argc, gchar ** argv)
{ {
GSList *tmp;
GError *err = NULL; GError *err = NULL;
const gchar *scenario = NULL; const gchar *scenario = NULL;
gboolean list_scenarios = FALSE; gboolean list_scenarios = FALSE;
guint count = -1;
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
guint signal_watch_id; guint signal_watch_id;
#endif #endif
guint count = 0;
GOptionEntry options[] = { GOptionEntry options[] = {
{"set-scenario", '\0', 0, G_OPTION_ARG_STRING, &scenario, {"set-scenario", '\0', 0, G_OPTION_ARG_STRING, &scenario,
@ -153,17 +156,18 @@ main (int argc, gchar ** argv)
g_print ("Pipeline started\n"); g_print ("Pipeline started\n");
g_main_loop_run (mainloop); g_main_loop_run (mainloop);
count = gst_validate_runner_get_reports_count (runner); for (tmp = gst_validate_runner_get_reports (runner); tmp; tmp = tmp->next) {
g_print ("Pipeline finished, issues found: %u\n", count); GstValidateReport *report = tmp->data;
if (count) {
GSList *iter;
GSList *issues = gst_validate_runner_get_reports (runner);
for (iter = issues; iter; iter = g_slist_next (iter)) { gst_validate_report_printf (report);
GstValidateReport *report = iter->data; if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) {
gst_validate_report_printf (report); g_printerr ("Got critical error %s, setting return value to -1\n",
((GstValidateReport *) (tmp->data))->message);
ret = -1;
} }
count++;
} }
g_print ("Pipeline finished, issues found: %u\n", count);
exit: exit:
gst_element_set_state (pipeline, GST_STATE_NULL); gst_element_set_state (pipeline, GST_STATE_NULL);
@ -174,7 +178,6 @@ exit:
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
g_source_remove (signal_watch_id); g_source_remove (signal_watch_id);
#endif #endif
if (count)
return -1; return ret;
return 0;
} }