3 * Copyright (C) 2013 Collabora Ltd.
4 * Author: Thiago Sousa Santos <thiago.sousa.santos@collabora.com>
6 * gst-validate-runner.c - Validate Runner class
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 #include "gst-validate-internal.h"
29 #include "gst-validate-report.h"
30 #include "gst-validate-monitor-factory.h"
31 #include "gst-validate-override-registry.h"
32 #include "gst-validate-runner.h"
35 * SECTION:gst-validate-runner
36 * @short_description: Class that runs Gst Validate tests for a pipeline
41 #define gst_validate_runner_parent_class parent_class
42 G_DEFINE_TYPE (GstValidateRunner, gst_validate_runner, G_TYPE_OBJECT);
52 static guint _signals[LAST_SIGNAL] = { 0 };
55 gst_validate_runner_dispose (GObject * object)
57 GstValidateRunner *runner = GST_VALIDATE_RUNNER_CAST (object);
59 g_slist_free_full (runner->reports,
60 (GDestroyNotify) gst_validate_report_unref);
62 G_OBJECT_CLASS (parent_class)->dispose (object);
66 gst_validate_runner_class_init (GstValidateRunnerClass * klass)
68 GObjectClass *gobject_class;
70 gobject_class = G_OBJECT_CLASS (klass);
72 gobject_class->dispose = gst_validate_runner_dispose;
74 _signals[REPORT_ADDED_SIGNAL] =
75 g_signal_new ("report-added", G_TYPE_FROM_CLASS (klass),
76 G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1,
77 GST_TYPE_VALIDATE_REPORT);
81 gst_validate_runner_init (GstValidateRunner * runner)
83 runner->setup = FALSE;
84 runner->max_printed_level = GST_VALIDATE_REPORT_LEVEL_NUM_ENTRIES;
88 * gst_validate_runner_new:
91 gst_validate_runner_new (void)
93 return g_object_new (GST_TYPE_VALIDATE_RUNNER, NULL);
97 gst_validate_runner_add_report (GstValidateRunner * runner,
98 GstValidateReport * report)
100 runner->reports = g_slist_prepend (runner->reports, report);
102 g_signal_emit (runner, _signals[REPORT_ADDED_SIGNAL], 0, report);
106 gst_validate_runner_get_reports_count (GstValidateRunner * runner)
108 g_return_val_if_fail (runner != NULL, 0);
109 return g_slist_length (runner->reports);
113 gst_validate_runner_get_reports (GstValidateRunner * runner)
115 /* TODO should we need locking or put in htte docs to always call this
116 * after pipeline ends? */
117 return runner->reports;
121 gst_validate_runner_printf (GstValidateRunner * runner)
126 GList *criticals = NULL;
128 for (tmp = gst_validate_runner_get_reports (runner); tmp; tmp = tmp->next) {
129 GstValidateReport *report = tmp->data;
131 if (gst_validate_report_should_print (report))
132 gst_validate_report_printf (report);
134 if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) {
135 criticals = g_list_append (criticals, tmp->data);
144 g_printerr ("\n\n==== Got criticals, Return value set to 18 ====\n");
146 for (iter = criticals; iter; iter = iter->next) {
147 g_printerr (" Critical error %s\n",
148 ((GstValidateReport *) (iter->data))->message);
153 gst_validate_printf (NULL, "Pipeline finished, issues found: %u\n", count);