validate:launcher: Start the server only when actually needed to run filtered tests

This commit is contained in:
Thibault Saunier 2014-03-26 11:00:32 +01:00
parent ff4879c749
commit 5510b96639

View file

@ -170,12 +170,13 @@ class GstValidateLaunchTest(GstValidateTest):
class GstValidateMediaCheckTest(Test): class GstValidateMediaCheckTest(Test):
def __init__(self, classname, options, reporter, media_info_path, uri, timeout=DEFAULT_TIMEOUT): def __init__(self, classname, options, reporter, file_infos, uri, timeout=DEFAULT_TIMEOUT):
super(GstValidateMediaCheckTest, self).__init__(G_V_DISCOVERER_COMMAND, classname, super(GstValidateMediaCheckTest, self).__init__(G_V_DISCOVERER_COMMAND, classname,
options, reporter, options, reporter,
timeout=timeout) timeout=timeout)
self._uri = uri self._uri = uri
self._media_info_path = urlparse.urlparse(media_info_path).path self.file_infos = file_infos
self._media_info_path = urlparse.urlparse(file_infos.path).path
def build_arguments(self): def build_arguments(self):
self.add_arguments(self._uri, "--expected-results", self.add_arguments(self._uri, "--expected-results",
@ -298,7 +299,7 @@ class GstValidateManager(TestsManager, Loggable):
self.add_test(GstValidateMediaCheckTest(classname, self.add_test(GstValidateMediaCheckTest(classname,
self.options, self.options,
self.reporter, self.reporter,
mediainfo.path, mediainfo,
uri, uri,
timeout=timeout)) timeout=timeout))
@ -314,6 +315,7 @@ class GstValidateManager(TestsManager, Loggable):
self.reporter, self.reporter,
comb, uri, comb, uri,
mediainfo.config)) mediainfo.config))
return self.tests
def _check_discovering_info(self, media_info, uri=None): def _check_discovering_info(self, media_info, uri=None):
self.debug("Checking %s", media_info) self.debug("Checking %s", media_info)
@ -426,10 +428,15 @@ class GstValidateManager(TestsManager, Loggable):
scenario=scenario)) scenario=scenario))
def needs_http_server(self): def needs_http_server(self):
for uri, mediainfo in self._list_uris(): for test in self.list_tests():
if urlparse.urlparse(uri).scheme == Protocols.HTTP and \ if self._is_test_wanted(test):
protocol = test.file_infos.config.get("file-info", "protocol")
uri = test.file_infos.config.get("file-info", "uri")
if protocol == Protocols.HTTP and \
"127.0.0.1:%s" % (self.options.http_server_port) in uri: "127.0.0.1:%s" % (self.options.http_server_port) in uri:
return True return True
return False
def get_blacklisted(self): def get_blacklisted(self):
return G_V_BLACKLISTED_TESTS return G_V_BLACKLISTED_TESTS