qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>, "Thomas Huth" <huth@tuxfamily.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [RFC PATCH v3 3/3] tests/acceptance: Run commands sending VNC keys
Date: Tue, 13 Aug 2019 15:49:21 +0200	[thread overview]
Message-ID: <20190813134921.30602-4-philmd@redhat.com> (raw)
In-Reply-To: <20190813134921.30602-1-philmd@redhat.com>

Proof of concept to interract with a framebuffer via VNC.

This test send 'mem' and 'help' to the firmware prompt
within the single X terminal opened.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
This test is limited because the '-vnc' option only allow
to bind TCP port. To allow parallel testing, I should try
to bind within a range instead of ':0'.
---
 tests/acceptance/machine_m68k_nextcube.py | 49 +++++++++++++++++++++++
 tests/requirements.txt                    |  1 +
 2 files changed, 50 insertions(+)

diff --git a/tests/acceptance/machine_m68k_nextcube.py b/tests/acceptance/machine_m68k_nextcube.py
index e09cab9f20..f4f853dfa1 100644
--- a/tests/acceptance/machine_m68k_nextcube.py
+++ b/tests/acceptance/machine_m68k_nextcube.py
@@ -13,6 +13,7 @@ import distutils.spawn
 
 from avocado_qemu import Test
 from avocado import skipUnless
+from vncdotool import api as vnc
 from avocado.utils import process
 from avocado.utils.path import find_command, CmdNotFoundError
 
@@ -119,3 +120,51 @@ class NextCubeMachine(Test):
         self.assertIn('System test failed. Error code 51', text)
         self.assertIn('Boot command', text)
         self.assertIn('Next>', text)
+
+
+    @staticmethod
+    def vnc_send_string(client, string, eol=True):
+        for key in string:
+            client.keyPress(key)
+            time.sleep(0.02)
+        if eol:
+            client.keyPress('enter')
+            time.sleep(0.02)
+
+    @skipUnless(tesseract_available(3), 'tesseract v3 OCR tool not available')
+    def test_bootrom_via_vnc_with_tesseract_v3(self):
+        """
+        :avocado: tags=arch:m68k
+        :avocado: tags=machine:next_cube
+        :avocado: tags=device:framebuffer
+        """
+        screenshot_path = os.path.join(self.workdir, "dump.png")
+
+        rom_url = ('http://www.nextcomputers.org/NeXTfiles/Software/ROM_Files/'
+                   '68040_Non-Turbo_Chipset/Rev_2.5_v66.BIN')
+        rom_hash = 'b3534796abae238a0111299fc406a9349f7fee24'
+        rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash)
+
+        self.vm.set_machine('next-cube')
+        self.vm.add_args('-bios', rom_path,
+                         '-vnc', ':0') # XXX do not use static TCP port...
+        self.vm.launch()
+
+        self.log.info('VM launched, waiting for display')
+        # TODO: Use avocado.utils.wait.wait_for to catch the
+        #       'displaysurface_create 1120x832' trace-event.
+        time.sleep(2)
+
+        with vnc.connect('127.0.0.1') as client:
+            self.vnc_send_string(client, 'help')
+            self.vnc_send_string(client, 'mem')
+            client.captureScreen(screenshot_path)
+            client.disconnect()
+
+        console_logger = logging.getLogger('console')
+        text = process.run("tesseract %s stdout" % screenshot_path).stdout_text
+        for line in text.split('\n'):
+            if len(line):
+                console_logger.debug(line)
+        self.assertIn('address space', text)
+        self.assertIn('System', text)
diff --git a/tests/requirements.txt b/tests/requirements.txt
index 3ae0e29ad7..f7467287a1 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -3,3 +3,4 @@
 # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
 avocado-framework==68.0
 paramiko
+vncdotool
-- 
2.20.1



  parent reply	other threads:[~2019-08-13 13:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13 13:49 [Qemu-devel] [PATCH v3 0/3] tests/acceptance: Add test of NeXTcube framebuffer using OCR Philippe Mathieu-Daudé
2019-08-13 13:49 ` [Qemu-devel] [PATCH v3 1/3] " Philippe Mathieu-Daudé
2019-08-13 13:49 ` [Qemu-devel] [PATCH v3 2/3] .travis.yml: Let the avocado job run the NeXTcube tests Philippe Mathieu-Daudé
2019-08-13 13:49 ` Philippe Mathieu-Daudé [this message]
2019-09-08 19:40   ` [Qemu-devel] [RFC PATCH v3 3/3] tests/acceptance: Run commands sending VNC keys Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190813134921.30602-4-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=crosa@redhat.com \
    --cc=fam@euphon.net \
    --cc=huth@tuxfamily.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).