All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test
@ 2019-06-06 21:14 Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 1/7] Acceptance tests: use relative location for tests Cleber Rosa
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Cleber Rosa @ 2019-06-06 21:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Philippe Mathieu-Daudé,
	Cornelia Huck, Wainer dos Santos Moschetta, Cleber Rosa,
	Alex Bennée, Samuel Ortiz

This adds an acceptance test that validates that a full blown Linux
guest can successfully boot in QEMU.

Changes from v5:
================

 * Added explicit "--enable-slirp=git" to Travis CI configure line, as
   these tests depend on "-netdev user" like networking.

 * Bumped Fedora to most recently released version (30).

 * Changed "checksum" parameter to 'sha256' and use the same hashes as
   provided by the Fedora project (instead of using Avocado's default
   sha1 and compute and use a different hash value).

 * New commit: Add "boot_linux" test for aarch64 and virt machine type

 * New commit: [RFC]: use Avocado data drainer for console logging

Changes from v4:
================

 * New commit "Acceptance tests: use relative location for tests"

 * New commit "Acceptance tests: keep a stable reference to the QEMU build dir"

 * Pinned the Fedora 29 image by adding a checksum.  The goal is to
   never allow more than one component to change at a time (the one
   allowed to change is QEMU itself).  Updates to the image should be
   manual. (Based on comments from Cornelia)

 * Moved the downloading of the Fedora 29 cloud image to the test
   setUp() method, canceling the test if the image can not be
   downloaded.

 * Removed the ":avocado: enable" tag, given that Avocado versions
   68.0 and later operate on a "recursive by default" manner, that
   is able to correctly identify this as an Avocado test.

Changes from v3:
================

 * New patch "Acceptance tests: depend on qemu-img"

Known Issues on v3 (no longer applicable):
==========================================

 * A recent TCG performance regression[1] affects this test in a
   number of ways:
   - The test execution may timeout by itself
   - The generation of SSH host keys in the guest's first boot is also
     affected (possibly also a timeout)
   - The cloud-init "phone home" feature attempts to read the host keys
     and fails, causing the test to timeout and fail

   These are not observed anymore once the fix[2] is applied.

[1] - https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg00338.html
[2] - https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg01129.html

Changes from v2:
================

 * Updated the tag to include the "arch:" key, in a similar fashion as to
   the tests in the "Acceptance Tests: target architecture support":
   - https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg00369.html

 * Renamed the test method name to test_x86_64_pc, again, similarly to the
   boot_linux_console.py tests in the series mentioned before.

 * Set the machine type explicitly, again similarly to the
   boot_linux_console.py tests in the series mentioned before.

 * Added messages after the launch of the VM, to let test runners know
   the test know waits for a boot confirmation from the the guest (Eduardo).

 * Updated commit message to reflect the fact that this version does
   not allow for parameterization of the guest OS, version, etc.

 * Dropped the RFC prefix on patch "RFC: Acceptance tests: add the
   build directory to the system PATH"

 * Changed the comments on "RFC: Acceptance tests: add the build
   directory to the system PATH" to make it clear the addition of a
   the build directory to the PATH may influence other utility code.

