Commit 6cb4f6db authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/cleber/tags/python-next-pull-request' into staging

Python queue, 2019-02-22

Python:
* introduce "python" directory with module namespace
* log QEMU launch command line on qemu.QEMUMachine

Acceptance Tests:
* initrd 4GiB+ test
* migration test
* multi vm support in test class
* bump Avocado version and drop "🥑 enable"

# gpg: Signature made Fri 22 Feb 2019 19:37:07 GMT
# gpg:                using RSA key 657E8D33A5F209F3
# gpg: Good signature from "Cleber Rosa <crosa@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3

* remotes/cleber/tags/python-next-pull-request:
  Acceptance tests: expect boot to extract 2GiB+ initrd with linux-v4.16
  Acceptance tests: use linux-3.6 and set vm memory to 4GiB
  tests.acceptance: adds simple migration test
  tests.acceptance: adds multi vm capability for acceptance tests
  scripts/qemu.py: log QEMU launch command line
  Introduce a Python module structure
  Acceptance tests: drop usage of "🥑

 enable"

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 21afe115 8f1c89ec
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7674,6 +7674,7 @@ LINKS="$LINKS pc-bios/qemu-icon.bmp"
LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
LINKS="$LINKS tests/acceptance tests/data"
LINKS="$LINKS tests/qemu-iotests/check"
LINKS="$LINKS python"
for bios_file in \
    $source_path/pc-bios/*.bin \
    $source_path/pc-bios/*.lid \
+40 −2
Original line number Diff line number Diff line
@@ -600,7 +600,6 @@ the ``avocado_qemu.Test`` class. Here's a simple usage example:

  class Version(Test):
      """
      :avocado: enable
      :avocado: tags=quick
      """
      def test_qmp_human_info_version(self):
@@ -634,7 +633,46 @@ instance, available at ``self.vm``. Because many tests will tweak the
QEMU command line, launching the QEMUMachine (by using ``self.vm.launch()``)
is left to the test writer.

At test "tear down", ``avocado_qemu.Test`` handles the QEMUMachine
The base test class has also support for tests with more than one
QEMUMachine. The way to get machines is through the ``self.get_vm()``
method which will return a QEMUMachine instance. The ``self.get_vm()``
method accepts arguments that will be passed to the QEMUMachine creation
and also an optional `name` attribute so you can identify a specific
machine and get it more than once through the tests methods. A simple
and hypothetical example follows:

.. code::

  from avocado_qemu import Test


  class MultipleMachines(Test):
      """
      :avocado: enable
      """
      def test_multiple_machines(self):
          first_machine = self.get_vm()
          second_machine = self.get_vm()
          self.get_vm(name='third_machine').launch()

          first_machine.launch()
          second_machine.launch()

          first_res = first_machine.command(
              'human-monitor-command',
              command_line='info version')

          second_res = second_machine.command(
              'human-monitor-command',
              command_line='info version')

          third_res = self.get_vm(name='third_machine').command(
              'human-monitor-command',
              command_line='info version')

          self.assertEquals(first_res, second_res, third_res)

At test "tear down", ``avocado_qemu.Test`` handles all the QEMUMachines
shutdown.

QEMUMachine
+7 −5
Original line number Diff line number Diff line
@@ -16,12 +16,13 @@ import errno
import logging
import os
import subprocess
import qmp.qmp
import re
import shutil
import socket
import tempfile

from . import qmp


LOG = logging.getLogger(__name__)

@@ -66,7 +67,7 @@ class QEMUMachineAddDeviceError(QEMUMachineError):
    failures reported by the QEMU binary itself.
    """

class MonitorResponseError(qmp.qmp.QMPError):
class MonitorResponseError(qmp.QMPError):
    """
    Represents erroneous QMP monitor reply
    """
@@ -266,7 +267,7 @@ class QEMUMachine(object):
        self._qemu_log_path = os.path.join(self._temp_dir, self._name + ".log")
        self._qemu_log_file = open(self._qemu_log_path, 'wb')

        self._qmp = qmp.qmp.QEMUMonitorProtocol(self._vm_monitor,
        self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor,
                                            server=True)

    def _post_launch(self):
@@ -319,6 +320,7 @@ class QEMUMachine(object):
        self._pre_launch()
        self._qemu_full_args = (self._wrapper + [self._binary] +
                                self._base_args() + self._args)
        LOG.debug('VM launch command: %r', ' '.join(self._qemu_full_args))
        self._popen = subprocess.Popen(self._qemu_full_args,
                                       stdin=devnull,
                                       stdout=self._qemu_log_file,
@@ -383,7 +385,7 @@ class QEMUMachine(object):
        """
        reply = self.qmp(cmd, conv_keys, **args)
        if reply is None:
            raise qmp.qmp.QMPError("Monitor is closed")
            raise qmp.QMPError("Monitor is closed")
        if "error" in reply:
            raise MonitorResponseError(reply)
        return reply["return"]
+0 −0

File moved.

+3 −2
Original line number Diff line number Diff line
@@ -13,7 +13,8 @@

import socket
import os
import qemu

from . import QEMUMachine


class QEMUQtestProtocol(object):
@@ -79,7 +80,7 @@ class QEMUQtestProtocol(object):
        self._sock.settimeout(timeout)


class QEMUQtestMachine(qemu.QEMUMachine):
class QEMUQtestMachine(QEMUMachine):
    '''A QEMU VM'''

    def __init__(self, binary, args=None, name=None, test_dir="/var/tmp",
Loading