[tests] Test lighttpd config before running other tests, show output if failed
parent
84ae82dd19
commit
82a9fa3ff2
|
@ -49,6 +49,7 @@ import imp
|
|||
import sys
|
||||
import traceback
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from service import *
|
||||
|
||||
|
@ -516,7 +517,22 @@ allow-listen {{ ip "127.0.0.1:{Env.port}"; }}
|
|||
class Lighttpd(Service):
|
||||
name = "lighttpd"
|
||||
|
||||
def TestConfig(self):
|
||||
logfile = open(self.log, "w")
|
||||
inp = self.devnull()
|
||||
args = [Env.worker, '-m', Env.plugindir, '-c', Env.lighttpdconf, '-t']
|
||||
print >> Env.log, "Testing lighttpd config: %s" % (' '.join(args))
|
||||
proc = subprocess.Popen(args, stdin = inp, stdout = logfile, stderr = logfile, close_fds = True)
|
||||
if None != inp: inp.close()
|
||||
logfile.close()
|
||||
status = proc.wait()
|
||||
if 0 != status:
|
||||
os.system("cat '%s'" % self.log)
|
||||
raise BaseException("testing lighttpd config failed with returncode %i" % (status))
|
||||
|
||||
def Prepare(self):
|
||||
self.TestConfig()
|
||||
|
||||
self.portfree(Env.port)
|
||||
if Env.no_angel:
|
||||
self.fork(Env.worker, '-m', Env.plugindir, '-c', Env.lighttpdconf)
|
||||
|
|
|
@ -9,7 +9,7 @@ import signal
|
|||
|
||||
import base
|
||||
|
||||
__all__ = [ "Service", "ServiceException" ]
|
||||
__all__ = [ "Service", "ServiceException", "devnull" ]
|
||||
|
||||
class ServiceException(Exception):
|
||||
def __init__(self, value): self.value = value
|
||||
|
@ -36,11 +36,13 @@ class Service(object):
|
|||
self.tests = None
|
||||
self.failed = False
|
||||
|
||||
def devnull(self):
|
||||
return devnull()
|
||||
|
||||
def fork(self, *args):
|
||||
if None == self.name:
|
||||
raise ServiceException("Service needs a name!")
|
||||
log = self.tests.PrepareFile("log/service-%s.log" % self.name, "")
|
||||
logfile = open(log, "w")
|
||||
logfile = open(self.log, "w")
|
||||
inp = devnull()
|
||||
|
||||
if base.Env.strace:
|
||||
|
@ -99,6 +101,7 @@ class Service(object):
|
|||
raise ServiceException("Timeout: cannot establish a connection to service %s on port %i" % (self.name, port))
|
||||
|
||||
def _prepare(self):
|
||||
self.log = self.tests.PrepareFile("log/service-%s.log" % self.name, "")
|
||||
self.failed = True
|
||||
self.Prepare()
|
||||
self.failed = False
|
||||
|
|
Loading…
Reference in New Issue