Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix clipboard test #641

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions qubes/device_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,14 @@ class DeviceCategory(Enum):
Microphone = ("m******",)
# Multimedia = Audio, Video, Displays etc.
Multimedia = (
"u01****",
"u0e****",
"u06****",
"u10****",
"p03****",
"p04****",
)
Audio = ("p0403**", "u01****")
Display = ("p0300**", "p0380**")
Video = ("p0400**", "u0e****")
Wireless = ("ue0****", "p0d****")
Bluetooth = ("ue00101", "p0d11**")
Storage = ("b******", "u08****", "p01****")
Expand Down
21 changes: 15 additions & 6 deletions qubes/tests/integ/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,9 @@ async def _test_clipboard(
expect_content=None,
expect_source_name=None,
):
if test_string.endswith("\n"):
# avoid final newline, zenity strips it
test_string = test_string[:-1] + "c"
testvm1 = self.app.add_new_vm(
qubes.vm.appvm.AppVM, name=self.make_vm_name("vm1"), label="red"
)
Expand All @@ -619,7 +622,7 @@ async def _test_clipboard(
p = await testvm1.run("cat > /tmp/source.txt", stdin=subprocess.PIPE)
await p.communicate(test_string.encode())
window_title = "user@{}".format(testvm1.name)
await testvm1.run(
p = await testvm1.run(
"zenity --text-info "
"--filename=/tmp/source.txt "
"--editable "
Expand All @@ -639,7 +642,13 @@ async def _test_clipboard(
await asyncio.sleep(5)
subprocess.check_call(["xdotool", "key", "ctrl+shift+c", "Escape"])

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

clipboard_content = (
open("/var/run/qubes/qubes-clipboard.bin", "r").read().strip()
Expand Down Expand Up @@ -718,14 +727,14 @@ def test_000_clipboard(self):
spawn.find_executable("xdotool"), "xdotool not installed"
)
def test_001_clipboard_64k(self):
test_string = "test123abc" * 6400
test_string = "test123ab\n" * 6400
self.loop.run_until_complete(self._test_clipboard(test_string))

@unittest.skipUnless(
spawn.find_executable("xdotool"), "xdotool not installed"
)
def test_002_clipboard_200k_truncated(self):
test_string = "test123abc" * 20000
test_string = "test123ab\n" * 20000
self.loop.run_until_complete(
self._test_clipboard(
test_string, expect_content="", expect_source_name=""
Expand All @@ -736,7 +745,7 @@ def test_002_clipboard_200k_truncated(self):
spawn.find_executable("xdotool"), "xdotool not installed"
)
def test_002_clipboard_200k(self):
test_string = "test123abc" * 20000
test_string = "test123ab\n" * 20000
self.loop.run_until_complete(
self._test_clipboard(
test_string, set_features={"gui-max-clipboard-size": 200_000}
Expand All @@ -747,7 +756,7 @@ def test_002_clipboard_200k(self):
spawn.find_executable("xdotool"), "xdotool not installed"
)
def test_002_clipboard_300k(self):
test_string = "test123abc" * 30000
test_string = "test123ab\n" * 30000
self.loop.run_until_complete(
self._test_clipboard(
test_string,
Expand Down