tests: register syslog logger, log test start
Move this functionality from our custom runner (qubes.tests.run), into base test class. This is very useful for correlating logs, so lets have it with nose2 runner too.
This commit is contained in:
parent
e0e0c7eaf9
commit
7def96c248
@ -13,7 +13,7 @@ install:
|
||||
- git clone https://github.com/"${TRAVIS_REPO_SLUG%%/*}"/qubes-builder ~/qubes-builder
|
||||
script:
|
||||
- PYTHONPATH=test-packages pylint qubes
|
||||
- ./run-tests --no-syslog
|
||||
- ./run-tests
|
||||
- ~/qubes-builder/scripts/travis-build
|
||||
env:
|
||||
- DIST_DOM0=fc25 USE_QUBES_REPO_VERSION=4.0 USE_QUBES_REPO_TESTING=1
|
||||
|
@ -115,6 +115,7 @@ except OSError:
|
||||
# command not found; let's assume we're outside
|
||||
pass
|
||||
|
||||
ha_syslog = None
|
||||
|
||||
def skipUnlessDom0(test_item):
|
||||
'''Decorator that skips test outside dom0.
|
||||
@ -697,6 +698,15 @@ class SystemTestCase(QubesTestCase):
|
||||
super(SystemTestCase, self).setUp()
|
||||
self.remove_test_vms()
|
||||
|
||||
global ha_syslog
|
||||
if ha_syslog is None:
|
||||
ha_syslog = logging.handlers.SysLogHandler('/dev/log')
|
||||
ha_syslog.setFormatter(
|
||||
logging.Formatter('%(name)s[%(process)d]: %(message)s'))
|
||||
logging.root.addHandler(ha_syslog)
|
||||
|
||||
self.log.critical('starting')
|
||||
|
||||
# need some information from the real qubes.xml - at least installed
|
||||
# templates; should not be used for testing, only to initialize self.app
|
||||
self.host_app = qubes.Qubes(os.path.join(
|
||||
|
@ -307,13 +307,6 @@ parser.add_argument('--logfile', '-o', metavar='FILE',
|
||||
action='store',
|
||||
help='if set, test run will be also logged to file')
|
||||
|
||||
parser.add_argument('--syslog',
|
||||
action='store_true', dest='syslog',
|
||||
help='reenable logging to syslog')
|
||||
parser.add_argument('--no-syslog',
|
||||
action='store_false', dest='syslog',
|
||||
help='disable logging to syslog')
|
||||
|
||||
parser.add_argument('--kmsg', '--very-brave-or-very-stupid',
|
||||
action='store_true', dest='kmsg',
|
||||
help='log most important things to kernel ring-buffer')
|
||||
@ -339,7 +332,6 @@ parser.set_defaults(
|
||||
failfast=False,
|
||||
loglevel='DEBUG',
|
||||
logfile=None,
|
||||
syslog=True,
|
||||
kmsg=False,
|
||||
verbose=2,
|
||||
quiet=0)
|
||||
@ -384,12 +376,6 @@ def main(args=None):
|
||||
logging.Formatter('%(asctime)s %(name)s[%(process)d]: %(message)s'))
|
||||
logging.root.addHandler(ha_file)
|
||||
|
||||
if args.syslog:
|
||||
ha_syslog = logging.handlers.SysLogHandler('/dev/log')
|
||||
ha_syslog.setFormatter(
|
||||
logging.Formatter('%(name)s[%(process)d]: %(message)s'))
|
||||
logging.root.addHandler(ha_syslog)
|
||||
|
||||
if args.kmsg:
|
||||
try:
|
||||
subprocess.check_call(('sudo', 'chmod', '666', '/dev/kmsg'))
|
||||
|
Loading…
Reference in New Issue
Block a user