validate: Add support for overrides field in meta structure

Add support for an 'overrides' field in validatetest meta structures that
allows changing issue severity levels during test execution. This enables
tests to pass when encountering known issues by downgrading their severity.

The overrides field accepts an array of change-severity structures with:
- issue-id: The issue ID to override
- new-severity: New severity level (critical, warning, issue, ignore)

Currently only change-severity overrides are supported. The feature follows
the same pattern as expected-issues and is only available in .validatetest
files, not .scenario files.

Includes comprehensive documentation and a test case demonstrating the
functionality.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9013>
This commit is contained in:
Thibault Saunier 2025-06-14 09:39:03 -04:00 committed by GStreamer Marge Bot
parent 0b745f67db
commit f99bf2abee
7 changed files with 67 additions and 4 deletions

View File

@ -0,0 +1,25 @@
The `overrides` field is an array of override structures.
At the moment, these overrides allow you to change the severity level of specific issues,
for example changing a critical issue to a warning to allow tests to pass
when encountering known issues.
Use `gst-validate-1.0 --print-issue-types` to print information about all issue types.
For example:
``` yaml
overrides = {
[change-severity, issue-id=runtime::not-negotiated, new-severity=warning],
[change-severity, issue-id=g-log::critical, new-severity=info],
}
```
**Each override has the following fields**:
* `issue-id`: (string): Issue ID to override - Mandatory
* `new-severity`: (string): New severity level (critical, warning, issue, ignore) - Mandatory
Currently only `change-severity` overrides are supported.
**Warning**: This field is validate only for [`.validatetest`](gst-validate-test-file.md) files, and not `.scenario`.

View File

@ -54,6 +54,7 @@ G_GNUC_INTERNAL gboolean gst_validate_scenario_check_and_set_needs_clock_sync (G
#define GST_VALIDATE_SCENARIO_SUFFIX ".scenario"
G_GNUC_INTERNAL gchar** gst_validate_scenario_get_include_paths(const gchar* relative_scenario);
G_GNUC_INTERNAL void _priv_validate_override_registry_deinit(void);
G_GNUC_INTERNAL gboolean _priv_add_override_from_struct (GstStructure * soverride);
G_GNUC_INTERNAL GstValidateReportingDetails gst_validate_runner_get_default_reporting_details (GstValidateRunner *runner);
G_GNUC_INTERNAL void gst_validate_runner_set_monitor_all_pipelines (GstValidateRunner *runner, gboolean monitor_all_pipelines);

View File

@ -252,8 +252,8 @@ enum
OK
};
static gboolean
_add_override_from_struct (GstStructure * soverride)
gboolean
_priv_add_override_from_struct (GstStructure * soverride)
{
GQuark issue_id;
GstValidateReportLevel level;
@ -367,7 +367,7 @@ _load_text_override_file (const gchar * filename)
for (tmp = structs; tmp; tmp = tmp->next) {
GstStructure *_struct = (GstStructure *) tmp->data;
if (!_add_override_from_struct (_struct)) {
if (!_priv_add_override_from_struct (_struct)) {
GST_ERROR ("Wrong overrides %" GST_PTR_FORMAT, _struct);
ret = WRONG_OVERRIDES;
}
@ -394,7 +394,7 @@ gst_validate_override_registry_preload (void)
GList *tmp, *overrides = gst_validate_get_config ("change-issue-severity");
for (tmp = overrides; tmp; tmp = tmp->next)
_add_override_from_struct (tmp->data);
_priv_add_override_from_struct (tmp->data);
g_list_free (overrides);
sos = g_getenv ("GST_VALIDATE_OVERRIDE");

View File

@ -7983,6 +7983,9 @@ register_action_types (void)
GBytes *meta_features_rank_doc =
g_resource_lookup_data (resource, "/validate/doc/meta-features-rank.md",
G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
GBytes *meta_overrides_doc =
g_resource_lookup_data (resource, "/validate/doc/meta-overrides.md",
G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
/* *INDENT-OFF* */
REGISTER_ACTION_TYPE ("meta", NULL,
@ -8159,6 +8162,14 @@ register_action_types (void)
.possible_variables = NULL,
.def = "{}"
},
{
.name="overrides",
.description=g_bytes_get_data (meta_overrides_doc, NULL),
.mandatory = FALSE,
.types = "{GstStructure as string}",
.possible_variables = NULL,
.def = "{}"
},
{
.name="features-rank",
.description=g_bytes_get_data (meta_features_rank_doc, NULL),
@ -8184,6 +8195,7 @@ register_action_types (void)
g_bytes_unref (meta_config_doc);
g_bytes_unref (meta_expected_issues_doc);
g_bytes_unref (meta_features_rank_doc);
g_bytes_unref (meta_overrides_doc);
REGISTER_ACTION_TYPE ("seek", _execute_seek,
((GstValidateActionParameter []) {

View File

@ -501,6 +501,16 @@ gst_validate_init (void)
/* Ensure we load overrides before any use of a monitor */
gst_validate_override_registry_preload ();
/* Load overrides from test file meta if any */
GList *overrides = get_structures_from_array_in_meta ("overrides");
for (GList * tmp = overrides; tmp; tmp = tmp->next) {
if (!_priv_add_override_from_struct (tmp->data)) {
GST_ERROR ("Failed to add override from test file: %" GST_PTR_FORMAT,
tmp->data);
}
}
g_list_free (overrides);
validate_initialized = TRUE;
gst_validate_extra_checks_init ();

View File

@ -4,6 +4,7 @@
<file>doc/meta-configs.md</file>
<file>doc/meta-expected-issues.md</file>
<file>doc/meta-features-rank.md</file>
<file>doc/meta-overrides.md</file>
</gresource>
</gresources>

View File

@ -0,0 +1,14 @@
meta,
args = {
"videotestsrc ! capsfilter name=cf ! fakesink",
},
overrides = {
[change-severity, issue-id=runtime::not-negotiated, new-severity=warning],
[change-severity, issue-id=scenario::not-ended, new-severity=warning],
}
set-properties, cf::caps="audio/x-raw"
wait, message-type=error
set-state, state=null