Changes from v1:
================

 * The commit message was adjusted, removing the reference to the
   avocado.utils.vmimage encoding issue on previous Avocado versions
   (<= 64.0) and the fix that would (and was) included in Avocado
   version 65.0.

 * Effectively added pycdlib==1.6.0 to the requirements.txt file,
   added on a56931eef3, and adjusted the commit message was also
   to reflect that.

 * Updated the default version of the guest OS, from Fedora 28 to 29.
   Besides possible improvements in the (virtual) hardware coverage,
   it brings a performance improvement in the order of 20% to the
   test.

 * Removed all direct parameters usage.  Because some parameters and
   its default values implemented in the test would prevent it from
   running on some environments.  Example: the "accel" parameter had a
   default value of "kvm", which would prevent this test, that boots a
   x86_64 OS, from running on a host arch different than x86_64.  I
   recognize that it's desirable to make tests reusable and
   parameterized (that was the reason for the first version doing so),
   but the mechanism to be used to define the architectures that a
   given test should support is still an open issue, and has been
   discussed in other threads.  I'll follow up those discussions with
   a proposal, and until then, removing those aspects from this test
   implementation seemed to be the best option.  A caveat: this test
   currently adds the same tag (x86_64) and follows other assumptions
   made on "boot_linux_console.py", that is, that a x86_64 target
   binary will be used to run it.  If a user is in an environment that
   does not have a x86_64 target binary, it could filter those tests
   out with: "avocado run --filter-by-tags='-x86_64' tests/acceptance".

 * Removed most arguments to the QEMU command line for pretty much the
   same reasons described above, and by following the general
   perception that I could grasp from other discussions that QEMU
   defaults should preferrably be used.  This test, as well as others,
   can and should be extended later to allow for different test
   scenarios by passing well documented parameter values.  That is,
   they should respect well-known parameters such as "accel" mentioned
   above, so that the same test can run with KVM or TCG.

 * Changed the value of the memory argument to 1024, which based on
   my experimentations and observations is the minimum amount of RAM
   for the Fedora 29 cloud image to sucessfully boot on QEMU.  I know
   there's no such thing as a "one size fits all", specially for QEMU,
   but this makes me wonder wether a x86_64 machine type shouldn't
   have its default_ram_size bumped to a number practical enough to
   run modern operating systems.

 * Added a new patch "RFC: Acceptance tests: add the build directory
   to the system PATH", which is supposed to gather feedback on how to
   enable the use of built binaries, such as qemu-img, to code used by
   the test code.  The specific situation here is that the vmimage,
   part of the avocado.utils libraries, makes use of qemu-img to create
   snapshot files.  Even though we could require qemu-img to be installed
   as a dependency of tests, system wide, it actually goes against the
   goal of testing all QEMU things from the source/build tree.  This
   became aparent with tests running on environments such as Travis CI,
   which don't necessarily have qemu-img available elsewhere.

Some hopefully useful pointers for reviewers:
=============================================

Git Info:
  - URI: https://github.com/clebergnu/qemu/tree/test_boot_linux_v6
  - Remote: https://github.com/clebergnu/qemu
  - Branch: test_boot_linux_v6

Travis CI Info:
  - Build: https://travis-ci.org/clebergnu/qemu/builds/542474730
  - Job: https://travis-ci.org/clebergnu/qemu/jobs/542474755

Previous version:
  - v5: https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg04652.html
  - v4: https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg02032.html
  - v3: https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg01677.html
  - v2: https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg04318.html
  - v1: http://lists.nongnu.org/archive/html/qemu-devel/2018-09/msg02530.html

Cleber Rosa (7):
  Acceptance tests: use relative location for tests
  Acceptance tests: keep a stable reference to the QEMU build dir
  Acceptance tests: add the build directory to the system PATH
  Acceptance tests: depend on qemu-img
  Add "boot_linux" test for x86_64 and pc and q35 machine types
  Add "boot_linux" test for aarch64 and virt machine type
  [RFC]: use Avocado data drainer for console logging

 .travis.yml                               |   2 +-
 tests/Makefile.include                    |   4 +-
 tests/acceptance/avocado_qemu/__init__.py |   8 +-
 tests/acceptance/boot_linux.py            | 111 ++++++++++++++++++++++
 tests/requirements.txt                    |   4 +-
 5 files changed, 124 insertions(+), 5 deletions(-)
 create mode 100644 tests/acceptance/boot_linux.py

-- 
2.21.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v6 1/7] Acceptance tests: use relative location for tests
  2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
