All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cleber Rosa <crosa@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Aleksandar Rikalo" <arikalo@wavecomp.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 2/2] Acceptance tests: add SPICE protocol check
Date: Fri, 21 Jun 2019 02:09:25 -0400	[thread overview]
Message-ID: <20190621060925.16214-3-crosa@redhat.com> (raw)
In-Reply-To: <20190621060925.16214-1-crosa@redhat.com>

This fires a QEMU binary with SPICE enabled, and does a basic
handshake, doing a basic client/server interaction and protocol
validation.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 .travis.yml               |  5 +++-
 tests/Makefile.include    |  6 +++++
 tests/acceptance/spice.py | 54 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 tests/acceptance/spice.py

diff --git a/.travis.yml b/.travis.yml
index aeb9b211cd..6c9257a459 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -231,7 +231,7 @@ matrix:
 
     # Acceptance (Functional) tests
     - env:
-        - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
+        - CONFIG="--python=/usr/bin/python3 --enable-spice --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
         - TEST_CMD="make check-acceptance"
       after_failure:
         - cat tests/results/latest/job.log
@@ -240,6 +240,9 @@ matrix:
           packages:
             - python3-pip
             - python3.5-venv
+            - libspice-protocol-dev
+            - libspice-server-dev
+
     # Using newer GCC with sanitizers
     - addons:
         apt:
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 4c97da2878..7fc2d28099 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1129,6 +1129,12 @@ AVOCADO_SHOW=app
 # Additional tags that are added to each occurence of "--filter-by-tags"
 AVOCADO_EXTRA_TAGS := ,-flaky
 
+# At last one test require spice to be enabled, allow it to be excluded
+# if it's not enabled
+ifneq ($(findstring y,"$(CONFIG_SPICE)"),y)
+AVOCADO_EXTRA_TAGS := $(AVOCADO_EXTRA_TAGS),-spice
+endif
+
 AVOCADO_TAGS=$(patsubst %-softmmu,--filter-by-tags=arch:%$(AVOCADO_EXTRA_TAGS), $(filter %-softmmu,$(TARGET_DIRS)))
 
 ifneq ($(findstring v2,"v$(PYTHON_VERSION)"),v2)
diff --git a/tests/acceptance/spice.py b/tests/acceptance/spice.py
new file mode 100644
index 0000000000..aa22b1992d
--- /dev/null
+++ b/tests/acceptance/spice.py
@@ -0,0 +1,54 @@
+# Simple functional tests for SPICE functionality
+#
+# Copyright (c) 2019 Red Hat, Inc.
+#
+# Author:
+#  Cleber Rosa <crosa@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+import socket
+import struct
+
+from avocado_qemu import Test
+from avocado.utils.network import find_free_port
+
+
+class Spice(Test):
+
+    def test_protocol(self):
+        """
+        :avocado: tags=quick
+        :avocado: tags=spice
+        """
+        port = find_free_port(5001, 5500, sequent=False)
+        self.vm.add_args('-nodefaults', '-S',
+                         '-spice', 'port=%d,disable-ticketing' % port)
+        self.vm.launch()
+
+        RED_MAGIC = 0x51444552
+        MAJOR_VERSION = 0x2
+
+        client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        client.connect(('127.0.0.1', port))
+        red_link_mess = struct.pack('<10I',
+                                    RED_MAGIC,      # magic
+                                    MAJOR_VERSION,  # major version
+                                    0x0,            # minor version
+                                    0x18,           # size in bytes from here
+                                    0x0,            # connection id
+                                    0x1,            # channel type RED_CHANNEL_MAIN
+                                    0x0,            # channel id
+                                    0x0,            # number of common caps
+                                    0x0,            # number of channel caps
+                                    0x14)           # caps offset from size
+        client.send(red_link_mess)
+
+        RED_LINK_REPLY_BASE_FMT = '<5I'  # magic, major, minor, size, error
+        red_link_reply = client.recv(struct.calcsize(RED_LINK_REPLY_BASE_FMT))
+        (magic, major, minor, size, error) = struct.unpack_from(RED_LINK_REPLY_BASE_FMT,
+                                                                red_link_reply)
+        self.assertEqual(magic, RED_MAGIC, "Mismatch of MAGIC number")
+        self.assertEqual(major, MAJOR_VERSION, "Mismatch of major protocol version")
+        self.assertEqual(error, 0x0, "Unexpected error reported by server")
-- 
2.21.0



  parent reply	other threads:[~2019-06-21  6:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21  6:09 [Qemu-devel] [PATCH 0/2] Acceptance tests: exclude "flaky" tests and introduce SPICE test Cleber Rosa
2019-06-21  6:09 ` [Qemu-devel] [PATCH 1/2] Acceptance tests: exclude "flaky" tests Cleber Rosa
2019-06-21  7:03   ` Philippe Mathieu-Daudé
2019-06-21 14:38     ` Cleber Rosa
2019-06-28 20:43       ` Wainer dos Santos Moschetta
2019-06-30 17:51         ` Cleber Rosa
2019-07-05 19:01           ` Wainer dos Santos Moschetta
2019-06-21  6:09 ` Cleber Rosa [this message]
2019-06-28 20:54   ` [Qemu-devel] [PATCH 2/2] Acceptance tests: add SPICE protocol check Wainer dos Santos Moschetta
2019-06-30 18:01     ` Cleber Rosa

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=20190621060925.16214-3-crosa@redhat.com \
    --to=crosa@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=arikalo@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=ehabkost@redhat.com \
    --cc=fam@euphon.net \
    --cc=philmd@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.