validate-runner: report-level initial work.

+ Defines reporting levels and document them.
+ Add API to get the default level.
+ fix indentation.
+ fix some typos.
+ Add the beginning of a reporting test.
This commit is contained in:
Mathieu Duponchelle 2014-10-08 05:08:21 +02:00 committed by Mathieu Duponchelle
parent 6e08079f8b
commit 6ed125bfb1
6 changed files with 171 additions and 7 deletions

View file

@ -21,6 +21,7 @@ libgstvalidate_@GST_API_VERSION@include_HEADERS = \
validate.h \
gst-validate-bin-monitor.h \
gst-validate-element-monitor.h \
gst-validate-enums.h \
gst-validate-monitor-factory.h \
gst-validate-monitor.h \
gst-validate-override.h \

View file

@ -0,0 +1,81 @@
/* GStreamer
* Copyright (C) 2014 Mathieu Duponchelle <mathieu.duponchelle@collabora.com>
*
* gst-validate-enums.h - Validate constants.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_VALIDATE_ENUMS_H__
#define __GST_VALIDATE_ENUMS_H__
/**
* GstValidateReportingLevel:
* @GST_VALIDATE_REPORTING_LEVEL_NONE: No debugging level specified or desired. Used to deactivate
* debugging output.
* @GST_VALIDATE_REPORTING_LEVEL_SYNTHETIC: Summary of the issues found, with no
* details.
* @GST_VALIDATE_REPORTING_LEVEL_SUBCHAIN: If set as the default level, similar
* issues can be reported multiple times for different subchains.
* If set as the level for a particular object (my_object:subchain), validate
* will report the issues where the object is the first to report an issue for
* a subchain.
* @GST_VALIDATE_REPORTING_LEVEL_MONITOR: If set as the default level, all the
* distinct issues for all the monitors will be reported.
* If set as the level for a particular object, all the distinct issues for this object
* will be reported.
* Note that if the same issue happens twice on the same object, up until this
* level that issue is only reported once.
* @GST_VALIDATE_REPORTING_LEVEL_ALL: All the issues will be reported, even those
* that repeat themselves inside the same object. This can be *very* verbose if
* set globally.
* @GST_VALIDATE_REPORTING_LEVEL_UNKNOWN: No reporting level known,
* reporting will default to the global reporting level.
*
* Setting the reporting level allows to control the way issues are reported
* when calling #gst_validate_runner_printf.
*
* The reporting level can be set through the "GST_VALIDATE_REPORTING_LEVEL"
* environment variable, as a comma-separated list of (optional) object categories / names
* and levels. No object category / name sets the global level.
*
* Examples: GST_VALIDATE_REPORTING_LEVEL=synthetic,h264parse:all
* GST_VALIDATE_REPORTING_LEVEL=none,h264parse::sink_0:synthetic
*/
typedef enum {
GST_VALIDATE_REPORTING_LEVEL_UNKNOWN = 0,
GST_VALIDATE_REPORTING_LEVEL_NONE = 1,
GST_VALIDATE_REPORTING_LEVEL_SYNTHETIC = 2,
GST_VALIDATE_REPORTING_LEVEL_SUBCHAIN = 3,
GST_VALIDATE_REPORTING_LEVEL_MONITOR = 4,
GST_VALIDATE_REPORTING_LEVEL_ALL = 5,
GST_VALIDATE_REPORTING_LEVEL_COUNT
} GstValidateReportingLevel;
/**
* GST_VALIDATE_REPORTING_LEVEL_DEFAULT:
*
* Defines the default reporting level to be used with gst-validate. It is normally
* set to #GST_VALIDATE_REPORTING_LEVEL_SYNTHETIC so only a synthetic report
* gets printed.
* As it can be configured at compile time, developer builds may chose to
* override that though.
*/
#ifndef GST_VALIDATE_REPORTING_LEVEL_DEFAULT
#define GST_VALIDATE_REPORTING_LEVEL_DEFAULT GST_VALIDATE_REPORTING_LEVEL_SYNTHETIC
#endif
#endif /* __GST_VALIDATE_RUNNER_H__ */

View file

