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

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