@ 2019-06-06 21:14 ` Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 2/7] Acceptance tests: keep a stable reference to the QEMU build dir Cleber Rosa
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Cleber Rosa @ 2019-06-06 21:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Philippe Mathieu-Daudé,
	Cornelia Huck, Wainer dos Santos Moschetta, Cleber Rosa,
	Alex Bennée, Samuel Ortiz

An Avocado Test ID[1] is composed by a number of components, but it
starts with the Test Name, usually a file system location that was
given to the loader.

Because the source directory is being given as a prefix to the
"tests/acceptance" directory containing the acceptance tests, the test
names will needlessly include the directory the user is using to host
the QEMU sources (and/or build tree).

Let's remove the source dir (or a build dir) from the path given to
the test loader.  This should give more constant names, and when using
result servers and databases, it should give the same test names
across executions from different people or from different directories.

[1] - https://avocado-framework.readthedocs.io/en/69.0/ReferenceGuide.html#test-id

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 0cd5f465b7..991ad05aea 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1147,7 +1147,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR)
             --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
             --filter-by-tags-include-empty --filter-by-tags-include-empty-key \
             $(AVOCADO_TAGS) \
-            --failfast=on $(SRC_PATH)/tests/acceptance, \
+            --failfast=on tests/acceptance, \
             "AVOCADO", "tests/acceptance")
 
 # Consolidated targets
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v6 2/7] Acceptance tests: keep a stable reference to the QEMU build dir
  2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 1/7] Acceptance tests: use relative location for tests Cleber Rosa
@ 2019-06-06 21:14 ` Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 3/7] Acceptance tests: add the build directory to the system PATH Cleber Rosa
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Cleber Rosa @ 2019-06-06 21:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Philippe Mathieu-Daudé,
	Cornelia Huck, Wainer dos Santos Moschetta, Cleber Rosa,
	Alex Bennée, Samuel Ortiz

This is related to the the differences in in-tree and out-of-tree
builds in QEMU.  For simplification, <BLD> means my build directory.

Currently, by running a `make check-acceptance` one gets (in
tests/acceptance/avocado_qemu/__init__.py):

   SRC_ROOT_DIR: <BLD>/tests/acceptance/avocado_qemu/../../..

This in itself is problematic, because after the parent directories
are applied, one may be left not with a pointer to the build directory
as intended, but with the location of the source tree (assuming they
differ). Built binaries, such as qemu-img, are of course not there and
can't be found.

Given that a Python '__file__' will contain the absolute path to the
file backing the module, say:

   __file__: <BLD>/tests/acceptance/avocado_qemu/__init__.py

                  |  4  |     3    |      2     |     1     |

A solution is to not "evaluate" the third parent dir (marked as 4
here) because that ends up following the "tests" directory symlink to
the source tree.  In fact, there's no need to keep or evaluate any of
the parent directories, we can just drop the rightmost 4 components,
and we'll keep a stable reference to the build directory (with no
symlink being followed).  This works for either a dedicated build
directory or also a combined source and build tree.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/acceptance/avocado_qemu/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 2b236a1cf0..ac59d36a4c 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -14,7 +14,7 @@ import uuid
 
 import avocado
 
-SRC_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..', '..')
+SRC_ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
 sys.path.append(os.path.join(SRC_ROOT_DIR, 'python'))
 
 from qemu import QEMUMachine
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v6 3/7] Acceptance tests: add the build directory to the system PATH
  2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 1/7] Acceptance tests: use relative location for tests Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 2/7] Acceptance tests: keep a stable reference to the QEMU build dir Cleber Rosa