@ -58,8 +58,9 @@
struct _GstValidateRunnerPrivate
{
GMutex mutex;
GList *reports;
GMutex mutex;
GList *reports;
GstValidateReportingLevel default_level;
};
#define GST_VALIDATE_RUNNER_LOCK(r) \
@ -89,6 +90,22 @@ enum
static guint _signals[LAST_SIGNAL] = { 0 };
static void
_set_report_levels_from_string (GstValidateRunner * self, const gchar * list)
{
GST_DEBUG_OBJECT (self, "setting report levels from string [%s]", list);
}
static void
_init_report_levels (GstValidateRunner * self)
{
const gchar *env;
env = g_getenv ("GST_VALIDATE_REPORT_LEVEL");
if (env)
_set_report_levels_from_string (self, env);
}
static void
gst_validate_runner_dispose (GObject * object)
{
@ -125,6 +142,9 @@ gst_validate_runner_init (GstValidateRunner * runner)
runner->priv = G_TYPE_INSTANCE_GET_PRIVATE (runner, GST_TYPE_VALIDATE_RUNNER,
GstValidateRunnerPrivate);
g_mutex_init (&runner->priv->mutex);
runner->priv->default_level = GST_VALIDATE_REPORTING_LEVEL_DEFAULT;
_init_report_levels (runner);
}
/**
@ -140,6 +160,12 @@ gst_validate_runner_new (void)
return g_object_new (GST_TYPE_VALIDATE_RUNNER, NULL);
}
GstValidateReportingLevel
gst_validate_runner_get_default_reporting_level (GstValidateRunner * runner)
{
return runner->priv->default_level;
}
void
gst_validate_runner_add_report (GstValidateRunner * runner,
GstValidateReport * report)
@ -179,7 +205,9 @@ gst_validate_runner_get_reports (GstValidateRunner * runner)
GList *ret;
GST_VALIDATE_RUNNER_LOCK (runner);
ret = g_list_copy_deep (runner->priv->reports, (GCopyFunc) gst_validate_report_ref, NULL);
ret =
g_list_copy_deep (runner->priv->reports,
(GCopyFunc) gst_validate_report_ref, NULL);
GST_VALIDATE_RUNNER_UNLOCK (runner);
return ret;
@ -190,10 +218,10 @@ gst_validate_runner_get_reports (GstValidateRunner * runner)
* @runner: The #GstValidateRunner to print all the reports for
*
* Prints all the report on the terminal or on wherever set
* on the #GST_VALIDATE_FILE env variable.
* in the #GST_VALIDATE_FILE env variable.
*
* Retrurns: 0 if no critical error has been found and 18 if a critical
* error as been detected. That return value is usually to be used as
* Returns: 0 if no critical error has been found and 18 if a critical
* error has been detected. That return value is usually to be used as
* exit code of the application.
* */
int

View file

@ -29,6 +29,7 @@ typedef struct _GstValidateRunner GstValidateRunner;
typedef struct _GstValidateRunnerClass GstValidateRunnerClass;
#include <gst/validate/gst-validate-report.h>
#include <gst/validate/gst-validate-enums.h>
G_BEGIN_DECLS
@ -78,6 +79,8 @@ GList * gst_validate_runner_get_reports (GstValidateRunner * runner);
int gst_validate_runner_printf (GstValidateRunner * runner);
GstValidateReportingLevel gst_validate_runner_get_default_reporting_level (GstValidateRunner *runner);
G_END_DECLS
#endif /* __GST_VALIDATE_RUNNER_H__ */

View file

@ -28,7 +28,8 @@ clean-local: clean-local-check
check_PROGRAMS = \
validate/padmonitor \
validate/monitoring
validate/monitoring \
validate/reporting
noinst_LTLIBRARIES=$(testutils_noisnt_libraries)
noinst_HEADERS=$(testutils_noinst_headers)

View file

@ -0,0 +1,50 @@
/* GstValidate
* Copyright (C) 2014 Mathieu Duponchelle <mathieu.duponchelle@collabora.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <gst/validate/validate.h>
#include <gst/check/gstcheck.h>
#include "test-utils.h"
GST_START_TEST (test_report_levels)
{
GstValidateRunner *runner;
fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL", "all", TRUE));
runner = gst_validate_runner_new ();
g_object_unref (runner);
}
GST_END_TEST;
static Suite *
gst_validate_suite (void)
{
Suite *s = suite_create ("reporting");
TCase *tc_chain = tcase_create ("reporting");
suite_add_tcase (s, tc_chain);
gst_validate_init ();
tcase_add_test (tc_chain, test_report_levels);
return s;
}
GST_CHECK_MAIN (gst_validate);