mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
validate-runner: implement synthetic report.
+ Fix criticals logic in validate_runner_printf + Update padmonitor tests + Split validate_report_printf function.
This commit is contained in:
parent
1993229993
commit
030e7e8ba8
5 changed files with 134 additions and 18 deletions
|
@ -447,7 +447,8 @@ gst_validate_report_unref (GstValidateReport * report)
|
|||
|
||||
if (G_UNLIKELY (g_atomic_int_dec_and_test (&report->refcount))) {
|
||||
g_free (report->message);
|
||||
g_list_free_full (report->shadow_reports, (GDestroyNotify) gst_validate_report_unref);
|
||||
g_list_free_full (report->shadow_reports,
|
||||
(GDestroyNotify) gst_validate_report_unref);
|
||||
g_slice_free (GstValidateReport, report);
|
||||
g_mutex_clear (&report->shadow_reports_lock);
|
||||
}
|
||||
|
@ -637,34 +638,55 @@ gst_validate_report_set_master_report (GstValidateReport * report,
|
|||
}
|
||||
if (add_shadow_report)
|
||||
master_report->shadow_reports =
|
||||
g_list_append (master_report->shadow_reports, gst_validate_report_ref (report));
|
||||
g_list_append (master_report->shadow_reports,
|
||||
gst_validate_report_ref (report));
|
||||
GST_VALIDATE_REPORT_SHADOW_REPORTS_UNLOCK (master_report);
|
||||
}
|
||||
|
||||
void
|
||||
gst_validate_report_printf (GstValidateReport * report)
|
||||
gst_validate_report_print_level (GstValidateReport * report)
|
||||
{
|
||||
GList *tmp;
|
||||
|
||||
gst_validate_printf (NULL, "%10s : %s\n",
|
||||
gst_validate_report_level_get_name (report->level),
|
||||
report->issue->summary);
|
||||
}
|
||||
|
||||
void
|
||||
gst_validate_report_print_detected_on (GstValidateReport * report)
|
||||
{
|
||||
GList *tmp;
|
||||
|
||||
gst_validate_printf (NULL, "%*s Detected on <%s",
|
||||
12, "", gst_validate_reporter_get_name (report->reporter));
|
||||
|
||||
for (tmp = report->shadow_reports; tmp; tmp = tmp->next) {
|
||||
GstValidateReport *shadow_report = (GstValidateReport *) tmp->data;
|
||||
gst_validate_printf (NULL, ", %s",
|
||||
gst_validate_reporter_get_name (shadow_report->reporter));
|
||||
}
|
||||
|
||||
gst_validate_printf (NULL, ">\n");
|
||||
}
|
||||
|
||||
void
|
||||
gst_validate_report_print_details (GstValidateReport * report)
|
||||
{
|
||||
if (report->message)
|
||||
gst_validate_printf (NULL, "%*s Details : %s\n", 12, "", report->message);
|
||||
}
|
||||
|
||||
void
|
||||
gst_validate_report_print_description (GstValidateReport * report)
|
||||
{
|
||||
if (report->issue->description)
|
||||
gst_validate_printf (NULL, "%*s Description : %s\n", 12, "",
|
||||
report->issue->description);
|
||||
}
|
||||
|
||||
void
|
||||
gst_validate_report_printf (GstValidateReport * report)
|
||||
{
|
||||
gst_validate_report_print_level (report);
|
||||
gst_validate_report_print_detected_on (report);
|
||||
gst_validate_report_print_details (report);
|
||||
gst_validate_report_print_description (report);
|
||||
gst_validate_printf (NULL, "\n");
|
||||
}
|
||||
|
|
|
@ -207,6 +207,10 @@ GstValidateIssueId gst_validate_report_get_issue_id (GstValidateReport * report)
|
|||
|
||||
gboolean gst_validate_report_check_abort (GstValidateReport * report);
|
||||
void gst_validate_report_printf (GstValidateReport * report);
|
||||
void gst_validate_report_print_level (GstValidateReport *report);
|
||||
void gst_validate_report_print_detected_on (GstValidateReport *report);
|
||||
void gst_validate_report_print_details (GstValidateReport *report);
|
||||
void gst_validate_report_print_description (GstValidateReport *report);
|
||||
|
||||
const gchar * gst_validate_report_level_get_name (GstValidateReportLevel level);
|
||||
const gchar * gst_validate_report_area_get_name (GstValidateReportArea area);
|
||||
|
|
|
@ -64,6 +64,7 @@ struct _GstValidateRunnerPrivate
|
|||
GMutex mutex;
|
||||
GList *reports;
|
||||
GstValidateReportingLevel default_level;
|
||||
GHashTable *reports_by_type;
|
||||
|
||||
/* A list of PatternLevel */
|
||||
GList *report_pattern_levels;
|
||||
|
@ -222,6 +223,12 @@ _init_report_levels (GstValidateRunner * self)
|
|||
_set_report_levels_from_string (self, env);
|
||||
}
|
||||
|
||||
static void
|
||||
_unref_report_list (gpointer unused, GList * reports, gpointer unused_too)
|
||||
{
|
||||
g_list_free_full (reports, (GDestroyNotify) gst_validate_report_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_validate_runner_dispose (GObject * object)
|
||||
{
|
||||
|
@ -234,6 +241,9 @@ gst_validate_runner_dispose (GObject * object)
|
|||
|
||||
g_mutex_clear (&runner->priv->mutex);
|
||||
|
||||
g_hash_table_foreach (runner->priv->reports_by_type, (GHFunc)
|
||||
_unref_report_list, NULL);
|
||||
g_hash_table_destroy (runner->priv->reports_by_type);
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
|
@ -261,6 +271,9 @@ gst_validate_runner_init (GstValidateRunner * runner)
|
|||
GstValidateRunnerPrivate);
|
||||
g_mutex_init (&runner->priv->mutex);
|
||||
|
||||
runner->priv->reports_by_type = g_hash_table_new (g_direct_hash,
|
||||
g_direct_equal);
|
||||
|
||||
runner->priv->default_level = GST_VALIDATE_REPORTING_LEVEL_DEFAULT;
|
||||
_init_report_levels (runner);
|
||||
}
|
||||
|
@ -312,6 +325,24 @@ gst_validate_runner_get_reporting_level_for_name (GstValidateRunner * runner,
|
|||
return GST_VALIDATE_REPORTING_LEVEL_UNKNOWN;
|
||||
}
|
||||
|
||||
static void
|
||||
synthesize_reports (GstValidateRunner * runner, GstValidateReport * report)
|
||||
{
|
||||
GstValidateIssueId issue_id;
|
||||
GList *reports;
|
||||
|
||||
issue_id = report->issue->issue_id;
|
||||
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
reports =
|
||||
g_hash_table_lookup (runner->priv->reports_by_type,
|
||||
(gconstpointer) issue_id);
|
||||
reports = g_list_append (reports, gst_validate_report_ref (report));
|
||||
g_hash_table_insert (runner->priv->reports_by_type, (gpointer) issue_id,
|
||||
reports);
|
||||
GST_VALIDATE_RUNNER_UNLOCK (runner);
|
||||
}
|
||||
|
||||
void
|
||||
gst_validate_runner_add_report (GstValidateRunner * runner,
|
||||
GstValidateReport * report)
|
||||
|
@ -321,8 +352,15 @@ gst_validate_runner_add_report (GstValidateRunner * runner,
|
|||
|
||||
/* Let's use our own reporting strategy */
|
||||
if (reporter_level == GST_VALIDATE_REPORTING_LEVEL_UNKNOWN) {
|
||||
if (runner->priv->default_level == GST_VALIDATE_REPORTING_LEVEL_NONE)
|
||||
return;
|
||||
switch (runner->priv->default_level) {
|
||||
case GST_VALIDATE_REPORTING_LEVEL_NONE:
|
||||
return;
|
||||
case GST_VALIDATE_REPORTING_LEVEL_SYNTHETIC:
|
||||
synthesize_reports (runner, report);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
|
@ -350,6 +388,7 @@ gst_validate_runner_get_reports_count (GstValidateRunner * runner)
|
|||
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
l = g_list_length (runner->priv->reports);
|
||||
l += g_hash_table_size (runner->priv->reports_by_type);
|
||||
GST_VALIDATE_RUNNER_UNLOCK (runner);
|
||||
|
||||
return l;
|
||||
|
@ -369,6 +408,44 @@ gst_validate_runner_get_reports (GstValidateRunner * runner)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static GList *
|
||||
_do_report_synthesis (GstValidateRunner * runner)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
GList *reports, *tmp;
|
||||
gpointer key, value;
|
||||
GList *criticals = NULL;
|
||||
|
||||
g_hash_table_iter_init (&iter, runner->priv->reports_by_type);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
||||
GstValidateReport *report;
|
||||
reports = (GList *) value;
|
||||
|
||||
if (!reports)
|
||||
continue;
|
||||
|
||||
report = (GstValidateReport *) (reports->data);
|
||||
gst_validate_report_print_level (report);
|
||||
gst_validate_report_print_detected_on (report);
|
||||
|
||||
if (report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL)
|
||||
criticals = g_list_append (criticals, report);
|
||||
|
||||
for (tmp = g_list_next (reports); tmp; tmp = tmp->next) {
|
||||
report = (GstValidateReport *) (tmp->data);
|
||||
gst_validate_report_print_detected_on (report);
|
||||
|
||||
if (report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL)
|
||||
criticals = g_list_append (criticals, report);
|
||||
}
|
||||
report = (GstValidateReport *) (reports->data);
|
||||
gst_validate_report_print_description (report);
|
||||
gst_validate_printf (NULL, "\n");
|
||||
}
|
||||
|
||||
return criticals;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_validate_runner_printf:
|
||||
* @runner: The #GstValidateRunner to print all the reports for
|
||||
|
@ -384,10 +461,10 @@ int
|
|||
gst_validate_runner_printf (GstValidateRunner * runner)
|
||||
{
|
||||
GList *reports, *tmp;
|
||||
guint count = 0;
|
||||
int ret = 0;
|
||||
GList *criticals = NULL;
|
||||
|
||||
criticals = _do_report_synthesis (runner);
|
||||
reports = gst_validate_runner_get_reports (runner);
|
||||
for (tmp = reports; tmp; tmp = tmp->next) {
|
||||
GstValidateReport *report = tmp->data;
|
||||
|
@ -395,17 +472,16 @@ gst_validate_runner_printf (GstValidateRunner * runner)
|
|||
if (gst_validate_report_should_print (report))
|
||||
gst_validate_report_printf (report);
|
||||
|
||||
if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) {
|
||||
if (report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) {
|
||||
criticals = g_list_append (criticals, tmp->data);
|
||||
ret = 18;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
if (criticals) {
|
||||
GList *iter;
|
||||
|
||||
g_printerr ("\n\n==== Got criticals, Return value set to 18 ====\n");
|
||||
ret = 18;
|
||||
|
||||
for (iter = criticals; iter; iter = iter->next) {
|
||||
g_printerr (" Critical error %s\n",
|
||||
|
@ -415,7 +491,8 @@ gst_validate_runner_printf (GstValidateRunner * runner)
|
|||
}
|
||||
|
||||
g_list_free_full (reports, (GDestroyNotify) gst_validate_report_unref);
|
||||
gst_validate_printf (NULL, "Issues found: %u\n", count);
|
||||
g_list_free (criticals);
|
||||
gst_validate_printf (NULL, "Issues found: %u\n",
|
||||
gst_validate_runner_get_reports_count (runner));
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ GST_START_TEST (buffer_before_segment)
|
|||
|
||||
fail_unless (gst_element_link (src, sink));
|
||||
|
||||
fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL", "all", TRUE));
|
||||
runner = gst_validate_runner_new ();
|
||||
monitor =
|
||||
gst_validate_monitor_factory_create (GST_OBJECT (src), runner, NULL);
|
||||
|
@ -131,6 +132,7 @@ GST_START_TEST (buffer_outside_segment)
|
|||
gst_element_class_add_metadata (GST_ELEMENT_GET_CLASS (src), "klass",
|
||||
"Decoder");
|
||||
|
||||
fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL", "all", TRUE));
|
||||
runner = gst_validate_runner_new ();
|
||||
monitor =
|
||||
gst_validate_monitor_factory_create (GST_OBJECT (src), runner, NULL);
|
||||
|
@ -208,6 +210,7 @@ _first_buffer_running_time (gboolean failing)
|
|||
src = gst_element_factory_make ("fakesrc", "fakesrc");
|
||||
sink = gst_element_factory_make ("fakesink", "fakesink");
|
||||
|
||||
fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL", "all", TRUE));
|
||||
runner = gst_validate_runner_new ();
|
||||
monitor =
|
||||
gst_validate_monitor_factory_create (GST_OBJECT (src), runner, NULL);
|
||||
|
@ -317,14 +320,15 @@ _test_flow_aggregation (GstFlowReturn flow, GstFlowReturn flow1,
|
|||
GstElement *demuxer = fake_demuxer_new ();
|
||||
GstBin *pipeline = GST_BIN (gst_pipeline_new ("validate-pipeline"));
|
||||
GList *reports;
|
||||
GstValidateRunner *runner;
|
||||
GstValidateMonitor *monitor;
|
||||
|
||||
GstValidateRunner *runner = gst_validate_runner_new ();
|
||||
GstValidateMonitor *monitor =
|
||||
gst_validate_monitor_factory_create (GST_OBJECT (pipeline),
|
||||
fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL", "all", TRUE));
|
||||
runner = gst_validate_runner_new ();
|
||||
monitor = gst_validate_monitor_factory_create (GST_OBJECT (pipeline),
|
||||
runner, NULL);
|
||||
gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor));
|
||||
|
||||
|
||||
gst_bin_add (pipeline, demuxer);
|
||||
fake_demuxer_prepare_pads (pipeline, demuxer, runner);
|
||||
|
||||
|
@ -413,6 +417,7 @@ GST_START_TEST (issue_concatenation)
|
|||
gint n_reports;
|
||||
gulong probe_id1, probe_id2;
|
||||
|
||||
fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL", "subchain", TRUE));
|
||||
runner = gst_validate_runner_new ();
|
||||
|
||||
src1 = create_and_monitor_element ("fakesrc", "fakesrc1", runner);
|
||||
|
|
|
@ -216,6 +216,14 @@ GST_START_TEST (test_global_levels)
|
|||
TRUE));
|
||||
runner = gst_validate_runner_new ();
|
||||
_create_issues (runner);
|
||||
/* One issue should get through the none filter */
|
||||
fail_unless_equals_int (gst_validate_runner_get_reports_count (runner), 1);
|
||||
g_object_unref (runner);
|
||||
|
||||
fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL", "synthetic", TRUE));
|
||||
runner = gst_validate_runner_new ();
|
||||
_create_issues (runner);
|
||||
/* Two reports of the same type */
|
||||
fail_unless_equals_int (gst_validate_runner_get_reports_count (runner), 1);
|
||||
g_object_unref (runner);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue