yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-Acceptance-tests-add-make-rule-for-running-them.patch

ae23c9
From ae8198a11e507c4f4f701aa92c3ae531d140e547 Mon Sep 17 00:00:00 2001
ae23c9
From: Yash Mankad <ymankad@redhat.com>
ae23c9
Date: Wed, 12 Dec 2018 00:14:41 +0000
ae23c9
Subject: [PATCH 13/13] Acceptance tests: add make rule for running them
ae23c9
MIME-Version: 1.0
ae23c9
Content-Type: text/plain; charset=UTF-8
ae23c9
Content-Transfer-Encoding: 8bit
ae23c9
ae23c9
RH-Author: Yash Mankad <ymankad@redhat.com>
ae23c9
Message-id: <9527fefa2d8d1b27d4a647cf8355236b61fb028b.1544573601.git.ymankad@redhat.com>
ae23c9
Patchwork-id: 83439
ae23c9
O-Subject: [RHEL-8.0 qemu-kvm PATCH v2 7/7] Acceptance tests: add make rule for running them
ae23c9
Bugzilla: 1655807
ae23c9
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ae23c9
ae23c9
From: Cleber Rosa <crosa@redhat.com>
ae23c9
ae23c9
The acceptance (aka functional, aka Avocado-based) tests are
ae23c9
Python files located in "tests/acceptance" that need to be run
ae23c9
with the Avocado libs and test runner.
ae23c9
ae23c9
Let's provide a convenient way for QEMU developers to run them,
ae23c9
by making use of the tests-venv with the required setup.
ae23c9
ae23c9
Also, while the Avocado test runner will take care of creating a
ae23c9
location to save test results to, it was understood that it's better
ae23c9
if the results are kept within the build tree.
ae23c9
ae23c9
Signed-off-by: Cleber Rosa <crosa@redhat.com>
ae23c9
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
Acked-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
ae23c9
Reviewed-by: Caio Carrara <ccarrara@redhat.com>
ae23c9
Message-Id: <20181018153134.8493-3-crosa@redhat.com>
ae23c9
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
ae23c9
(cherry picked from commit a56931eef343c7564e35bcc05eaed2a469a1b1b8)
ae23c9
Signed-off-by: Yash Mankad <ymankad@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 docs/devel/testing.rst | 43 ++++++++++++++++++++++++++++++++++++++-----
ae23c9
 tests/Makefile.include | 21 +++++++++++++++++++--
ae23c9
 tests/requirements.txt |  1 +
ae23c9
 3 files changed, 58 insertions(+), 7 deletions(-)
ae23c9
ae23c9
diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
ae23c9
index f33e5a8..db08a80 100644
ae23c9
--- a/docs/devel/testing.rst
ae23c9
+++ b/docs/devel/testing.rst
ae23c9
@@ -524,10 +524,39 @@ Tests based on ``avocado_qemu.Test`` can easily:
ae23c9
    - http://avocado-framework.readthedocs.io/en/latest/api/test/avocado.html#avocado.Test
ae23c9
    - http://avocado-framework.readthedocs.io/en/latest/api/utils/avocado.utils.html
ae23c9
 
ae23c9
-Installation
ae23c9
-------------
ae23c9
+Running tests
ae23c9
+-------------
ae23c9
+
ae23c9
+You can run the acceptance tests simply by executing:
ae23c9
+
ae23c9
+.. code::
ae23c9
+
ae23c9
+  make check-acceptance
ae23c9
+
ae23c9
+This involves the automatic creation of Python virtual environment
ae23c9
+within the build tree (at ``tests/venv``) which will have all the
ae23c9
+right dependencies, and will save tests results also within the
ae23c9
+build tree (at ``tests/results``).
ae23c9
 
ae23c9
-To install Avocado and its dependencies, run:
ae23c9
+Note: the build environment must be using a Python 3 stack, and have
ae23c9
+the ``venv`` and ``pip`` packages installed.  If necessary, make sure
ae23c9
+``configure`` is called with ``--python=`` and that those modules are
ae23c9
+available.  On Debian and Ubuntu based systems, depending on the
ae23c9
+specific version, they may be on packages named ``python3-venv`` and
ae23c9
+``python3-pip``.
ae23c9
+
ae23c9
+The scripts installed inside the virtual environment may be used
ae23c9
+without an "activation".  For instance, the Avocado test runner
ae23c9
+may be invoked by running:
ae23c9
+
ae23c9
+ .. code::
ae23c9
+
ae23c9
+  tests/venv/bin/avocado run $OPTION1 $OPTION2 tests/acceptance/
ae23c9
+
ae23c9
+Manual Installation
ae23c9
+-------------------
ae23c9
+
ae23c9
+To manually install Avocado and its dependencies, run:
ae23c9
 
