2014-01-09 17:43:15 +00:00
|
|
|
#!/usr//bin/python
|
|
|
|
#
|
|
|
|
# Copyright (c) 2014,Thibault Saunier <thibault.saunier@collabora.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# 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 os
|
2014-01-22 23:15:54 +00:00
|
|
|
import sys
|
2014-01-10 09:27:25 +00:00
|
|
|
import utils
|
2014-01-09 17:43:15 +00:00
|
|
|
import urlparse
|
|
|
|
import loggable
|
2014-02-06 16:24:30 +00:00
|
|
|
from optparse import OptionParser, OptionGroup
|
2014-01-09 17:43:15 +00:00
|
|
|
|
2014-01-13 16:31:57 +00:00
|
|
|
from httpserver import HTTPServer
|
2014-02-12 10:18:14 +00:00
|
|
|
from baseclasses import _TestsLauncher, ScenarioManager
|
2014-02-06 16:24:30 +00:00
|
|
|
from utils import printc, path2url, DEFAULT_MAIN_DIR, launch_command, Colors
|
2014-01-09 17:43:15 +00:00
|
|
|
|
2014-01-22 23:15:54 +00:00
|
|
|
|
2014-02-06 16:24:30 +00:00
|
|
|
QA_ASSETS = "gst-qa-assets"
|
2014-02-12 10:20:06 +00:00
|
|
|
MEDIAS_FOLDER = "medias"
|
2014-01-09 17:43:15 +00:00
|
|
|
DEFAULT_GST_QA_ASSETS_REPO = "git://people.freedesktop.org/~tsaunier/gst-qa-assets/"
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = OptionParser()
|
|
|
|
# FIXME:
|
|
|
|
#parser.add_option("-g", "--gdb", dest="gdb",
|
|
|
|
#action="store_true",
|
|
|
|
#default=False,
|
|
|
|
#help="Run applications into gdb")
|
2014-01-14 17:07:46 +00:00
|
|
|
parser.add_option("-f", "--forever", dest="forever",
|
|
|
|
action="store_true", default=False,
|
|
|
|
help="Keep running tests until one fails")
|
2014-01-24 15:38:12 +00:00
|
|
|
parser.add_option("-F", "--fatal-error", dest="fatal_error",
|
|
|
|
action="store_true", default=False,
|
|
|
|
help="Stop on first fail")
|
2014-01-09 17:43:15 +00:00
|
|
|
parser.add_option("-t", "--wanted-tests", dest="wanted_tests",
|
2014-01-22 23:15:54 +00:00
|
|
|
default=[],
|
|
|
|
action="append",
|
2014-01-09 17:43:15 +00:00
|
|
|
help="Define the tests to execute, it can be a regex")
|
2014-01-22 23:15:54 +00:00
|
|
|
parser.add_option("-b", "--blacklisted-tests", dest="blacklisted_tests",
|
|
|
|
default=[],
|
|
|
|
action="append",
|
2014-01-30 11:20:33 +00:00
|
|
|
help="Define the tests not to execute, it can be a regex.")
|
2014-01-09 17:43:15 +00:00
|
|
|
parser.add_option("-L", "--list-tests",
|
|
|
|
dest="list_tests",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="List tests and exit")
|
|
|
|
parser.add_option("-m", "--mute", dest="mute",
|
|
|
|
action="store_true", default=False,
|
|
|
|
help="Mute playback output, which mean that we use "
|
|
|
|
"a fakesink")
|
2014-01-10 09:27:25 +00:00
|
|
|
parser.add_option("-n", "--no-color", dest="no_color",
|
|
|
|
action="store_true", default=False,
|
|
|
|
help="Set it to output no colored text in the terminal")
|
2014-01-10 14:29:31 +00:00
|
|
|
parser.add_option("-g", "--generate-media-info", dest="generate_info",
|
|
|
|
action="store_true", default=False,
|
|
|
|
help="Set it in order to generate the missing .media_infos files")
|
2014-02-06 16:24:30 +00:00
|
|
|
|
|
|
|
dir_group = OptionGroup(parser, "Directories and files to be used by the launcher")
|
|
|
|
parser.add_option('--xunit-file', action='store',
|
|
|
|
dest='xunit_file', metavar="FILE",
|
|
|
|
default=None,
|
|
|
|
help=("Path to xml file to store the xunit report in. "
|
|
|
|
"Default is xunit.xml in the logs-dir directory"))
|
|
|
|
dir_group.add_option("-M", "--main-dir", dest="main_dir",
|
|
|
|
default=DEFAULT_MAIN_DIR,
|
|
|
|
help="Main directory where to put files."
|
|
|
|
"Logs will land into 'main_dir'" + os.pathsep + "'logs' and"
|
|
|
|
"assets will be cloned into 'main_dir'" + os.pathsep + "'gst-qa-assets'"
|
|
|
|
" if not explicitely changed")
|
|
|
|
dir_group.add_option("-o", "--output-dir", dest="outputdir",
|
|
|
|
action="store_true", default=os.path.join(DEFAULT_MAIN_DIR,
|
|
|
|
"logs"),
|
|
|
|
help="Directory where to store logs and rendered files")
|
|
|
|
dir_group.add_option("-l", "--logs-dir", dest="logsdir",
|
|
|
|
default=None,
|
|
|
|
help="Directory where to store logs, default is logs/ in "
|
|
|
|
"--output-dir result")
|
|
|
|
dir_group.add_option("-R", "--render-path", dest="dest",
|
|
|
|
default=None,
|
|
|
|
help="Set the path to which projects should be rendered")
|
|
|
|
dir_group.add_option("-p", "--medias-paths", dest="paths", action="append",
|
|
|
|
default=None,
|
|
|
|
help="Paths in which to look for media files, will be %s "
|
|
|
|
"if nothing specified" %
|
|
|
|
os.path.join(DEFAULT_MAIN_DIR, QA_ASSETS, "medias"))
|
|
|
|
dir_group.add_option("", "--clone-dir", dest="clone_dir",
|
|
|
|
default=None,
|
|
|
|
help="Paths in which to look for media files, will be %s "
|
|
|
|
"if nothing specified" %
|
|
|
|
[os.path.join(DEFAULT_MAIN_DIR, QA_ASSETS)])
|
|
|
|
parser.add_option_group(dir_group)
|
|
|
|
|
|
|
|
http_server_group = OptionGroup(parser, "Handle the HTTP server to be created")
|
|
|
|
http_server_group.add_option("", "--http-server-port", dest="http_server_port",
|
2014-01-13 16:31:57 +00:00
|
|
|
default=8079,
|
|
|
|
help="Port on which to run the http server on localhost")
|
2014-02-06 16:24:30 +00:00
|
|
|
http_server_group.add_option("-s", "--folder-for-http-server", dest="http_server_dir",
|
|
|
|
default=os.path.join(DEFAULT_MAIN_DIR, QA_ASSETS, "medias"),
|
|
|
|
help="Folder in which to create an http server on localhost")
|
|
|
|
parser.add_option_group(http_server_group)
|
|
|
|
|
|
|
|
assets_group = OptionGroup(parser, "Handle remote assets")
|
|
|
|
assets_group.add_option("-u", "--update-assets-command", dest="update_assets_command",
|
|
|
|
default="git pull --rebase",
|
|
|
|
help="Command to update assets")
|
|
|
|
assets_group.add_option("", "--get-assets-command", dest="get_assets_command",
|
|
|
|
default="git clone",
|
|
|
|
help="Command to get assets")
|
|
|
|
assets_group.add_option("", "--remote-assets-url", dest="remote_assets_url",
|
|
|
|
default=DEFAULT_GST_QA_ASSETS_REPO,
|
|
|
|
help="Url to the remote assets")
|
2014-03-19 16:03:05 +00:00
|
|
|
assets_group.add_option("-S", "--sync", dest="sync", action="store_true",
|
|
|
|
default=False, help="Synchronize asset repository")
|
2014-02-06 16:24:30 +00:00
|
|
|
parser.add_option_group(assets_group)
|
2014-01-10 10:36:10 +00:00
|
|
|
|
2014-01-09 17:43:15 +00:00
|
|
|
loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False)
|
|
|
|
|
|
|
|
tests_launcher = _TestsLauncher()
|
|
|
|
tests_launcher.add_options(parser)
|
2014-01-22 23:15:54 +00:00
|
|
|
|
2014-01-30 11:20:33 +00:00
|
|
|
blacklisted = tests_launcher.get_blacklisted()
|
|
|
|
if blacklisted:
|
|
|
|
msg = "Currently 'hardcoded' blacklisted tests:\n"
|
|
|
|
for name, bug in blacklisted:
|
|
|
|
sys.argv.extend(["-b", name])
|
|
|
|
msg += " + %s -- bug: %s\n" % (name, bug)
|
|
|
|
|
|
|
|
printc(msg, Colors.FAIL, True)
|
2014-01-22 23:15:54 +00:00
|
|
|
|
2014-01-09 17:43:15 +00:00
|
|
|
(options, args) = parser.parse_args()
|
2014-01-30 23:23:29 +00:00
|
|
|
if options.logsdir is None:
|
|
|
|
options.logsdir = os.path.join(options.outputdir, "logs")
|
2014-01-09 17:43:15 +00:00
|
|
|
if options.xunit_file is None:
|
|
|
|
options.xunit_file = os.path.join(options.logsdir, "xunit.xml")
|
2014-02-06 16:24:30 +00:00
|
|
|
|
2014-01-09 17:43:15 +00:00
|
|
|
if options.dest is None:
|
2014-01-30 23:23:29 +00:00
|
|
|
options.dest = os.path.join(options.outputdir, "rendered")
|
2014-01-10 09:58:54 +00:00
|
|
|
if not os.path.exists(options.dest):
|
|
|
|
os.makedirs(options.dest)
|
2014-01-09 17:43:15 +00:00
|
|
|
if urlparse.urlparse(options.dest).scheme == "":
|
|
|
|
options.dest = path2url(options.dest)
|
2014-02-06 16:24:30 +00:00
|
|
|
|
2014-01-10 09:27:25 +00:00
|
|
|
if options.no_color:
|
|
|
|
utils.desactivate_colors()
|
2014-02-06 16:24:30 +00:00
|
|
|
if options.clone_dir is None:
|
|
|
|
options.clone_dir = os.path.join(DEFAULT_MAIN_DIR, QA_ASSETS)
|
|
|
|
if options.paths is None:
|
2014-02-12 10:20:06 +00:00
|
|
|
options.paths = os.path.join(options.clone_dir, MEDIAS_FOLDER)
|
2014-01-10 09:27:25 +00:00
|
|
|
|
2014-01-09 17:43:15 +00:00
|
|
|
tests_launcher.set_settings(options, args)
|
|
|
|
|
2014-03-19 16:03:05 +00:00
|
|
|
if options.remote_assets_url and options.sync:
|
2014-02-06 16:24:30 +00:00
|
|
|
if os.path.exists(options.clone_dir):
|
|
|
|
launch_command("cd %s && %s" % (options.clone_dir,
|
|
|
|
options.update_assets_command))
|
2014-01-09 17:43:15 +00:00
|
|
|
else:
|
2014-02-06 16:24:30 +00:00
|
|
|
launch_command("%s %s %s" % (options.get_assets_command,
|
|
|
|
options.remote_assets_url,
|
|
|
|
options.clone_dir))
|
2014-01-09 17:43:15 +00:00
|
|
|
|
2014-02-12 10:18:14 +00:00
|
|
|
# Ensure that the scenario manager singleton is ready to be used
|
|
|
|
ScenarioManager().config = options
|
2014-01-09 17:43:15 +00:00
|
|
|
tests_launcher.list_tests()
|
2014-01-10 14:29:31 +00:00
|
|
|
|
2014-03-19 16:04:14 +00:00
|
|
|
if options.list_tests:
|
|
|
|
l = tests_launcher.tests
|
|
|
|
l.sort()
|
|
|
|
for test in l:
|
|
|
|
printc(test)
|
|
|
|
return 0
|
|
|
|
|
2014-01-13 16:31:57 +00:00
|
|
|
httpsrv = HTTPServer(options)
|
|
|
|
if tests_launcher.needs_http_server():
|
|
|
|
httpsrv.start()
|
|
|
|
|
|
|
|
e = None
|
|
|
|
try:
|
|
|
|
tests_launcher.run_tests()
|
|
|
|
tests_launcher.final_report()
|
|
|
|
except Exception as e:
|
|
|
|
pass
|
|
|
|
finally:
|
|
|
|
httpsrv.stop()
|
|
|
|
if e is not None:
|
|
|
|
raise
|
2014-01-09 17:43:15 +00:00
|
|
|
|
|
|
|
return 0
|