meson:validate:test: Properly set paths to run launcher based tests
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Fri, 9 Sep 2016 15:09:45 +0000 (12:09 -0300)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Fri, 9 Sep 2016 15:24:54 +0000 (12:24 -0300)
Adding a --validate-tools-path option to the launcher, allowing
to pass it from meson.

validate/launcher/apps/gstvalidate.py
validate/launcher/baseclasses.py
validate/launcher/utils.py
validate/tests/check/meson.build
validate/tests/getpluginsdir [moved from validate/tests/check/getpluginsdir with 100% similarity]
validate/tests/launcher_tests/meson.build
validate/tests/meson.build

index 02f394c..704ee4c 100644 (file)
@@ -16,8 +16,8 @@
 # License along with this program; if not, write to the
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
+import argparse
 import os
-import sys
 import time
 import urlparse
 import subprocess
@@ -37,13 +37,16 @@ from launcher.utils import path2url, url2path, DEFAULT_TIMEOUT, which, \
 #
 
 # definitions of commands to use
-GST_VALIDATE_COMMAND = "gst-validate-1.0"
-GST_VALIDATE_TRANSCODING_COMMAND = "gst-validate-transcoding-1.0"
-G_V_DISCOVERER_COMMAND = "gst-validate-media-check-1.0"
-if "win32" in sys.platform:
-    GST_VALIDATE_COMMAND += ".exe"
-    GST_VALIDATE_TRANSCODING_COMMAND += ".exe"
-    G_V_DISCOVERER_COMMAND += ".exe"
+parser = argparse.ArgumentParser(add_help=False)
+parser.add_argument("--validate-tools-path", dest="validate_tools_path",
+                default="",
+                help="defines the paths to look for GstValidate tools.")
+options, args = parser.parse_known_args()
+
+GST_VALIDATE_COMMAND = which("gst-validate-1.0", options.validate_tools_path)
+GST_VALIDATE_TRANSCODING_COMMAND = which("gst-validate-transcoding-1.0", options.validate_tools_path)
+G_V_DISCOVERER_COMMAND = which("gst-validate-media-check-1.0", options.validate_tools_path)
+ScenarioManager.GST_VALIDATE_COMMAND = GST_VALIDATE_COMMAND
 
 AUDIO_ONLY_FILE_TRANSCODING_RATIO = 5
 
@@ -555,9 +558,15 @@ class GstValidateTestManager(GstValidateBaseTestManager):
         self._default_generators_registered = False
 
     def init(self):
-        if which(GST_VALIDATE_COMMAND) and which(GST_VALIDATE_TRANSCODING_COMMAND):
-            return True
-        return False
+        for command, name in [
+                (GST_VALIDATE_TRANSCODING_COMMAND, "gst-validate-1.0"),
+                (GST_VALIDATE_COMMAND, "gst-validate-transcoding-1.0"),
+                (G_V_DISCOVERER_COMMAND, "gst-validate-media-check-1.0")]:
+            if not command:
+                self.error("%s not found" % command)
+                return False
+
+        return True
 
     def add_options(self, parser):
         group = parser.add_argument_group("GstValidate tools specific options"
@@ -566,6 +575,8 @@ class GstValidateTestManager(GstValidateBaseTestManager):
 not been tested and explicitely activated if you set use --wanted-tests ALL""")
         group.add_argument("--validate-check-uri", dest="validate_uris",
                            action="append", help="defines the uris to run default tests on")
+        group.add_argument("--validate-tools-path", dest="validate_tools_path",
+                           action="append", help="defines the paths to look for GstValidate tools.")
 
     def print_valgrind_bugs(self):
         # Look for all the 'pending' bugs in our supp file
index 9c626bc..6106ad4 100644 (file)
@@ -1519,9 +1519,7 @@ class ScenarioManager(Loggable):
     all_scenarios = []
 
     FILE_EXTENSION = "scenario"
-    GST_VALIDATE_COMMAND = "gst-validate-1.0"
-    if "win32" in sys.platform:
-        GST_VALIDATE_COMMAND += ".exe"
+    GST_VALIDATE_COMMAND = ""
 
     def __new__(cls, *args, **kwargs):
         if not cls._instance:
index b461827..03b3a3f 100644 (file)
@@ -85,21 +85,23 @@ def mkdir(directory):
         pass
 
 
-def which(name):
-    result = []
+def which(name, extra_path=None):
     exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
-    path = os.environ.get('PATH', None)
-    if path is None:
+    path = os.environ.get('PATH', '')
+    if extra_path:
+        path = extra_path + os.pathsep + path
+    if not path:
         return []
-    for p in os.environ.get('PATH', '').split(os.pathsep):
+
+    for p in path.split(os.pathsep):
         p = os.path.join(p, name)
         if os.access(p, os.X_OK):
-            result.append(p)
+            return p
         for e in exts:
             pext = p + e
             if os.access(pext, os.X_OK):
-                result.append(pext)
-    return result
+                return pext
+    return None
 
 
 def get_color_for_result(result):
index 9c555eb..e61f14d 100644 (file)
@@ -14,7 +14,6 @@ test_defines = [
   '-DGST_USE_UNSTABLE_API',
 ]
 
-getpluginsdir = find_program('getpluginsdir')
 runcmd = run_command(getpluginsdir, 'gstreamer', 'gstreamer-' + apiversion)
 if runcmd.returncode() == 0
     needed_plugins_dirs = runcmd.stdout().strip()
index 91e101e..8f16792 100644 (file)
@@ -1,9 +1,26 @@
 launcher = find_program(meson.build_root() + '/validate/tools/gst-validate-launcher',
     required : false)
 
+runcmd = run_command(getpluginsdir, 'gstreamer', 'gstreamer-' + apiversion,
+    'gst-plugins-base', 'gst-plugins-base-' + apiversion)
+if runcmd.returncode() == 0
+    needed_plugins_dirs = runcmd.stdout().strip()
+    message('Using GStreamer plug-ins in ' + needed_plugins_dirs)
+else
+    error('Could not determine GStreamer plugins directory for unit tests.')
+endif
+
+test_env = [
+    'GST_PLUGIN_SYSTEM_PATH_1_0=',
+    'GST_PLUGIN_PATH_1_0=' + needed_plugins_dirs,
+    'GST_PLUGIN_SCANNER_1_0='+ meson.build_root() + '/libs/gst/helpers/gst-plugin-scanner',
+]
+
 if launcher.found()
     test_name = 'launcher_tests'
     test(test_name, launcher, args: ['-o', meson.build_root() + '/validate-launcher-output/',
-      meson.current_source_dir() + '/test_validate.py'],
-      env: ['GST_REGISTRY=@0@/@1@.registry'.format(meson.current_build_dir(), test_name)])
+      meson.current_source_dir() + '/test_validate.py', '--validate-tools-path',
+      meson.build_root() + '/validate/tools/'],
+      env: ['GST_REGISTRY=@0@/@1@.registry'.format(meson.current_build_dir(), test_name)] +
+      test_env)
 endif
index 2153ca1..2f6cd48 100644 (file)
@@ -1,4 +1,5 @@
 # FIXME: make check work on windows
+getpluginsdir = find_program('getpluginsdir')
 if host_machine.system() != 'windows'
 subdir('check')
 endif