On 19/10/22 10:31, Ani Sinha wrote:
On Wed, Oct 19, 2022 at 11:59 AM Ani Sinha <a...@anisinha.ca> wrote:
On Wed, Oct 19, 2022 at 8:29 AM Ani Sinha <a...@anisinha.ca> wrote:

This introduces QEMU acpi/smbios biosbits avocado test which is run
from within the python virtual environment. When the bits tests are run, bits
binaries are downloaded from an external repo/location, bios bits iso is
regenerated containing the acpi/smbios bits tests that are maintained as a part
of the QEMU source under tests/avocado/acpi-bits/bits-test . When the VM is
spawned with the iso, it runs the tests in batch mode and the results are pushed
out from the VM to the test machine where they are analyzed by this script and
pass/fail results are reported.

Cc: Daniel P. Berrangé <berra...@redhat.com>
Cc: Paolo Bonzini <pbonz...@redhat.com>
Cc: Maydell Peter <peter.mayd...@linaro.org>
Cc: John Snow <js...@redhat.com>
Cc: Thomas Huth <th...@redhat.com>
Cc: Alex Bennée <alex.ben...@linaro.org>
Cc: Igor Mammedov <imamm...@redhat.com>
Cc: Michael Tsirkin <m...@redhat.com>
Signed-off-by: Ani Sinha <a...@anisinha.ca>
---
  tests/avocado/acpi-bits.py | 363 +++++++++++++++++++++++++++++++++++++
  1 file changed, 363 insertions(+)
  create mode 100644 tests/avocado/acpi-bits.py

+import logging
+import os
+import re
+import shutil
+import subprocess
+import tarfile
+import tempfile
+import time
+import zipfile
+from typing import (
+    List,
+    Optional,
+    Sequence,
+)
+from qemu.machine import QEMUMachine
+from avocado import skipIf
+from avocado_qemu import QemuBaseTest

+@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
+class AcpiBitsTest(QemuBaseTest): #pylint: disable=too-many-instance-attributes
+    """
+    ACPI and SMBIOS tests using biosbits.

  <snip>

+
+    def setUp(self): # pylint: disable=arguments-differ
+        super().setUp('qemu-system-')
+
+        if shutil.which('xorriso') is None:
+            logging.error('xorriso is required to run this test.')
+            self.skipTest("xorriso is not installed. Please install it.")

This would result in output like this when xorriso is not found:

$ which xorriso
/usr/bin/which: no xorriso in
(/home/anisinha/.local/bin:/home/anisinha/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
[anisinha@centos8 build]$ ./tests/venv/bin/avocado run -t acpi tests/avocado
Fetching asset from
tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits
JOB ID     : 95aba043201755ed888ef7d1598402c555118df4
JOB LOG    : 
/home/anisinha/avocado/job-results/job-2022-10-19T02.27-95aba04/job.log
  (1/1) tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits:
ERROR: xorriso is not installed. Please install it. (0.00 s)

If an optional tool is missing, the test should be SKIPped, this is not an ERROR.

RESULTS    : PASS 0 | ERROR 1 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0
| CANCEL 0
JOB TIME   : 0.61 s



skipIf() was not working for me, hence I had to resort to this. I got
skipIf() working now so in v6 I will remove the above hunk and add the
conditional as @skipIf decorator.

For the records,
@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
does not work for me.
@skipIf(os.getenv('GITLAB_CI') is not None, 'Running on GitLab')
works.
A quick grep indicates that the former is used all over the place!

Because @skipIf works (at least as a class decorator).

Maybe something is missing on your side? Look at the
tesseract_available() example:

$ git grep tesseract_available
tests/avocado/machine_m68k_nextcube.py:14:from tesseract_utils import tesseract_available, tesseract_ocr tests/avocado/machine_m68k_nextcube.py:58: @skipUnless(tesseract_available(3), 'tesseract v3 OCR tool not available') tests/avocado/machine_m68k_nextcube.py:70: @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available') tests/avocado/tesseract_utils.py:14:def tesseract_available(expected_version):

$ grep GITLAB_CI *
grep: acpi-bits: Is a directory
acpi-bits.py:@skipIf(os.getenv('GITLAB_CI') is not None, 'Running on GitLab')
grep: avocado_qemu: Is a directory
boot_linux.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
intel_iommu.py:@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
linux_initrd.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_aspeed.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_aspeed.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_mips_malta.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_mips_malta.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_rx_gdbsim.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_rx_gdbsim.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
[...]

Reply via email to