From f9e6044124f108fe0e3fe0d42b06bb8db7ca5309 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 4 Oct 2022 19:14:49 -0300 Subject: [PATCH] validate: Handle testfiles that need an HTTP server Part-of: --- .../gst/validate/gst-validate-internal.h | 1 + .../gst/validate/gst-validate-scenario.c | 3 +- .../validate/launcher/apps/gstvalidate.py | 42 +++++++++++-------- .../validate/launcher/baseclasses.py | 18 ++++++++ .../testsuites/validate_known_issues.py | 1 + 5 files changed, 46 insertions(+), 19 deletions(-) diff --git a/subprojects/gst-devtools/validate/gst/validate/gst-validate-internal.h b/subprojects/gst-devtools/validate/gst/validate/gst-validate-internal.h index aee26fd926..30921fb5c6 100644 --- a/subprojects/gst-devtools/validate/gst/validate/gst-validate-internal.h +++ b/subprojects/gst-devtools/validate/gst/validate/gst-validate-internal.h @@ -56,6 +56,7 @@ G_GNUC_INTERNAL void _priv_validate_override_registry_deinit(void); G_GNUC_INTERNAL GstValidateReportingDetails gst_validate_runner_get_default_reporting_details (GstValidateRunner *runner); +#define GST_VALIDATE_VALIDATE_TEST_SUFFIX ".validatetest" G_GNUC_INTERNAL GstValidateMonitor * gst_validate_get_monitor (GObject *object); G_GNUC_INTERNAL void gst_validate_init_runner (void); G_GNUC_INTERNAL void gst_validate_deinit_runner (void); diff --git a/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c b/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c index 115b00f92c..e9ef125c65 100644 --- a/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c +++ b/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c @@ -5441,7 +5441,8 @@ _parse_scenario (GFile * f, GKeyFile * kf) gboolean ret = FALSE; gchar *path = g_file_get_path (f); - if (g_str_has_suffix (path, GST_VALIDATE_SCENARIO_SUFFIX)) { + if (g_str_has_suffix (path, GST_VALIDATE_SCENARIO_SUFFIX) + || g_str_has_suffix (path, GST_VALIDATE_VALIDATE_TEST_SUFFIX)) { GstStructure *meta = NULL; GList *tmp, *structures = gst_validate_structs_parse_from_gfile (f, (GstValidateGetIncludePathsFunc) diff --git a/subprojects/gst-devtools/validate/launcher/apps/gstvalidate.py b/subprojects/gst-devtools/validate/launcher/apps/gstvalidate.py index b9b11dd5ea..8cf45d7941 100644 --- a/subprojects/gst-devtools/validate/launcher/apps/gstvalidate.py +++ b/subprojects/gst-devtools/validate/launcher/apps/gstvalidate.py @@ -192,18 +192,24 @@ class GstValidateSimpleTestsGenerator(GstValidateTestsGenerator): super().__init__(name, test_manager) def populate_tests(self, uri_minfo_special_scenarios, scenarios): + validatetests = [] for root, _, files in os.walk(self.tests_dir): for f in files: name, ext = os.path.splitext(f) if ext != ".validatetest": continue - fpath = os.path.abspath(os.path.join(root, f)) - pathname = os.path.abspath(os.path.join(root, name)) - name = pathname.replace(os.path.commonpath([self.tests_dir, root]), '').replace('/', '.') - self.add_test(GstValidateSimpleTest(fpath, 'test' + name, - self.test_manager.options, - self.test_manager.reporter)) + validatetests.append(os.path.abspath(os.path.join(root, f))) + + for validatetest in self.test_manager.scenarios_manager.discover_scenarios(validatetests): + pathname, _ext = os.path.splitext(validatetest.path) + name = pathname.replace(os.path.commonpath([self.tests_dir, root]), '').replace('/', '.') + + self.add_test(GstValidateSimpleTest(validatetest.path, + 'test' + name, + self.test_manager.options, + self.test_manager.reporter, + test_info=validatetest)) class GstValidatePipelineTestsGenerator(GstValidateTestsGenerator): @@ -679,8 +685,10 @@ class GstValidateMixerTestsGenerator(GstValidatePipelineTestsGenerator): class GstValidateSimpleTest(GstValidateTest): - def __init__(self, test_file, *args, **kwargs): + def __init__(self, test_file, *args, test_info=None, **kwargs): self.test_file = test_file + self.test_info = test_info + super().__init__(GstValidateBaseTestManager.COMMAND, *args, **kwargs) def build_arguments(self): @@ -688,6 +696,12 @@ class GstValidateSimpleTest(GstValidateTest): if self.options.mute: self.add_arguments('--use-fakesinks') + def needs_http_server(self): + try: + return bool(self.test_info.needs_http_server) + except AttributeError: + return False + class GstValidateLaunchTest(GstValidateTest): @@ -1192,18 +1206,10 @@ not been tested and explicitly activated if you set use --wanted-tests ALL""") def needs_http_server(self): for test in self.list_tests(): - if self._is_test_wanted(test) and test.media_descriptor is not None: - protocol = test.media_descriptor.get_protocol() - uri = test.media_descriptor.get_uri() - uri_requires_http_server = False - if uri: - if 'http-server-port' in uri: - expanded_uri = uri % { - 'http-server-port': self.options.http_server_port} - uri_requires_http_server = expanded_uri.find( - "127.0.0.1:%s" % self.options.http_server_port) != -1 - if protocol in [Protocols.HTTP, Protocols.HLS, Protocols.DASH] or uri_requires_http_server: + if self._is_test_wanted(test): + if test.needs_http_server(): return True + return False def set_settings(self, options, args, reporter): diff --git a/subprojects/gst-devtools/validate/launcher/baseclasses.py b/subprojects/gst-devtools/validate/launcher/baseclasses.py index 0371e9d54c..3bd95b5601 100644 --- a/subprojects/gst-devtools/validate/launcher/baseclasses.py +++ b/subprojects/gst-devtools/validate/launcher/baseclasses.py @@ -881,6 +881,24 @@ class GstValidateTest(Test): else: self.scenario = scenario + def needs_http_server(self): + if self.media_descriptor is None: + return False + + protocol = self.media_descriptor.get_protocol() + uri = self.media_descriptor.get_uri() + uri_requires_http_server = False + if uri: + if 'http-server-port' in uri: + expanded_uri = uri % { + 'http-server-port': self.options.http_server_port} + uri_requires_http_server = expanded_uri.find( + "127.0.0.1:%s" % self.options.http_server_port) != -1 + if protocol in [Protocols.HTTP, Protocols.HLS, Protocols.DASH] or uri_requires_http_server: + return True + + return False + def kill_subprocess(self): Test.kill_subprocess(self) diff --git a/subprojects/gst-integration-testsuites/testsuites/validate_known_issues.py b/subprojects/gst-integration-testsuites/testsuites/validate_known_issues.py index 3cb8e6ef52..1b8ed72ceb 100644 --- a/subprojects/gst-integration-testsuites/testsuites/validate_known_issues.py +++ b/subprojects/gst-integration-testsuites/testsuites/validate_known_issues.py @@ -8,6 +8,7 @@ KNOWN_ISSUES = { r"^validate\.((?!glvideomixer).)*$", r"^validate\.((?!launch_pipeline).)*$", r"^validate\.((?!rtsp*).)*$", + r"^validate\.((?!dash*).)*$", ], "max_retries": 2, },