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

View file

@ -18,7 +18,7 @@
# Boston, MA 02110-1301, USA.
import os
import logging
import loggable
from testdefinitions import _TestsLauncher, DEFAULT_QA_SAMPLE_PATH
from utils import printc
from optparse import OptionParser
@ -60,13 +60,7 @@ def main():
action="store_true", default=False,
help="Mute playback output, which mean that we use "
"a fakesink")
try:
level = getattr(logging,
os.environ["GST_VALIDATE_LAUNCHER_DEBUG"].upper(),
None)
logging.basicConfig(level=level)
except:
pass
loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False)
tests_launcher = _TestsLauncher()
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 re
import codecs
import logging
from loggable import Loggable
from xml.sax import saxutils
from utils import mkdir, Result, printc
@ -46,10 +46,12 @@ def escape_cdata(cdata):
return xml_safe(cdata).replace(']]>', ']]>]]&gt;<![CDATA[')
class Reporter(object):
class Reporter(Loggable):
name = 'simple'
def __init__(self, options):
Loggable.__init__(self)
self._current_test = None
self.out = None
self.options = options
@ -75,7 +77,7 @@ class Reporter(object):
self.stats["passed"] += 1
def add_results(self, test):
logging.debug("%s", test)
self.debug("%s", test)
if test.result == Result.PASSED:
self.set_passed(test)
elif test.result == Result.FAILED or \
@ -132,7 +134,7 @@ class XunitReporter(Reporter):
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.encoding, 'replace')
self.stats['encoding'] = self.encoding

View file

@ -24,7 +24,7 @@ import re
import time
import subprocess
import reporters
import logging
from loggable import Loggable
from optparse import OptionGroup
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",
"gst-qa-samples")
class Test(object):
class Test(Loggable):
""" A class representing a particular test. """
def __init__(self, application_name, classname, options, reporter, scenario=None, timeout=DEFAULT_TIMEOUT):
Loggable.__init__(self)
self.timeout = timeout
self.classname = classname
self.options = options
@ -81,7 +82,7 @@ class Test(object):
self.error = error
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:
self.set_result(Result.TIMEOUT, "Application timed out", "timeout")
elif self.process.returncode == 0: