tests/acceptance: Handle machine type for ARM target
RFC PATCH 1/1 tests/acceptance: Handle machine type for ARM target
Hi all,
I'm still unsure this is the best solution. I tend to think that any arch-independent test case (i.e. not tagged 'arch') should be skipped on all arches except for x86_64. Opening up for discussion though.
Note: It was decided that ARM targets should not default to any machine type: https://www.mail-archive.com/[email protected]/msg625999.html
-- 8< --
Some tests are meant arch-independent and as such they don't set the machine type (i.e. relying to defaults) on launched VMs. The arm targets, however, don't provide any default machine so tests fail.
This patch adds a logic on the base Test class so that machine type is set to 'virt' when:
a) The test case doesn't have arch:aarch64 or arch:arm tag. Here I assume that if the test was tagged for a specific arch then the writer took care of setting a machine type.
b) The target binary arch is any of aarch64 or arm. Note:
self.target_arch can end up None if qemu_bin is passed by Avocado parameter and the filename doesn't match expected format. In this case the test will fail.
--- tests/acceptance/avocado_qemu/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tests/acceptance/avocado_qemu/__init__.py +12 -0
@@ -9,6 +9,7 @@ # later. See the COPYING file in the top-level directory. import os +import re import sys import uuid
@@ -65,10 +66,21 @@ class Test(avocado.Test): if self.qemu_bin is None: self.cancel("No QEMU binary defined or found in the source tree") + m = re.match('qemu-system-(.*)', self.qemu_bin.split('/').pop()) + if m: + self.target_arch = m.group(1) + else: + self.target_arch = None + def _new_vm(self, *args): vm = QEMUMachine(self.qemu_bin) if args: vm.add_args(*args) + # Handle lack of default machine type on some targets. + # Assume that arch tagged tests have machine type set properly. + if self.tags.get('arch') is None and \ + self.target_arch in ('aarch64', 'arm'): + vm.set_machine('virt') return vm @property
Signature · 1 line
2.18.1
Quoted 7 lines · Wainer dos Santos Moschetta
Hi all,
I'm still unsure this is the best solution. I tend to think that any arch-independent test case (i.e. not tagged 'arch') should be skipped on all arches except for
x86_64. Opening up for discussion though.
I'm confused... if you're calling a test case "arch-independent", why should it be skipped on all but one arch? Anyway, I don't think we should define such a broad policy... This line of thought is very x86_64 centric, and quite honestly, doesn't map to QEMU's goals.
I agree that we're being a bit "disonest" by not assuring that tests we send will work on all targets... but at least we're having that discussion. The next step would be to start triaging and discussing wether it's worth running those against other targets, considering the cost and benefits.
Quoted 36 lines
Note: It was decided that ARM targets should not default to any machine type: https://www.mail-archive.com/[email protected]/msg625999.html
-- 8< --
Some tests are meant arch-independent and as such they don't set the machine type (i.e. relying to defaults) on launched VMs. The arm targets, however, don't provide any default machine so tests fail.This patch adds a logic on the base Test class so that machine type is set to 'virt' when:
a) The test case doesn't have arch:aarch64 or arch:arm tag. Here I assume that if the test was tagged for a specific arch then the writer took care of setting a machine type.
b) The target binary arch is any of aarch64 or arm. Note:
self.target_arch can end up None ifqemu_binis passed by Avocado parameter and the filename doesn't match expected format. In this case the test will fail.Signed-off-by Wainer dos Santos Moschetta <[email protected]>--- tests/acceptance/avocado_qemu/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)tests/acceptance/avocado_qemu/__init__.py +1
-0@@ -9,6 +9,7 @@ # later. See the COPYING file in the top-level directory. import os +import re import sys import uuid
tests/acceptance/avocado_qemu/__init__.py class Test(avocado.Test): · line 74
Quoted 9 lines
tests/acceptance/avocado_qemu/__init__.py +6
-0@@ -65,10 +66,21 @@ class Test(avocado.Test): if self.qemu_bin is None: self.cancel("No QEMU binary defined or found in the source tree") + m = re.match('qemu-system-(.*)', self.qemu_bin.split('/').pop()) + if m: + self.target_arch = m.group(1) + else: + self.target_arch = None +
The "arch" tag and parameter are actually related to the target that should be used. I don't see the need for a "target_arch" based on that.
tests/acceptance/avocado_qemu/__init__.py class Test(avocado.Test): · line 83
Quoted 9 lines
tests/acceptance/avocado_qemu/__init__.py +5
-0def _new_vm(self, *args): vm = QEMUMachine(self.qemu_bin) if args: vm.add_args(*args) + # Handle lack of default machine type on some targets. + # Assume that arch tagged tests have machine type set properly. + if self.tags.get('arch') is None and \ + self.target_arch in ('aarch64', 'arm'): + vm.set_machine('virt')
This (considering it deals with "arch" instead of "target_arch") is one of the very important points to be determined. How much wrapping around different QEMU behavior on different targets/machines/devices should we do? This will possibly be case-by-case discussions with different outcomes, but hopefully we can come up with a general direction.
Thanks,
- Cleber.
Quoted 6 lines
tests/acceptance/avocado_qemu/__init__.py +0
-0return vm @propertySignature · 1 line
2.18.1
Quoted 8 lines · Cleber Rosa
Quoted 7 lines · Wainer dos Santos Moschetta
Hi all,
I'm still unsure this is the best solution. I tend to think that any arch-independent test case (i.e. not tagged 'arch') should be skipped on all arches except for
x86_64. Opening up for discussion though.
Quoted 4 lines
I'm confused... if you're calling a test case "arch-independent", why should it be skipped on all but one arch? Anyway, I don't think we should define such a broad policy... This line of thought is very
x86_64centric, and quite honestly, doesn't map to QEMU's goals.
What I meant for "arch-independent" is a test which does not have "arch" tag. You call it "generic test". We can agree on use "generic test" for better communication.
The absence of "arch" tag can means either 1) "run on all built targets" or 2) "pick one target and run it". I suggested x86_64 thinking on case 2) because it provides a default machine type that I supposed (I might be indeed wrong) just works on most cases. Your follow up patch [1] addresses the scenario 1) but allows the user to pick that one target of 2).
All in all, we should agree on the semantic of "arch" when it is not present. Should it be "any" or "all"? Configurable or not? Let's discuss this on [1].
So NACK this patch.
[1] [RFC PATCH] Acceptance tests: run generic tests on all built targets
Quoted 46 lines
I agree that we're being a bit "disonest" by not assuring that tests we send will work on all targets... but at least we're having that discussion. The next step would be to start triaging and discussing wether it's worth running those against other targets, considering the cost and benefits.
Quoted 39 lines
Note: It was decided that ARM targets should not default to any machine type: https://www.mail-archive.com/[email protected]/msg625999.html
-- 8< --
Some tests are meant arch-independent and as such they don't set the machine type (i.e. relying to defaults) on launched VMs. The arm targets, however, don't provide any default machine so tests fail.This patch adds a logic on the base Test class so that machine type is set to 'virt' when:
a) The test case doesn't have arch:aarch64 or arch:arm tag. Here I assume that if the test was tagged for a specific arch then the writer took care of setting a machine type.
b) The target binary arch is any of aarch64 or arm. Note:
self.target_arch can end up None ifqemu_binis passed by Avocado parameter and the filename doesn't match expected format. In this case the test will fail.Signed-off-by Wainer dos Santos Moschetta <[email protected]>--- tests/acceptance/avocado_qemu/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)tests/acceptance/avocado_qemu/__init__.py +1
-0@@ -9,6 +9,7 @@ # later. See the COPYING file in the top-level directory. import os +import re import sys import uuid@@ -65,10 +66,21 @@ class Test(avocado.Test): if self.qemu_bin is None: self.cancel("No QEMU binary defined or found in the source tree")
Quoted 9 lines
tests/acceptance/avocado_qemu/__init__.py class Test(avocado.Test): · line 74
Quoted 6 lines
tests/acceptance/avocado_qemu/__init__.py +6
-0+ m = re.match('qemu-system-(.*)', self.qemu_bin.split('/').pop()) + if m: + self.target_arch = m.group(1) + else: + self.target_arch = None +The "arch" tag and parameter are actually related to the target that should be used. I don't see the need for a "
target_arch" based on that.
I could have used self.arch indeed. But notice that self.arch is None when "arch" tag does not exist. So I still need to guess the architecture from the binary.
Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py class Test(avocado.Test): · line 83
Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +5
-0def _new_vm(self, *args): vm = QEMUMachine(self.qemu_bin) if args: vm.add_args(*args) + # Handle lack of default machine type on some targets. + # Assume that arch tagged tests have machine type set properly. + if self.tags.get('arch') is None and \ + self.target_arch in ('aarch64', 'arm'): + vm.set_machine('virt')
Quoted 6 lines
This (considering it deals with "arch" instead of "
target_arch") is one of the very important points to be determined. How much wrapping around different QEMU behavior on different targets/machines/devices should we do? This will possibly be case-by-case discussions with different outcomes, but hopefully we can come up with a general direction.
Yep. Let's continue that discussion on your patch.
Thanks for the comments!
- Wainer
Quoted 10 lines
Thanks,
- Cleber.Quoted 6 lines
tests/acceptance/avocado_qemu/__init__.py +0
-0return vm @propertySignature · 1 line
2.18.1
RFC PATCH 1/1 Acceptance tests: run generic tests on all built targets
In reply to Wainer dos Santos MoschettaThe intention here is to discuss the validity of running the the acceptance tests are not depedent on target specific functionality on all built targets.
Subtle but important questions that this topic brings:
1) Should the QEMU binary target provide, as much as possible, a similar experience across targets, or should upper layer code deal with it?
2) Are those tests exercising the same exact features and implementation, which just happen to be linked to various different binaries? Or is the simple fact that they are integrated into different code worth testing?
3) Should the default target match the host target? Or the first binary found in the build tree? Or something else?
An example of a Travis CI job based on this can be seen here:
https://travis-ci.org/clebergnu/qemu/jobs/548905146
--- .travis.yml | 2 +- tests/Makefile.include | 18 +++++++++++++++++- tests/acceptance/avocado_qemu/__init__.py | 9 +++++++++ tests/acceptance/cpu_queries.py | 3 +++ tests/acceptance/migration.py | 4 +++- 5 files changed, 33 insertions(+), 3 deletions(-)
.travis.yml +1 -1
@@ -232,7 +232,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" - - TEST_CMD="make check-acceptance" + - TEST_CMD="make check-acceptance-all" after_failure: - cat tests/results/latest/job.log addons:
tests/Makefile.include +17 -1
@@ -1154,7 +1154,23 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(AVOCADO_TAGS) \ --failfast=on $(SRC_PATH)/tests/acceptance, \ - "AVOCADO", "tests/acceptance") + "AVOCADO", "tests/acceptance (target arch based on test)") + +# Allows one to run tests that are generic (independent of target) +# using a given target +check-acceptance-generic-on-%: check-venv $(TESTS_RESULTS_DIR) + $(call quiet-command, \ + $(TESTS_VENV_DIR)/bin/python -m avocado \ + --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ + --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ + --filter-by-tags=-arch -p arch=$* \ + -p add-qtest=yes -p set-arm-aarch64-machine=yes \ + --failfast=on $(SRC_PATH)/tests/acceptance, \ + "AVOCADO", "tests/acceptance (target arch set to $*)") + +check-acceptance-generic: $(patsubst %-softmmu,check-acceptance-generic-on-%, $(filter %-softmmu,$(TARGET_DIRS))) + +check-acceptance-all: check-acceptance check-acceptance-generic # Consolidated targets
tests/acceptance/avocado_qemu/__init__.py +9 -0
@@ -69,6 +69,15 @@ class Test(avocado.Test): vm = QEMUMachine(self.qemu_bin) if args: vm.add_args(*args) + if self.params.get('add-qtest', default=False): + # mips and sh4 targets require either a bios or a kernel or + # qtest enabled to not abort right at the commad line + if self.arch in ('mips', 'mipsel', 'mips64', 'mips64el', 'sh4'): + vm.add_args('-accel', 'qtest') + if self.params.get('set-arm-aarch64-machine', default=False): + # arm and aarch64 require a machine type to be set + if self.arch in ('arm', 'aarch64'): + vm.set_machine('virt') return vm @property
tests/acceptance/cpu_queries.py +3 -0
@@ -18,6 +18,9 @@ class QueryCPUModelExpansion(Test): """ def test(self): + """ + :avocado: tags=arch:x86_64 + """ self.vm.set_machine('none') self.vm.add_args('-S') self.vm.launch()
tests/acceptance/migration.py +3 -1
@@ -33,8 +33,10 @@ class Migration(Test): self.cancel('Failed to find a free port') return port - def test_migration_with_tcp_localhost(self): + blacklist_targets = ["arm", "ppc64", "sh4", "s390x"] + if self.arch in blacklist_targets: + self.cancel("Test failing on targets: %s" % ", ".join(blacklist_targets)) source_vm = self.get_vm() dest_uri = 'tcp:localhost:%u' % self._get_free_port() dest_vm = self.get_vm('-incoming', dest_uri)
Signature · 1 line
2.21.0