mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
launcher: Move http serveur and xvfb server to the main test runner object
No good reason for it to be in the main function
This commit is contained in:
parent
3f4f815500
commit
1b3867b82d
2 changed files with 47 additions and 40 deletions
|
@ -49,6 +49,8 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import xml.etree.cElementTree as ET
|
import xml.etree.cElementTree as ET
|
||||||
|
|
||||||
|
from .vfb_server import get_virual_frame_buffer_server
|
||||||
|
from .httpserver import HTTPServer
|
||||||
from .utils import mkdir, Result, Colors, printc, DEFAULT_TIMEOUT, GST_SECOND, \
|
from .utils import mkdir, Result, Colors, printc, DEFAULT_TIMEOUT, GST_SECOND, \
|
||||||
Protocols, look_for_file_in_source_dir, get_data_file, BackTraceGenerator, \
|
Protocols, look_for_file_in_source_dir, get_data_file, BackTraceGenerator, \
|
||||||
check_bugs_resolution
|
check_bugs_resolution
|
||||||
|
@ -1414,6 +1416,9 @@ class _TestsLauncher(Loggable):
|
||||||
self.jobs = []
|
self.jobs = []
|
||||||
self.total_num_tests = 0
|
self.total_num_tests = 0
|
||||||
self.server = None
|
self.server = None
|
||||||
|
self.httpsrv = None
|
||||||
|
self.vfb_server = None
|
||||||
|
|
||||||
|
|
||||||
def _list_app_dirs(self):
|
def _list_app_dirs(self):
|
||||||
app_dirs = []
|
app_dirs = []
|
||||||
|
@ -1589,6 +1594,19 @@ class _TestsLauncher(Loggable):
|
||||||
if not tester.check_expected_failures():
|
if not tester.check_expected_failures():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if self.needs_http_server() or options.httponly is True:
|
||||||
|
self.httpsrv = HTTPServer(options)
|
||||||
|
self.httpsrv.start()
|
||||||
|
|
||||||
|
if options.no_display:
|
||||||
|
self.vfb_server = get_virual_frame_buffer_server(options)
|
||||||
|
res = vfb_server.start()
|
||||||
|
if res[0] is False:
|
||||||
|
printc("Could not start virtual frame server: %s" % res[1],
|
||||||
|
Colors.FAIL)
|
||||||
|
return False
|
||||||
|
os.environ["DISPLAY"] = vfb_server.display_id
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _check_tester_has_other_testsuite(self, testsuite, tester):
|
def _check_tester_has_other_testsuite(self, testsuite, tester):
|
||||||
|
@ -1790,30 +1808,37 @@ class _TestsLauncher(Loggable):
|
||||||
self._stop_server()
|
self._stop_server()
|
||||||
|
|
||||||
def run_tests(self):
|
def run_tests(self):
|
||||||
self._start_server()
|
try:
|
||||||
if self.options.forever:
|
self._start_server()
|
||||||
r = 1
|
if self.options.forever:
|
||||||
while True:
|
r = 1
|
||||||
printc("Running iteration %d" % r, title=True)
|
while True:
|
||||||
|
printc("Running iteration %d" % r, title=True)
|
||||||
|
|
||||||
if not self._run_tests():
|
if not self._run_tests():
|
||||||
break
|
break
|
||||||
r += 1
|
r += 1
|
||||||
self.clean_tests()
|
self.clean_tests()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
elif self.options.n_runs:
|
elif self.options.n_runs:
|
||||||
res = True
|
res = True
|
||||||
for r in range(self.options.n_runs):
|
for r in range(self.options.n_runs):
|
||||||
t = "Running iteration %d" % r
|
t = "Running iteration %d" % r
|
||||||
print("%s\n%s\n%s\n" % ("=" * len(t), t, "=" * len(t)))
|
print("%s\n%s\n%s\n" % ("=" * len(t), t, "=" * len(t)))
|
||||||
if not self._run_tests():
|
if not self._run_tests():
|
||||||
res = False
|
res = False
|
||||||
self.clean_tests()
|
self.clean_tests()
|
||||||
|
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
return self._run_tests()
|
return self._run_tests()
|
||||||
|
finally:
|
||||||
|
if self.httpsrv:
|
||||||
|
self.httpsrv.stop()
|
||||||
|
if self.vfb_server:
|
||||||
|
vfb_server.stop()
|
||||||
|
self.clean_tests()
|
||||||
|
|
||||||
def final_report(self):
|
def final_report(self):
|
||||||
return self.reporter.final_report()
|
return self.reporter.final_report()
|
||||||
|
|
|
@ -29,8 +29,6 @@ import subprocess
|
||||||
|
|
||||||
|
|
||||||
from .loggable import Loggable
|
from .loggable import Loggable
|
||||||
from .httpserver import HTTPServer
|
|
||||||
from .vfb_server import get_virual_frame_buffer_server
|
|
||||||
from .baseclasses import _TestsLauncher, ScenarioManager
|
from .baseclasses import _TestsLauncher, ScenarioManager
|
||||||
from .utils import printc, path2url, DEFAULT_MAIN_DIR, launch_command, Colors, Protocols, which
|
from .utils import printc, path2url, DEFAULT_MAIN_DIR, launch_command, Colors, Protocols, which
|
||||||
|
|
||||||
|
@ -581,22 +579,9 @@ Note that all testsuite should be inside python modules, so the directory should
|
||||||
printc("\nNumber of tests: %d" % len(tests), Colors.OKGREEN)
|
printc("\nNumber of tests: %d" % len(tests), Colors.OKGREEN)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
httpsrv = HTTPServer(options)
|
|
||||||
if tests_launcher.needs_http_server() or options.httponly is True:
|
|
||||||
httpsrv.start()
|
|
||||||
|
|
||||||
vfb_server = get_virual_frame_buffer_server(options)
|
|
||||||
if options.no_display:
|
|
||||||
res = vfb_server.start()
|
|
||||||
if res[0] is False:
|
|
||||||
printc("Could not start virtual frame server: %s" % res[1],
|
|
||||||
Colors.FAIL)
|
|
||||||
exit(1)
|
|
||||||
os.environ["DISPLAY"] = vfb_server.display_id
|
|
||||||
|
|
||||||
if options.httponly is True:
|
if options.httponly is True:
|
||||||
print("Running HTTP server only")
|
print("Running HTTP server only")
|
||||||
return
|
return 0
|
||||||
|
|
||||||
# There seems to be some issue with forking, dconf and some gtype
|
# There seems to be some issue with forking, dconf and some gtype
|
||||||
# initialization that deadlocks occasionally, setting the
|
# initialization that deadlocks occasionally, setting the
|
||||||
|
@ -615,9 +600,6 @@ Note that all testsuite should be inside python modules, so the directory should
|
||||||
res = tests_launcher.final_report()
|
res = tests_launcher.final_report()
|
||||||
if options.ignore_numfailures:
|
if options.ignore_numfailures:
|
||||||
res = 0
|
res = 0
|
||||||
tests_launcher.clean_tests()
|
|
||||||
httpsrv.stop()
|
|
||||||
vfb_server.stop()
|
|
||||||
if exception is not None:
|
if exception is not None:
|
||||||
raise exception
|
raise exception
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue