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-04-30 09:52:00 +00:00
|
|
|
from argparse import ArgumentParser
|
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-03-19 17:09:09 +00:00
|
|
|
from utils import printc, path2url, DEFAULT_MAIN_DIR, DEFAULT_GST_QA_ASSETS, 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():
|
2014-04-30 09:52:00 +00:00
|
|
|
parser = ArgumentParser()
|
|
|
|
parser.add_argument("-d", "--debug", dest="debug",
|
2014-03-26 18:37:44 +00:00
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="Let user debug the process on timeout")
|
2014-04-30 09:52:00 +00:00
|
|
|
parser.add_argument("-f", "--forever", dest="forever",
|
2014-01-14 17:07:46 +00:00
|
|
|
action="store_true", default=False,
|
|
|
|
help="Keep running tests until one fails")
|
2014-04-30 09:52:00 +00:00
|
|
|
parser.add_argument("-F", "--fatal-error", dest="fatal_error",
|
2014-01-24 15:38:12 +00:00
|
|
|
action="store_true", default=False,
|
|
|
|
help="Stop on first fail")
|
2014-04-30 09:52:00 +00:00
|
|
|
parser.add_argument("-t", "--wanted-tests", dest="wanted_tests",
|
2014-01-22 23:15:54 +00:00
|
|
|
default=[],
|
|
|
|
action="append",
|
2014-04-25 11:18:41 +00:00
|
|
|
help="Define the tests to execute, it can be a regex"
|
|
|
|
" if it contains defaults_only, only default scenarios"
|
|
|
|
" will be executed")
|
2014-04-30 09:52:00 +00:00
|
|
|
parser.add_argument("-b", "--blacklisted-tests", dest="blacklisted_tests",
|
2014-01-22 23:15:54 +00:00
|
|
|
default=[],
|
|
|
|
action="append",
|
2014-01-30 11:20:33 +00:00
|
|
|
help="Define the tests not to execute, it can be a regex.")
|
2014-04-30 09:52:00 +00:00
|
|
|
parser.add_argument("-L", "--list-tests",
|
2014-01-09 17:43:15 +00:00
|
|
|
dest="list_tests",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="List tests and exit")
|
2014-04-30 09:52:00 +00:00
|
|
|
parser.add_argument("-m", "--mute", dest="mute",
|
2014-01-09 17:43:15 +00:00
|
|
|
action="store_true", default=False,
|
|
|
|
help="Mute playback output, which mean that we use "
|
|
|
|
"a fakesink")
|
2014-04-30 09:52:00 +00:00
|
|
|
parser.add_argument("-n", "--no-color", dest="no_color",
|
2014-01-10 09:27:25 +00:00
|
|
|
action="store_true", default=False,
|
|
|
|
help="Set it to output no colored text in the terminal")
|
2014-04-30 09:52:00 +00:00
|
|
|
parser.add_argument("-g", "--generate-media-info", dest="generate_info",
|
2014-01-10 14:29:31 +00:00
|
|
|
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
|
|
|
|
2014-04-30 09:52:00 +00:00
|
|
|
dir_group = parser.add_argument_group("Directories and files to be used by the launcher")
|
|
|
|
parser.add_argument('--xunit-file', action='store',
|
2014-02-06 16:24:30 +00:00
|
|
|
dest='xunit_file', metavar="FILE",
|
|
|
|
default=None,
|
|
|
|
help=("Path to xml file to store the xunit report in. "
|
2014-03-19 17:09:09 +00:00
|
|
|
"Default is LOGSDIR/xunit.xml"))
|
2014-04-30 09:52:00 +00:00
|
|
|
dir_group.add_argument("-M", "--main-dir", dest="main_dir",
|
2014-02-06 16:24:30 +00:00
|
|
|
default=DEFAULT_MAIN_DIR,
|
2014-03-19 17:09:09 +00:00
|
|
|
help="Main directory where to put files. Default is %s" % DEFAULT_MAIN_DIR)
|
2014-04-30 09:52:00 +00:00
|
|
|
dir_group.add_argument("-o", "--output-dir", dest="output_dir",
|
2014-03-19 17:09:09 +00:00
|
|
|
default=None,
|
|
|
|
help="Directory where to store logs and rendered files. Default is MAIN_DIR")
|
2014-04-30 09:52:00 +00:00
|
|
|
dir_group.add_argument("-l", "--logs-dir", dest="logsdir",
|
2014-02-06 16:24:30 +00:00
|
|
|
default=None,
|
2014-03-19 17:09:09 +00:00
|
|
|
help="Directory where to store logs, default is OUTPUT_DIR/logs")
|
2014-04-30 09:52:00 +00:00
|
|
|
dir_group.add_argument("-R", "--render-path", dest="dest",
|
2014-02-06 16:24:30 +00:00
|
|
|
default=None,
|
2014-03-19 17:09:09 +00:00
|
|
|
help="Set the path to which projects should be rendered, default is OUTPUT_DIR/rendered")
|
2014-04-30 09:52:00 +00:00
|
|
|
dir_group.add_argument("-p", "--medias-paths", dest="paths", action="append",
|
2014-02-06 16:24:30 +00:00
|
|
|
default=None,
|
2014-03-19 17:09:09 +00:00
|
|
|
help="Paths in which to look for media files, default is MAIN_DIR/gst-qa-assets/media")
|
2014-04-30 09:52:00 +00:00
|
|
|
dir_group.add_argument("-a", "--clone-dir", dest="clone_dir",
|
2014-02-06 16:24:30 +00:00
|
|
|
default=None,
|
2014-03-19 17:09:09 +00:00
|
|
|
help="Paths in which to look for media files, default is MAIN_DIR/gst-qa-assets")
|
2014-02-06 16:24:30 +00:00
|
|
|
|
2014-04-30 09:52:00 +00:00
|
|
|
http_server_group = parser.add_argument_group("Handle the HTTP server to be created")
|
|
|
|
http_server_group.add_argument("--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-04-30 09:52:00 +00:00
|
|
|
http_server_group.add_argument("-s", "--folder-for-http-server", dest="http_server_dir",
|
2014-03-19 17:09:09 +00:00
|
|
|
default=None,
|
|
|
|
help="Folder in which to create an http server on localhost. Default is PATHS")
|
2014-02-06 16:24:30 +00:00
|
|
|
|
2014-04-30 09:52:00 +00:00
|
|
|
assets_group = parser.add_argument_group("Handle remote assets")
|
|
|
|
assets_group.add_argument("-u", "--update-assets-command", dest="update_assets_command",
|
2014-04-28 11:08:09 +00:00
|
|
|
default="git fetch %s && git checkout FETCH_HEAD && git annex get ."
|
|
|
|
% (DEFAULT_GST_QA_ASSETS_REPO, ),
|
2014-02-06 16:24:30 +00:00
|
|
|
help="Command to update assets")
|
2014-04-30 09:52:00 +00:00
|
|
|
assets_group.add_argument("--get-assets-command", dest="get_assets_command",
|
2014-02-06 16:24:30 +00:00
|
|
|
default="git clone",
|
|
|
|
help="Command to get assets")
|
2014-04-30 09:52:00 +00:00
|
|
|
assets_group.add_argument("--remote-assets-url", dest="remote_assets_url",
|
2014-02-06 16:24:30 +00:00
|
|
|
default=DEFAULT_GST_QA_ASSETS_REPO,
|
2014-03-19 17:09:09 +00:00
|
|
|
help="Url to the remote assets (default:%s)" % DEFAULT_GST_QA_ASSETS_REPO)
|
2014-04-30 09:52:00 +00:00
|
|
|
assets_group.add_argument("-S", "--sync", dest="sync", action="store_true",
|
2014-03-19 16:03:05 +00:00
|
|
|
default=False, help="Synchronize asset repository")
|
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-04-30 09:52:00 +00:00
|
|
|
(options, args) = parser.parse_known_args()
|
2014-01-30 11:20:33 +00:00
|
|
|
|
2014-03-19 17:09:09 +00:00
|
|
|
# Get absolute path for main_dir and base everything on that
|
|
|
|
options.main_dir = os.path.abspath(options.main_dir)
|
2014-01-22 23:15:54 +00:00
|
|
|
|
2014-03-19 17:09:09 +00:00
|
|
|
# default for output_dir is MAINDIR
|
|
|
|
if not options.output_dir:
|
|
|
|
options.output_dir = options.main_dir
|
|
|
|
else:
|
|
|
|
options.output_dir = os.path.abspath(options.output_dir)
|
|
|
|
|
|
|
|
# other output directories
|
2014-01-30 23:23:29 +00:00
|
|
|
if options.logsdir is None:
|
2014-03-19 17:09:09 +00:00
|
|
|
options.logsdir = os.path.join(options.output_dir, "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")
|
|
|
|
if options.dest is None:
|
2014-03-19 17:09:09 +00:00
|
|
|
options.dest = os.path.join(options.output_dir, "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:
|
2014-03-19 17:09:09 +00:00
|
|
|
options.clone_dir = os.path.join(options.main_dir, QA_ASSETS)
|
2014-02-06 16:24:30 +00:00
|
|
|
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-03-19 17:09:09 +00:00
|
|
|
if options.http_server_dir is None:
|
|
|
|
options.http_server_dir = options.paths
|
|
|
|
|
2014-03-19 17:42:37 +00:00
|
|
|
if not options.sync and not os.path.exists(options.clone_dir) and \
|
|
|
|
options.clone_dir == os.path.join(options.clone_dir, MEDIAS_FOLDER):
|
|
|
|
printc("Media path (%s) does not exists. Forgot to run --sync ?"
|
|
|
|
% options.clone_dir, Colors.FAIL, True)
|
2014-03-19 17:09:09 +00:00
|
|
|
return -1
|
|
|
|
|
2014-03-19 16:13:14 +00:00
|
|
|
blacklisted = tests_launcher.get_blacklisted()
|
|
|
|
if blacklisted:
|
|
|
|
msg = "Currently 'hardcoded' blacklisted tests:\n"
|
|
|
|
for name, bug in blacklisted:
|
2014-04-15 13:26:36 +00:00
|
|
|
options.blacklisted_tests.append(name)
|
2014-03-19 16:13:14 +00:00
|
|
|
msg += " + %s -- bug: %s\n" % (name, bug)
|
|
|
|
|
|
|
|
printc(msg, Colors.FAIL, True)
|
|
|
|
|
2014-04-15 13:26:36 +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,
|
2014-04-28 11:08:09 +00:00
|
|
|
options.update_assets_command),
|
|
|
|
fails=True)
|
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,
|
2014-04-28 11:08:09 +00:00
|
|
|
options.clone_dir),
|
|
|
|
fails=True)
|
|
|
|
launch_command("cd %s && %s" % (options.clone_dir,
|
|
|
|
options.update_assets_command),
|
|
|
|
fails=True)
|
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)
|
2014-04-25 08:23:21 +00:00
|
|
|
|
|
|
|
printc("\nNumber of tests: %d" % len (l), Colors.OKGREEN)
|
2014-03-19 16:04:14 +00:00
|
|
|
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
|