validate: Handle testfiles that need an HTTP server
authorThibault Saunier <tsaunier@igalia.com>
Tue, 4 Oct 2022 22:14:49 +0000 (19:14 -0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 5 Oct 2022 20:29:22 +0000 (20:29 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3122>

subprojects/gst-devtools/validate/gst/validate/gst-validate-internal.h
subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c
subprojects/gst-devtools/validate/launcher/apps/gstvalidate.py
subprojects/gst-devtools/validate/launcher/baseclasses.py
subprojects/gst-integration-testsuites/testsuites/validate_known_issues.py

index aee26fd..30921fb 100644 (file)
@@ -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);
index 115b00f..e9ef125 100644 (file)
@@ -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)
index b9b11dd..8cf45d7 100644 (file)
@@ -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):
index 0371e9d..3bd95b5 100644 (file)
@@ -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)
 
index 3cb8e6e..1b8ed72 100644 (file)
@@ -8,6 +8,7 @@ KNOWN_ISSUES = {
             r"^validate\.((?!glvideomixer).)*$",
             r"^validate\.((?!launch_pipeline).)*$",
             r"^validate\.((?!rtsp*).)*$",
+            r"^validate\.((?!dash*).)*$",
         ],
         "max_retries": 2,
     },