From: Thibault Saunier Date: Fri, 9 Sep 2016 15:09:45 +0000 (-0300) Subject: meson:validate:test: Properly set paths to run launcher based tests X-Git-Tag: 1.19.3~491^2~949 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c9fe14293f2601766819cad488cf8eb59cff317;p=platform%2Fupstream%2Fgstreamer.git meson:validate:test: Properly set paths to run launcher based tests Adding a --validate-tools-path option to the launcher, allowing to pass it from meson. --- diff --git a/validate/launcher/apps/gstvalidate.py b/validate/launcher/apps/gstvalidate.py index 02f394c..704ee4c 100644 --- a/validate/launcher/apps/gstvalidate.py +++ b/validate/launcher/apps/gstvalidate.py @@ -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 diff --git a/validate/launcher/baseclasses.py b/validate/launcher/baseclasses.py index 9c626bc..6106ad4 100644 --- a/validate/launcher/baseclasses.py +++ b/validate/launcher/baseclasses.py @@ -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: diff --git a/validate/launcher/utils.py b/validate/launcher/utils.py index b461827..03b3a3f 100644 --- a/validate/launcher/utils.py +++ b/validate/launcher/utils.py @@ -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): diff --git a/validate/tests/check/meson.build b/validate/tests/check/meson.build index 9c555eb..e61f14d 100644 --- a/validate/tests/check/meson.build +++ b/validate/tests/check/meson.build @@ -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() diff --git a/validate/tests/check/getpluginsdir b/validate/tests/getpluginsdir similarity index 100% rename from validate/tests/check/getpluginsdir rename to validate/tests/getpluginsdir diff --git a/validate/tests/launcher_tests/meson.build b/validate/tests/launcher_tests/meson.build index 91e101e..8f16792 100644 --- a/validate/tests/launcher_tests/meson.build +++ b/validate/tests/launcher_tests/meson.build @@ -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 diff --git a/validate/tests/meson.build b/validate/tests/meson.build index 2153ca1..2f6cd48 100644 --- a/validate/tests/meson.build +++ b/validate/tests/meson.build @@ -1,4 +1,5 @@ # FIXME: make check work on windows +getpluginsdir = find_program('getpluginsdir') if host_machine.system() != 'windows' subdir('check') endif