validate: launcher: add the debug logger from pitivi

It is way more powerfull, simple to use and usefull
than the stock python one and has been proved to work reliably
This commit is contained in:
Thibault Saunier 2014-01-08 18:51:14 +01:00
parent b51e143fdf
commit e591882794
5 changed files with 1241 additions and 28 deletions

View file

@ -21,7 +21,7 @@ import subprocess
import urlparse import urlparse
import urllib import urllib
import ConfigParser import ConfigParser
import logging from loggable import Loggable
from testdefinitions import Test, TestsManager, DEFAULT_TIMEOUT from testdefinitions import Test, TestsManager, DEFAULT_TIMEOUT
@ -70,12 +70,13 @@ class GstValidateTest(Test):
self.add_arguments(self.pipeline_desc) self.add_arguments(self.pipeline_desc)
class GstValidateManager(TestsManager): class GstValidateManager(TestsManager, Loggable):
name = "validate" name = "validate"
def __init__(self): def __init__(self):
super(GstValidateManager, self).__init__() TestsManager.__init__(self)
Loggable.__init__(self)
self._uris = [] self._uris = []
def add_options(self, group): def add_options(self, group):
@ -92,7 +93,7 @@ class GstValidateManager(TestsManager):
self._add_test(name, scenario, pipe) self._add_test(name, scenario, pipe)
def _check_discovering_info(self, media_info, uri=None): def _check_discovering_info(self, media_info, uri=None):
logging.debug("Checking %s", media_info) self.debug("Checking %s", media_info)
config = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
f = open(media_info) f = open(media_info)
config.readfp(f) config.readfp(f)
@ -110,7 +111,7 @@ class GstValidateManager(TestsManager):
break break
self._uris.append((uri, config)) self._uris.append((uri, config))
except ConfigParser.NoOptionError as e: except ConfigParser.NoOptionError as e:
logging.debug("Exception: %s for %s", e, media_info) self.debug("Exception: %s for %s", e, media_info)
pass pass
f.close() f.close()
@ -133,8 +134,8 @@ class GstValidateManager(TestsManager):
return True return True
except subprocess.CalledProcessError: except subprocess.CalledProcessError as e:
logging.debug("Exception: %s", e) self.debug("Exception: %s", e)
return False return False
def _list_uris(self): def _list_uris(self):
@ -148,7 +149,7 @@ class GstValidateManager(TestsManager):
for path in self.options.paths: for path in self.options.paths:
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
for f in files: for f in files:
fpath = os.path.join(path, root,f) fpath = os.path.join(path, root, f)
if os.path.isdir(fpath) or fpath.endswith(MEDIA_INFO_EXT): if os.path.isdir(fpath) or fpath.endswith(MEDIA_INFO_EXT):
continue continue
elif fpath.endswith(STREAM_INFO): elif fpath.endswith(STREAM_INFO):
@ -156,7 +157,7 @@ class GstValidateManager(TestsManager):
else: else:
self._discover_file(path2url(fpath), fpath) self._discover_file(path2url(fpath), fpath)
logging.debug("Uris found: %s", self._uris) self.debug("Uris found: %s", self._uris)
return self._uris return self._uris
@ -169,7 +170,7 @@ class GstValidateManager(TestsManager):
return name return name
def _add_test(self, name, scenario, pipe): def _add_playback_test(self, name, scenario, pipe):
if self.options.mute: if self.options.mute:
if "autovideosink" in pipe: if "autovideosink" in pipe:
pipe = pipe.replace("autovideosink", "fakesink") pipe = pipe.replace("autovideosink", "fakesink")
@ -181,7 +182,7 @@ class GstValidateManager(TestsManager):
npipe = pipe npipe = pipe
if scenario in SEEKING_REQUIERED_SCENARIO: if scenario in SEEKING_REQUIERED_SCENARIO:
if config.getboolean("media-info", "seekable") is False: if config.getboolean("media-info", "seekable") is False:
logging.debug("Do not run %s as %s does not support seeking", self.debug("Do not run %s as %s does not support seeking",
scenario, uri) scenario, uri)
continue continue
@ -193,7 +194,7 @@ class GstValidateManager(TestsManager):
fname = "%s.%s" % (self._get_fname(name, scenario, fname = "%s.%s" % (self._get_fname(name, scenario,
config.get("file-info", "protocol")), config.get("file-info", "protocol")),
os.path.basename(uri).replace(".", "_")) os.path.basename(uri).replace(".", "_"))
logging.debug("Adding: %s", fname) self.debug("Adding: %s", fname)
self.tests.append(GstValidateTest(fname, self.tests.append(GstValidateTest(fname,
self.options, self.options,
@ -203,7 +204,7 @@ class GstValidateManager(TestsManager):
config) config)
) )
else: else:
logging.debug("Adding: %s", name) self.debug("Adding: %s", name)
self.tests.append(GstValidateTest(self._get_fname(fname, scenario), self.tests.append(GstValidateTest(self._get_fname(fname, scenario),
self.options, self.options,
self.reporter, self.reporter,

View file

@ -18,7 +18,7 @@
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
import os import os
import logging import loggable
from testdefinitions import _TestsLauncher, DEFAULT_QA_SAMPLE_PATH from testdefinitions import _TestsLauncher, DEFAULT_QA_SAMPLE_PATH
from utils import printc from utils import printc
from optparse import OptionParser from optparse import OptionParser
@ -60,13 +60,7 @@ def main():
action="store_true", default=False, action="store_true", default=False,
help="Mute playback output, which mean that we use " help="Mute playback output, which mean that we use "
"a fakesink") "a fakesink")
try: loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False)
level = getattr(logging,
os.environ["GST_VALIDATE_LAUNCHER_DEBUG"].upper(),
None)
logging.basicConfig(level=level)
except:
pass
tests_launcher = _TestsLauncher() tests_launcher = _TestsLauncher()
tests_launcher.add_options(parser) tests_launcher.add_options(parser)

1215
validate/tools/loggable.py Normal file

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@
import os import os
import re import re
import codecs import codecs
import logging from loggable import Loggable
from xml.sax import saxutils from xml.sax import saxutils
from utils import mkdir, Result, printc from utils import mkdir, Result, printc
@ -46,10 +46,12 @@ def escape_cdata(cdata):
return xml_safe(cdata).replace(']]>', ']]>]]&gt;<![CDATA[') return xml_safe(cdata).replace(']]>', ']]>]]&gt;<![CDATA[')
class Reporter(object): class Reporter(Loggable):
name = 'simple' name = 'simple'
def __init__(self, options): def __init__(self, options):
Loggable.__init__(self)
self._current_test = None self._current_test = None
self.out = None self.out = None
self.options = options self.options = options
@ -75,7 +77,7 @@ class Reporter(object):
self.stats["passed"] += 1 self.stats["passed"] += 1
def add_results(self, test): def add_results(self, test):
logging.debug("%s", test) self.debug("%s", test)
if test.result == Result.PASSED: if test.result == Result.PASSED:
self.set_passed(test) self.set_passed(test)
elif test.result == Result.FAILED or \ elif test.result == Result.FAILED or \
@ -132,7 +134,7 @@ class XunitReporter(Reporter):
The file includes a report of test errors and failures. The file includes a report of test errors and failures.
""" """
logging.debug("Writing XML file to: %s", self.options.xunit_file) self.debug("Writing XML file to: %s", self.options.xunit_file)
self.xml_file = codecs.open(self.options.xunit_file, 'w', self.xml_file = codecs.open(self.options.xunit_file, 'w',
self.encoding, 'replace') self.encoding, 'replace')
self.stats['encoding'] = self.encoding self.stats['encoding'] = self.encoding

View file

@ -24,7 +24,7 @@ import re
import time import time
import subprocess import subprocess
import reporters import reporters
import logging from loggable import Loggable
from optparse import OptionGroup from optparse import OptionGroup
from utils import mkdir, Result, Colors, printc from utils import mkdir, Result, Colors, printc
@ -34,11 +34,12 @@ DEFAULT_TIMEOUT = 10
DEFAULT_QA_SAMPLE_PATH = os.path.join(os.path.expanduser('~'), "Videos", DEFAULT_QA_SAMPLE_PATH = os.path.join(os.path.expanduser('~'), "Videos",
"gst-qa-samples") "gst-qa-samples")
class Test(object): class Test(Loggable):
""" A class representing a particular test. """ """ A class representing a particular test. """
def __init__(self, application_name, classname, options, reporter, scenario=None, timeout=DEFAULT_TIMEOUT): def __init__(self, application_name, classname, options, reporter, scenario=None, timeout=DEFAULT_TIMEOUT):
Loggable.__init__(self)
self.timeout = timeout self.timeout = timeout
self.classname = classname self.classname = classname
self.options = options self.options = options
@ -81,7 +82,7 @@ class Test(object):
self.error = error self.error = error
def check_results(self): def check_results(self):
logging.debug("%s returncode: %d", self, self.process.returncode) self.debug("%s returncode: %d", self, self.process.returncode)
if self.result == Result.TIMEOUT: if self.result == Result.TIMEOUT:
self.set_result(Result.TIMEOUT, "Application timed out", "timeout") self.set_result(Result.TIMEOUT, "Application timed out", "timeout")
elif self.process.returncode == 0: elif self.process.returncode == 0: