Skip to content

Commit

Permalink
use tcp connection to make running the tests reliable on win32
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@19485 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 27, 2018
1 parent 5b2b0f6 commit 87641fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
26 changes: 15 additions & 11 deletions src/unittests/unit/server/mixins/server_mixins_option_test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,24 @@ def _test(self, subcommand="start", options={}):
log("starting test server with options=%s", options)
args = ["--%s=%s" % (k,v) for k,v in options.items()]
tcp_port = None
if TEST_RFB:
tcp_port = get_free_tcp_port()
args += ["--bind-tcp=0.0.0.0:%i" % tcp_port]
xvfb = None
if WIN32 or OSX:
display = ""
display_arg = []
connect_args = []
elif self.display:
display = self.display
display_arg = [display]
connect_args = [display]
args.append("--use-display")
else:
display = self.find_free_display()
display_arg = [display]
connect_args = [display]
if subcommand=="shadow":
xvfb = self.start_Xvfb(display)
if TEST_RFB or WIN32:
tcp_port = get_free_tcp_port()
args += ["--bind-tcp=0.0.0.0:%i" % tcp_port]
if WIN32:
connect_args = ["tcp://127.0.0.1:%i" % tcp_port]
server = None
client = None
rfb_client = None
Expand All @@ -104,10 +106,10 @@ def _test(self, subcommand="start", options={}):
log("args=%s", " ".join("'%s'" % x for x in args))
server = self.check_server(subcommand, display, *args)
#we should always be able to get the version:
client = self.run_xpra(["version"]+display_arg)
client = self.run_xpra(["version"]+connect_args)
assert pollwait(client, 5)==0, "version client failed to connect to server with args=%s" % args
#run info query:
cmd = ["info"]+display_arg
cmd = ["info"]+connect_args
client = self.run_xpra(cmd)
r = pollwait(client, 5)
assert r==0, "info client failed and returned %s for server with args=%s" % (r, args)
Expand All @@ -130,17 +132,19 @@ def _test(self, subcommand="start", options={}):
"attach",
"--clipboard=no", #could create loops
"--notifications=no", #may get sent to the desktop session running the tests!
]+display_arg
]+connect_args
gui_client = self.run_xpra(xpra_args, **client_kwargs)
r = pollwait(gui_client, 5)
if r is not None:
log.warn("gui client stdout: %s", gui_client.stdout_file)
assert r is None, "gui client terminated early and returned %i for server with args=%s" % (r, args)

if self.display:
self.check_stop_server(server, subcommand="exit", display=display)
self.stop_server(server, "exit", *connect_args)
else:
self.check_stop_server(server, subcommand="stop", display=display)
self.stop_server(server, "stop", *connect_args)
if display:
assert display not in self.dotxpra.displays(), "server socket for display %s should have been removed" % display

if gui_client:
r = pollwait(gui_client, 1)
Expand Down
10 changes: 6 additions & 4 deletions src/unittests/unit/server_test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,16 @@ def check_server(cls, subcommand, display, *args):
return server_proc

@classmethod
def check_stop_server(cls, server_proc, subcommand="stop", display=":99999"):
def stop_server(cls, server_proc, subcommand="stop", *connect_args):
if server_proc.poll():
return
cmd = [subcommand]
if display:
cmd.append(display)
cmd = [subcommand]+list(connect_args)
stopit = cls.run_xpra(cmd)
assert pollwait(stopit) is not None, "%s command failed to exit" % subcommand
assert pollwait(server_proc) is not None, "server process %s failed to exit" % server_proc

@classmethod
def check_stop_server(cls, server_proc, subcommand="stop", display=":99999"):
cls.stop_server(server_proc, subcommand, display)
if display:
assert display not in cls.dotxpra.displays(), "server socket for display %s should have been removed" % display

0 comments on commit 87641fa

Please sign in to comment.