mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-21 17:21:13 +00:00
validate: Add a way to retrieve HTTP server port in .validatetest files
By setting a `$(http_server_port)s` variable in a dedicated config file and making sure that file can always be imported in `.validatetest` files. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7700>
This commit is contained in:
parent
ea99a670e3
commit
19060b2ce0
3 changed files with 58 additions and 9 deletions
|
@ -724,18 +724,31 @@ _file_get_structures (GFile * file, gchar ** err,
|
|||
GList *tmpstructures;
|
||||
gchar **include_dirs = NULL;
|
||||
|
||||
if (!get_include_paths_func
|
||||
&& g_str_has_suffix (location, GST_VALIDATE_SCENARIO_SUFFIX)) {
|
||||
if (get_include_paths_func)
|
||||
include_dirs = get_include_paths_func (filename);
|
||||
|
||||
if (g_str_has_suffix (location, GST_VALIDATE_SCENARIO_SUFFIX)) {
|
||||
GST_INFO
|
||||
("Trying to include a scenario, take into account scenario include dir");
|
||||
|
||||
get_include_paths_func = (GstValidateGetIncludePathsFunc)
|
||||
gst_validate_scenario_get_include_paths;
|
||||
gchar **extra_includes =
|
||||
gst_validate_scenario_get_include_paths (filename);
|
||||
if (extra_includes) {
|
||||
gint i = 0;
|
||||
gint existing_len =
|
||||
include_dirs ? g_strv_length (include_dirs) : 0;
|
||||
gint extra_len = g_strv_length (extra_includes);
|
||||
include_dirs =
|
||||
g_realloc_n (include_dirs, existing_len + extra_len + 1,
|
||||
sizeof (gchar *));
|
||||
for (i = 0; extra_includes[i] != NULL; i++) {
|
||||
include_dirs[existing_len + i] = extra_includes[i];
|
||||
}
|
||||
include_dirs[existing_len + i] = NULL;
|
||||
g_free (extra_includes);
|
||||
}
|
||||
}
|
||||
|
||||
if (get_include_paths_func)
|
||||
include_dirs = get_include_paths_func (filename);
|
||||
|
||||
if (!include_dirs) {
|
||||
GFile *dir = g_file_get_parent (file);
|
||||
included = g_file_resolve_relative_path (dir, location);
|
||||
|
|
|
@ -587,6 +587,31 @@ gst_validate_get_test_file_scenario (GList ** structs,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gchar **
|
||||
validate_test_include_paths (const gchar * includer_file)
|
||||
{
|
||||
gchar **env_configdir;
|
||||
gchar *configs_path = g_strdup (g_getenv ("GST_VALIDATE_TEST_CONFIG_PATH"));
|
||||
|
||||
if (includer_file) {
|
||||
gchar *relative_dir = g_path_get_dirname (includer_file);
|
||||
gchar *tmp_configs_path = configs_path ?
|
||||
g_strdup_printf ("%s" G_SEARCHPATH_SEPARATOR_S "%s", configs_path,
|
||||
relative_dir) : g_strdup (relative_dir);
|
||||
g_free (relative_dir);
|
||||
|
||||
g_free (configs_path);
|
||||
configs_path = tmp_configs_path;
|
||||
}
|
||||
|
||||
env_configdir =
|
||||
configs_path ? g_strsplit (configs_path, G_SEARCHPATH_SEPARATOR_S,
|
||||
0) : NULL;
|
||||
g_free (configs_path);
|
||||
|
||||
return env_configdir;
|
||||
}
|
||||
|
||||
/* Only the first monitor pipeline will be used */
|
||||
GstStructure *
|
||||
gst_validate_setup_test_file (const gchar * testfile, gboolean use_fakesinks)
|
||||
|
@ -603,8 +628,8 @@ gst_validate_setup_test_file (const gchar * testfile, gboolean use_fakesinks)
|
|||
gst_validate_set_globals (NULL);
|
||||
gst_validate_structure_set_variables_from_struct_file (NULL, global_testfile);
|
||||
testfile_structs =
|
||||
gst_validate_utils_structs_parse_from_filename (global_testfile, NULL,
|
||||
NULL);
|
||||
gst_validate_utils_structs_parse_from_filename (global_testfile,
|
||||
validate_test_include_paths, NULL);
|
||||
|
||||
if (!testfile_structs)
|
||||
gst_validate_abort ("Could not load test file: %s", global_testfile);
|
||||
|
|
|
@ -43,6 +43,7 @@ import shutil
|
|||
import uuid
|
||||
from itertools import cycle
|
||||
from fractions import Fraction
|
||||
from pathlib import Path
|
||||
|
||||
from .utils import GstCaps, which
|
||||
from . import reporters
|
||||
|
@ -1031,6 +1032,12 @@ class GstValidateTest(Test):
|
|||
subproc_env['GST_XINITTHREADS'] = '1'
|
||||
self.add_env_variable('GST_XINITTHREADS', '1')
|
||||
|
||||
vaildateconfigs_path = os.environ.get('GST_VALIDATE_TEST_CONFIG_PATH', "")
|
||||
extra_configs = os.path.join(self.options.logsdir, "_validate_test_extra_configs")
|
||||
vaildateconfigs_path = f"{extra_configs}{os.pathsep}{vaildateconfigs_path}"
|
||||
subproc_env['GST_VALIDATE_TEST_CONFIG_PATH'] = vaildateconfigs_path
|
||||
self.add_env_variable('GST_VALIDATE_TEST_CONFIG_PATH', vaildateconfigs_path)
|
||||
|
||||
if self.scenario is not None:
|
||||
scenario = self.scenario.get_execution_name()
|
||||
subproc_env["GST_VALIDATE_SCENARIO"] = scenario
|
||||
|
@ -2023,6 +2030,10 @@ class _TestsLauncher(Loggable):
|
|||
if self.needs_http_server() or options.httponly is True:
|
||||
self.httpsrv = HTTPServer(options)
|
||||
self.httpsrv.start()
|
||||
configsdir = Path(options.logsdir) / "_validate_test_extra_configs"
|
||||
os.makedirs(configsdir, exist_ok=True)
|
||||
with open(configsdir / "http_server_port.var", "w") as f:
|
||||
f.write(f"set-globals,http_server_port={self.options.http_server_port}")
|
||||
|
||||
if options.no_display:
|
||||
self.vfb_server = get_virual_frame_buffer_server(options)
|
||||
|
|
Loading…
Reference in a new issue