Skip to contentSkip to conversation

Acceptance tests: cpu_queries.py improvements

PATCH New Cleber Rosa 1 participant 5 messages Sep 11, 2019

lore
Share & tools
lore
#1 lore raw

PATCH 1/4 tests/acceptance/cpu_queries.py: cleanups

In reply to Cleber Rosa

Simple cleanups for debugging code that is not being used.

---
 tests/acceptance/cpu_queries.py | 3 ---
 1 file changed, 3 deletions(-)
tests/acceptance/cpu_queries.py +0 -3
index e71edec39f..a9ac3d692e 100644
@@ -8,8 +8,6 @@
 # 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 logging
-
 from avocado_qemu import Test
 
 class QueryCPUModelExpansion(Test):
@@ -24,7 +22,6 @@ class QueryCPUModelExpansion(Test):
 
         cpus = self.vm.command('query-cpu-definitions')
         for c in cpus:
-            print(repr(c))
             self.assertNotIn('', c['unavailable-features'], c['name'])
 
         for c in cpus:
Signature · 1 line
2.21.0
#0 lore raw

cover Acceptance tests: cpu_queries.py improvements

The cpu_queries.py test is currently x86_64 specific, so this sets a 'arch' tag to make sure the correct target binary is used by default.

Also, a few minor cleanups and optimizations.

Cleber Rosa (4):
tests/acceptance/cpu_queries.py: cleanups tests/acceptance/cpu_queries.py: tag test as x86_64 specific tests/acceptance/cpu_queries.py: add machine tag tests/acceptance/cpu_queries.py: minor optmizations

 tests/acceptance/cpu_queries.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/4 tests/acceptance/cpu_queries.py: tag test as x86_64 specific

This is an usability improvement, and prevents the test from being automatically run with some not supported targets (say on an ppc64le or aarch64 host).

Actually, the x86_64 tagging is a little white lie, because in theory, at least parts of the test, such as the query-cpu-model-expansion query, should also work on s390x. But, that is actually failing, so a future development round will attempt to make tests run on all possible supported targets.

---
 tests/acceptance/cpu_queries.py | 2 ++
 1 file changed, 2 insertions(+)
tests/acceptance/cpu_queries.py +2 -0
index a9ac3d692e..1028588920 100644
@@ -13,6 +13,8 @@ from avocado_qemu import Test
 class QueryCPUModelExpansion(Test):
     """
     Run query-cpu-model-expansion for each CPU model, and validate results
+
+    :avocado: tags=arch:x86_64
     """
 
     def test(self):
Signature · 1 line
2.21.0
#3 lore raw

PATCH 3/4 tests/acceptance/cpu_queries.py: add machine tag

In reply to Cleber Rosa

This is for informational / filtering purposes only, that is, allows one to run all tests with machine model "none".

---
 tests/acceptance/cpu_queries.py | 1 +
 1 file changed, 1 insertion(+)
tests/acceptance/cpu_queries.py +1 -0
index 1028588920..9cd6f553ff 100644
@@ -15,6 +15,7 @@ class QueryCPUModelExpansion(Test):
     Run query-cpu-model-expansion for each CPU model, and validate results
 
     :avocado: tags=arch:x86_64
+    :avocado: tags=machine:none
     """
 
     def test(self):
Signature · 1 line
2.21.0
#4 lore raw

PATCH 4/4 tests/acceptance/cpu_queries.py: minor optmizations

In reply to Cleber Rosa

This avoids the second loop over the cpus, and reuses some of the variables.

---
 tests/acceptance/cpu_queries.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
tests/acceptance/cpu_queries.py +5 -6
index 9cd6f553ff..54aa310fb8 100644
@@ -25,9 +25,8 @@ class QueryCPUModelExpansion(Test):
 
         cpus = self.vm.command('query-cpu-definitions')
         for c in cpus:
-            self.assertNotIn('', c['unavailable-features'], c['name'])
-
-        for c in cpus:
-            model = {'name': c['name']}
-            e = self.vm.command('query-cpu-model-expansion', model=model, type='full')
-            self.assertEquals(e['model']['name'], c['name'])
+            model_name = c['name']
+            self.assertNotIn('', c['unavailable-features'], model_name)
+            e = self.vm.command('query-cpu-model-expansion',
+                                model={'name': model_name}, type='full')
+            self.assertEquals(e['model']['name'], model_name)
Signature · 1 line
2.21.0