ae23c9
 .. code::
ae23c9
 
ae23c9
@@ -668,11 +697,15 @@ The exact QEMU binary to be used on QEMUMachine.
ae23c9
 Uninstalling Avocado
ae23c9
 --------------------
ae23c9
 
ae23c9
-If you've followed the installation instructions above, you can easily
ae23c9
-uninstall Avocado.  Start by listing the packages you have installed::
ae23c9
+If you've followed the manual installation instructions above, you can
ae23c9
+easily uninstall Avocado.  Start by listing the packages you have
ae23c9
+installed::
ae23c9
 
ae23c9
   pip list --user
ae23c9
 
ae23c9
 And remove any package you want with::
ae23c9
 
ae23c9
   pip uninstall <package_name>
ae23c9
+
ae23c9
+If you've used ``make check-acceptance``, the Python virtual environment where
ae23c9
+Avocado is installed will be cleaned up as part of ``make check-clean``.
ae23c9
diff --git a/tests/Makefile.include b/tests/Makefile.include
ae23c9
index 99a9dcd..1177ca3 100644
ae23c9
--- a/tests/Makefile.include
ae23c9
+++ b/tests/Makefile.include
ae23c9
@@ -10,6 +10,7 @@ check-help:
ae23c9
 	@echo " $(MAKE) check-speed          Run qobject speed tests"
ae23c9
 	@echo " $(MAKE) check-qapi-schema    Run QAPI schema tests"
ae23c9
 	@echo " $(MAKE) check-block          Run block tests"
ae23c9
+	@echo " $(MAKE) check-acceptance     Run all acceptance (functional) tests"
ae23c9
 	@echo " $(MAKE) check-report.html    Generates an HTML test report"
ae23c9
 	@echo " $(MAKE) check-venv           Creates a Python venv for tests"
ae23c9
 	@echo " $(MAKE) check-clean          Clean the tests"
ae23c9
@@ -956,10 +957,15 @@ check-decodetree:
ae23c9
 
ae23c9
 # Python venv for running tests
ae23c9
 
ae23c9
-.PHONY: check-venv
ae23c9
+.PHONY: check-venv check-acceptance
ae23c9
 
ae23c9
 TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv
ae23c9
 TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt
ae23c9
+TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
ae23c9
+# Controls the output generated by Avocado when running tests.
ae23c9
+# Any number of command separated loggers are accepted.  For more
ae23c9
+# information please refer to "avocado --help".
ae23c9
+AVOCADO_SHOW=none
ae23c9
 
ae23c9
 $(shell $(PYTHON) -c 'import sys; assert sys.version_info >= (3,0)' >/dev/null 2>&1)
ae23c9
 ifeq ($(.SHELLSTATUS),0)
ae23c9
@@ -976,8 +982,19 @@ $(TESTS_VENV_DIR):
ae23c9
 	$(error "venv directory for tests requires Python 3")
ae23c9
 endif
ae23c9
 
ae23c9
+$(TESTS_RESULTS_DIR):
ae23c9
+	$(call quiet-command, mkdir -p $@, \
ae23c9
+            MKDIR, $@)
ae23c9
+
ae23c9
 check-venv: $(TESTS_VENV_DIR)
ae23c9
 
ae23c9
+check-acceptance: check-venv $(TESTS_RESULTS_DIR)
ae23c9
+	$(call quiet-command, \
ae23c9
+            $(TESTS_VENV_DIR)/bin/python -m avocado \
ae23c9
+            --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
ae23c9
+            --failfast=on $(SRC_PATH)/tests/acceptance, \
ae23c9
+            "AVOCADO", "tests/acceptance")
ae23c9
+
ae23c9
 # Consolidated targets
ae23c9
 
ae23c9
 .PHONY: check-qapi-schema check-qtest check-unit check check-clean
ae23c9
@@ -992,7 +1009,7 @@ check-clean:
ae23c9
 	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
ae23c9
 	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
ae23c9
 	rm -f tests/test-qapi-gen-timestamp
ae23c9
-	rm -rf $(TESTS_VENV_DIR)
ae23c9
+	rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR)
ae23c9
 
ae23c9
 clean: check-clean
ae23c9
 
ae23c9
diff --git a/tests/requirements.txt b/tests/requirements.txt
ae23c9
index d39f9d1..64c6e27 100644
ae23c9
--- a/tests/requirements.txt
ae23c9
+++ b/tests/requirements.txt
ae23c9
@@ -1,3 +1,4 @@
ae23c9
 # Add Python module requirements, one per line, to be installed
ae23c9
 # in the tests/venv Python virtual environment. For more info,
ae23c9
 # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
ae23c9
+avocado-framework==65.0
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9