Skip to content

Commit 3153306

Browse files
committed
tests: fix clipboard test
First of all, wait for the zenity process to finish, do not leak it. But then, adjust the test string to not be a single long line - zenity often hangs on a single 300k line. Fixes QubesOS/qubes-issues#9646
1 parent 98855ca commit 3153306

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

qubes/tests/integ/basic.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ async def _test_clipboard(
599599
expect_content=None,
600600
expect_source_name=None,
601601
):
602+
if test_string.endswith("\n"):
603+
# avoid final newline, zenity strips it
604+
test_string = test_string[:-1] + "c"
602605
testvm1 = self.app.add_new_vm(
603606
qubes.vm.appvm.AppVM, name=self.make_vm_name("vm1"), label="red"
604607
)
@@ -619,7 +622,7 @@ async def _test_clipboard(
619622
p = await testvm1.run("cat > /tmp/source.txt", stdin=subprocess.PIPE)
620623
await p.communicate(test_string.encode())
621624
window_title = "user@{}".format(testvm1.name)
622-
await testvm1.run(
625+
p = await testvm1.run(
623626
"zenity --text-info "
624627
"--filename=/tmp/source.txt "
625628
"--editable "
@@ -639,7 +642,13 @@ async def _test_clipboard(
639642
await asyncio.sleep(5)
640643
subprocess.check_call(["xdotool", "key", "ctrl+shift+c", "Escape"])
641644

642-
await self.wait_for_window_coro(window_title, show=False)
645+
try:
646+
await asyncio.wait_for(p.communicate(), 5)
647+
except TimeoutError:
648+
# this kills only the qrexec-client process, not zenity itself,
649+
# but it's good enough for the test
650+
p.terminate()
651+
await p.wait()
643652

644653
clipboard_content = (
645654
open("/var/run/qubes/qubes-clipboard.bin", "r").read().strip()
@@ -718,14 +727,14 @@ def test_000_clipboard(self):
718727
spawn.find_executable("xdotool"), "xdotool not installed"
719728
)
720729
def test_001_clipboard_64k(self):
721-
test_string = "test123abc" * 6400
730+
test_string = "test123ab\n" * 6400
722731
self.loop.run_until_complete(self._test_clipboard(test_string))
723732

724733
@unittest.skipUnless(
725734
spawn.find_executable("xdotool"), "xdotool not installed"
726735
)
727736
def test_002_clipboard_200k_truncated(self):
728-
test_string = "test123abc" * 20000
737+
test_string = "test123ab\n" * 20000
729738
self.loop.run_until_complete(
730739
self._test_clipboard(
731740
test_string, expect_content="", expect_source_name=""
@@ -736,7 +745,7 @@ def test_002_clipboard_200k_truncated(self):
736745
spawn.find_executable("xdotool"), "xdotool not installed"
737746
)
738747
def test_002_clipboard_200k(self):
739-
test_string = "test123abc" * 20000
748+
test_string = "test123ab\n" * 20000
740749
self.loop.run_until_complete(
741750
self._test_clipboard(
742751
test_string, set_features={"gui-max-clipboard-size": 200_000}
@@ -747,7 +756,7 @@ def test_002_clipboard_200k(self):
747756
spawn.find_executable("xdotool"), "xdotool not installed"
748757
)
749758
def test_002_clipboard_300k(self):
750-
test_string = "test123abc" * 30000
759+
test_string = "test123ab\n" * 30000
751760
self.loop.run_until_complete(
752761
self._test_clipboard(
753762
test_string,

0 commit comments

Comments
 (0)