@ 2019-06-06 21:14 ` Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 4/7] Acceptance tests: depend on qemu-img Cleber Rosa
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Cleber Rosa @ 2019-06-06 21:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Philippe Mathieu-Daudé,
	Cornelia Huck, Wainer dos Santos Moschetta, Cleber Rosa,
	Alex Bennée, Samuel Ortiz

So that when binaries such as qemu-img are searched for, those in the
build tree will be favored.  As a clarification, SRC_ROOT_DIR is
dependent on the location from where tests are executed, so they are
equal to the build directory if one is being used.

The original motivation is that Avocado libraries such as
avocado.utils.vmimage.get() may use the matching binaries, but it may
also apply to any other binary that test code may eventually attempt
to execute.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/acceptance/avocado_qemu/__init__.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index ac59d36a4c..47c57a9221 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -52,6 +52,12 @@ def pick_default_qemu_bin(arch=None):
 
 class Test(avocado.Test):
     def setUp(self):
+        # Some utility code uses binaries from the system's PATH.  For
+        # instance, avocado.utils.vmimage.get() uses qemu-img, to
+        # create a snapshot image.  This is a transparent way of
+        # making sure those utilities find and use binaries on the
+        # build tree by default.
+        os.environ['PATH'] = '%s:%s' % (SRC_ROOT_DIR, os.environ['PATH'])
         self._vms = {}
         arches = self.tags.get('arch', [])
         if len(arches) == 1:
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v6 4/7] Acceptance tests: depend on qemu-img
  2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
                   ` (2 preceding siblings ...)
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 3/7] Acceptance tests: add the build directory to the system PATH Cleber Rosa
@ 2019-06-06 21:14 ` Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 5/7] Add "boot_linux" test for x86_64 and pc and q35 machine types Cleber Rosa
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Cleber Rosa @ 2019-06-06 21:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Philippe Mathieu-Daudé,
	Cornelia Huck, Wainer dos Santos Moschetta, Cleber Rosa,
	Alex Bennée, Samuel Ortiz

Tests using the avocado.utils.vmimage library make use of qemu-img,
and because it makes sense to use the version matching the rest of the
source code, let's make sure it gets built.

Its selection, instead of a possible qemu-img binary installed system
wide, is already dealt with by the change that adds the build dir to
the PATH during the test execution.

This is based on the same work for qemu-iotests, and suggested by its
author:

  - https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg00951.html

CC: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 991ad05aea..31fc6ec59c 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1141,7 +1141,7 @@ $(TESTS_RESULTS_DIR):
 
 check-venv: $(TESTS_VENV_DIR)
 
-check-acceptance: check-venv $(TESTS_RESULTS_DIR)
+check-acceptance: check-venv $(TESTS_RESULTS_DIR) qemu-img$(EXESUF)
 	$(call quiet-command, \
             $(TESTS_VENV_DIR)/bin/python -m avocado \
             --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v6 5/7] Add "boot_linux" test for x86_64 and pc and q35 machine types
  2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
                   ` (3 preceding siblings ...)
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 4/7] Acceptance tests: depend on qemu-img Cleber Rosa
@ 2019-06-06 21:14 ` Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 6/7] Add "boot_linux" test for aarch64 and virt machine type Cleber Rosa
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Cleber Rosa @ 2019-06-06 21:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Philippe Mathieu-Daudé,
	Cornelia Huck, Wainer dos Santos Moschetta, Cleber Rosa,
	Alex Bennée, Samuel Ortiz

This acceptance test, validates that a full blown Linux guest can
successfully boot in QEMU.  In this specific case, the guest chosen is
Fedora version 30.  It adds two different tests for machine types pc
and q35.

The method for checking the successful boot is based on "cloudinit"
and its "phone home" feature.  The guest is given an ISO image
with the location of the phone home server, and the information to
post (the instance ID).  Upon receiving the correct information,
from the guest, the test is considered to have PASSed.

This test is currently limited to user mode networking only, and
instructs the guest to connect to the "router" address that is hard
coded in QEMU.

To create the cloudinit ISO image that will be used to configure the
guest, the pycdlib library is also required and has been added as
requirement to the virtual environment created by "check-venv".

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 .travis.yml                    |  2 +-
 tests/acceptance/boot_linux.py | 83 ++++++++++++++++++++++++++++++++++
 tests/requirements.txt         |  2 +
 3 files changed, 86 insertions(+), 1 deletion(-)
 create mode 100644 tests/acceptance/boot_linux.py

diff --git a/.travis.yml b/.travis.yml
index b053a836a3..df74234692 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -224,7 +224,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-slirp=git --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
         - TEST_CMD="make check-acceptance"
       addons:
         apt:
diff --git a/tests/acceptance/boot_linux.py b/tests/acceptance/boot_linux.py
new file mode 100644
index 0000000000..2180f69a12
--- /dev/null
+++ b/tests/acceptance/boot_linux.py
@@ -0,0 +1,83 @@
+# Functional test that boots a complete Linux system via a cloud image
+#
+# Copyright (c) 2018-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 os
+
+from avocado_qemu import Test
+
+from avocado.utils import cloudinit
+from avocado.utils import network
+from avocado.utils import vmimage
+
+
+class BootLinux(Test):
+    """
+    Boots a Linux system, checking for a successful initialization
+    """
+
+    timeout = 600
+    chksum = None
+
+    def setUp(self):
+        super(BootLinux, self).setUp()
+        self.prepare_boot()
+        self.vm.add_args('-m', '1024')
+        self.vm.add_args('-drive', 'file=%s' % self.boot.path)
+        self.prepare_cloudinit()
+
+    def prepare_boot(self):
+        try:
+            self.log.info('Downloading and preparing boot image')
+            self.boot = vmimage.get(
+                'fedora', arch=self.arch, version='30',
+                checksum=self.chksum,
+                algorithm='sha256',
+                cache_dir=self.cache_dirs[0],
+                snapshot_dir=self.workdir)
+        except:
+            self.cancel('Failed to download boot image')
+
+    def prepare_cloudinit(self):
+        cloudinit_iso = os.path.join(self.workdir, 'cloudinit.iso')
+        self.phone_home_port = network.find_free_port()
+        cloudinit.iso(cloudinit_iso, self.name,
+                      username='root',
+                      password='password',
+                      # QEMU's hard coded usermode router address
+                      phone_home_host='10.0.2.2',
+                      phone_home_port=self.phone_home_port)
+        self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
+
+    def wait_for_boot_confirmation(self):
+        self.log.info('VM launched, waiting for boot confirmation from guest')
+        cloudinit.wait_for_phone_home(('0.0.0.0', self.phone_home_port), self.name)
+
+
+class BootLinuxX8664(BootLinux):
+
+    chksum = '72b6ae7b4ed09a4dccd6e966e1b3ac69bd97da419de9760b410e837ba00b4e26'
+
+    def test_pc(self):
+        """
+        :avocado: tags=arch:x86_64
+        :avocado: tags=machine:pc
+        """
+        self.vm.set_machine('pc')
+        self.vm.launch()
+        self.wait_for_boot_confirmation()
+
+    def test_q35(self):
+        """
+        :avocado: tags=arch:x86_64
+        :avocado: tags=machine:q35
+        """
+        self.vm.set_machine('q35')
+        self.vm.launch()
+        self.wait_for_boot_confirmation()
diff --git a/tests/requirements.txt b/tests/requirements.txt
index 3ae0e29ad7..9d2c79b146 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -3,3 +3,5 @@
 # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
 avocado-framework==68.0
 paramiko
+pycdlib==1.6.0
+
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v6 6/7] Add "boot_linux" test for aarch64 and virt machine type
  2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
                   ` (4 preceding siblings ...)
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 5/7] Add "boot_linux" test for x86_64 and pc and q35 machine types Cleber Rosa
@ 2019-06-06 21:14 ` Cleber Rosa
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 7/7] [RFC]: use Avocado data drainer for console logging Cleber Rosa
  2019-06-06 23:03 ` [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test no-reply
  7 siblings, 0 replies; 9+ messages in thread
From: Cleber Rosa @ 2019-06-06 21:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Philippe Mathieu-Daudé,
	Cornelia Huck, Wainer dos Santos Moschetta, Cleber Rosa,
	Alex Bennée, Samuel Ortiz

This boots a Fedora 30 guest using edk2.

During the first Fedora 30 boot on aarch64, there's a filesystem
resize operation.  The typical output is similar to:

   [  203.798938] EXT4-fs (sda2): resizing filesystem from 999168 to 999675 blocks
   [  203.823032] EXT4-fs (sda2): resized filesystem to 999675

It was observed that, when using virtio-blk, it seems that random
numbers are exhausted, unless an RNG device is given.  Interestingly
the same was *not* observed with virtio-scsi.  In accordance with the
other similar tests, this uses the default devices on the machine
model used (virtio-blk here) and adds the necessary options to make
it operation.

In the future, other combinations (such as virtio-scsi) can, should
and will be tested.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/acceptance/boot_linux.py | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/tests/acceptance/boot_linux.py b/tests/acceptance/boot_linux.py
index 2180f69a12..9b54a0241f 100644
--- a/tests/acceptance/boot_linux.py
+++ b/tests/acceptance/boot_linux.py
@@ -10,7 +10,7 @@
 
 import os
 
-from avocado_qemu import Test
+from avocado_qemu import Test, SRC_ROOT_DIR
 
 from avocado.utils import cloudinit
 from avocado.utils import network
@@ -81,3 +81,23 @@ class BootLinuxX8664(BootLinux):
         self.vm.set_machine('q35')
         self.vm.launch()
         self.wait_for_boot_confirmation()
+
+
+class BootLinuxAarch64(BootLinux):
+
+    chksum = '528f2659a410e3a8bd47d32a6ac4e6c5729f1d28dbad0763b4282a753ddcab1f'
+
+    def test_virt(self):
+        """
+        :avocado: tags=arch:aarch64
+        :avocado: tags=machine:virt
+        """
+        self.vm.set_machine('virt')
+        self.vm.add_args('-cpu', 'cortex-a53')
+        self.vm.add_args('-bios',
+                         os.path.join(SRC_ROOT_DIR, 'pc-bios',
+                                      'edk2-aarch64-code.fd'))
+        self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
+        self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
+        self.vm.launch()
+        self.wait_for_boot_confirmation()
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v6 7/7] [RFC]: use Avocado data drainer for console logging
  2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
                   ` (5 preceding siblings ...)
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 6/7] Add "boot_linux" test for aarch64 and virt machine type Cleber Rosa
@ 2019-06-06 21:14 ` Cleber Rosa
  2019-06-06 23:03 ` [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test no-reply
  7 siblings, 0 replies; 9+ messages in thread
From: Cleber Rosa @ 2019-06-06 21:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Eduardo Habkost, Philippe Mathieu-Daudé,
	Cornelia Huck, Wainer dos Santos Moschetta, Cleber Rosa,
	Alex Bennée, Samuel Ortiz

This depends on a proposed feature to Avocado, a new module that
"drains" data and processes it.  In this case, a drainer for the
console socket file descriptor is used, and the data is sent to the
"console" logger.

This allows for a much better feedback of the test process, showing
boot data from the guest as it happens, without obstructing the test
code path.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/acceptance/boot_linux.py | 14 +++++++++++---
 tests/requirements.txt         |  2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/tests/acceptance/boot_linux.py b/tests/acceptance/boot_linux.py
index 9b54a0241f..f3507f519e 100644
--- a/tests/acceptance/boot_linux.py
+++ b/tests/acceptance/boot_linux.py
@@ -15,6 +15,7 @@ from avocado_qemu import Test, SRC_ROOT_DIR
 from avocado.utils import cloudinit
 from avocado.utils import network
 from avocado.utils import vmimage
+from avocado.utils import datadrainer
 
 
 class BootLinux(Test):
@@ -55,6 +56,13 @@ class BootLinux(Test):
                       phone_home_port=self.phone_home_port)
         self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
 
+    def launch(self):
+        self.vm.set_console()
+        self.vm.launch()
+        console_drainer = datadrainer.LineLogger(self.vm.console_socket.fileno(),
+                                                 logger=self.log.getChild('console'))
+        console_drainer.start()
+
     def wait_for_boot_confirmation(self):
         self.log.info('VM launched, waiting for boot confirmation from guest')
         cloudinit.wait_for_phone_home(('0.0.0.0', self.phone_home_port), self.name)
@@ -70,7 +78,7 @@ class BootLinuxX8664(BootLinux):
         :avocado: tags=machine:pc
         """
         self.vm.set_machine('pc')
-        self.vm.launch()
+        self.launch()
         self.wait_for_boot_confirmation()
 
     def test_q35(self):
@@ -79,7 +87,7 @@ class BootLinuxX8664(BootLinux):
         :avocado: tags=machine:q35
         """
         self.vm.set_machine('q35')
-        self.vm.launch()
+        self.launch()
         self.wait_for_boot_confirmation()
 
 
@@ -99,5 +107,5 @@ class BootLinuxAarch64(BootLinux):
                                       'edk2-aarch64-code.fd'))
         self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
         self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
-        self.vm.launch()
+        self.launch()
         self.wait_for_boot_confirmation()
diff --git a/tests/requirements.txt b/tests/requirements.txt
index 9d2c79b146..28eaf7b61e 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,7 +1,7 @@
 # Add Python module requirements, one per line, to be installed
 # in the tests/venv Python virtual environment. For more info,
 # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
-avocado-framework==68.0
+-e git+https://github.com/clebergnu/avocado@datadrainer#egg=avocado_framework
 paramiko
 pycdlib==1.6.0
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test
  2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
                   ` (6 preceding siblings ...)
  2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 7/7] [RFC]: use Avocado data drainer for console logging Cleber Rosa
