avocado-framework / avocado

Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native tests are written in Python and they follow the unittest pattern, but any executable can serve as a test.
https://avocado-framework.github.io/
Other
345 stars 343 forks source link

avocado-vt tests fail for AMD hosts #6033

Open SinadShan opened 2 months ago

SinadShan commented 2 months ago

Describe the bug Running avocado-vt tests on an Oracle Linux AMD host fails with the error:

JOB ID     : 2d2563d6a1eee8a19d00bdf9297e3ba1a12f5c31
JOB LOG    : /root/avocado/job-results/job-2024-09-19T10.25-2d2563d/job.log
 (1/1) io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_native: STARTED
 (1/1) io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_native: ERROR: argument of type 'int' is not iterable (0.55 s)
RESULTS    : PASS 0 | ERROR 1 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 10.51 s

More from debug logs:

[stdlog] 2024-09-19 10:25:32,683 avocado.test test             L0314 ERROR| Exception raised during postprocessing: argument of type 'int' is not iterable
[stderr] Traceback (most recent call last):
[stderr]   File "/usr/lib/python3.9/site-packages/avocado_vt/plugins/vt_runner.py", line 74, in runTest
[stderr]     raise self.__status  # pylint: disable-msg=E0702
[stderr]   File "/usr/lib/python3.9/site-packages/avocado_vt/test.py", line 146, in setUp
[stderr]     self._runTest()
[stderr]   File "/usr/lib/python3.9/site-packages/avocado_vt/test.py", line 268, in _runTest
[stderr]     params = env_process.preprocess(self, params, env)
[stderr]   File "/usr/lib/python3.9/site-packages/virttest/error_context.py", line 141, in new_fn
[stderr]     return fn(*args, **kwargs)
[stderr]   File "/usr/lib/python3.9/site-packages/virttest/env_process.py", line 1039, in preprocess
[stderr]     if cpu_family is not None and "power" in cpu_family:
[stderr] TypeError: argument of type 'int' is not iterable
**Steps to reproduce**
Steps to reproduce the behavior with a reproducible whenever possible.

Expected behavior Tests execute without errors

Current behavior Error

System information (please complete the following information):

Additional information

The issue was rooted down to get_family in avocado/utils/cpu.py returning integer type for AMD hosts:

def get_family():
    """Get family name of the cpu like Broadwell, Haswell, power8, power9."""
    family = None
    arch = get_arch()
    if arch == "x86_64" or arch == "i386":
        if get_vendor() == "amd":
            cpu_info = _get_info()
            pattern = r"cpu family\s*:"
            for line in cpu_info:
                line = line.decode("utf-8")
                if re.search(pattern, line):
                    family = int(line.split(":")[1])
                    return family 
richtja commented 2 months ago

Hi @SinadShan, thank you for reporting this issue. I agree that we should make better description of return values of get_family() method. But can you please check your avocado-vt version, because it seems to me that this issue has been fixed on latest avocado-vt.

SinadShan commented 2 months ago

I had used the latest released avocado-vt version 104.0 in which this issue was seen. This issue does seem to be fixed in a recent commit, but a release tag has not been made with these changes. Using the latest source should fix this issue. Thanks!