@ 2019-06-06 23:03 ` no-reply
  7 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2019-06-06 23:03 UTC (permalink / raw)
  To: crosa
  Cc: fam, ehabkost, alex.bennee, cohuck, qemu-devel, wainersm, crosa,
	philmd, sameo

Patchew URL: https://patchew.org/QEMU/20190606211414.8681-1-crosa@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test
Type: series
Message-id: 20190606211414.8681-1-crosa@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20190606211414.8681-1-crosa@redhat.com -> patchew/20190606211414.8681-1-crosa@redhat.com
Switched to a new branch 'test'
7362d67bed use Avocado data drainer for console logging
1c6ac71e07 Add "boot_linux" test for aarch64 and virt machine type
76dfc6e28e Add "boot_linux" test for x86_64 and pc and q35 machine types
01a69804c2 Acceptance tests: depend on qemu-img
b7dc969d31 Acceptance tests: add the build directory to the system PATH
5f3b84c3b6 Acceptance tests: keep a stable reference to the QEMU build dir
8d08990c7c Acceptance tests: use relative location for tests

=== OUTPUT BEGIN ===
1/7 Checking commit 8d08990c7c78 (Acceptance tests: use relative location for tests)
2/7 Checking commit 5f3b84c3b6f7 (Acceptance tests: keep a stable reference to the QEMU build dir)
ERROR: line over 90 characters
#48: FILE: tests/acceptance/avocado_qemu/__init__.py:17:
+SRC_ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

total: 1 errors, 0 warnings, 8 lines checked

Patch 2/7 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

3/7 Checking commit b7dc969d311a (Acceptance tests: add the build directory to the system PATH)
4/7 Checking commit 01a69804c2b2 (Acceptance tests: depend on qemu-img)
5/7 Checking commit 76dfc6e28e21 (Add "boot_linux" test for x86_64 and pc and q35 machine types)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#43: 
new file mode 100644

WARNING: line over 80 characters
#107: FILE: tests/acceptance/boot_linux.py:60:
+        cloudinit.wait_for_phone_home(('0.0.0.0', self.phone_home_port), self.name)

total: 0 errors, 2 warnings, 96 lines checked

Patch 5/7 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/7 Checking commit 1c6ac71e07f2 (Add "boot_linux" test for aarch64 and virt machine type)
7/7 Checking commit 7362d67bed37 (use Avocado data drainer for console logging)
WARNING: line over 80 characters
#38: FILE: tests/acceptance/boot_linux.py:62:
+        console_drainer = datadrainer.LineLogger(self.vm.console_socket.fileno(),

WARNING: line over 80 characters
#39: FILE: tests/acceptance/boot_linux.py:63:
+                                                 logger=self.log.getChild('console'))

total: 0 errors, 2 warnings, 50 lines checked

Patch 7/7 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20190606211414.8681-1-crosa@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-06-07 19:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-06 21:14 [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test Cleber Rosa
2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 1/7] Acceptance tests: use relative location for tests Cleber Rosa
2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 2/7] Acceptance tests: keep a stable reference to the QEMU build dir Cleber Rosa
2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 3/7] Acceptance tests: add the build directory to the system PATH Cleber Rosa
2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 4/7] Acceptance tests: depend on qemu-img Cleber Rosa
2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 5/7] Add "boot_linux" test for x86_64 and pc and q35 machine types Cleber Rosa
2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 6/7] Add "boot_linux" test for aarch64 and virt machine type Cleber Rosa
2019-06-06 21:14 ` [Qemu-devel] [PATCH v6 7/7] [RFC]: use Avocado data drainer for console logging Cleber Rosa
2019-06-06 23:03 ` [Qemu-devel] [PATCH v6 0/7] Add "boot_linux" acceptance test no-reply

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.