qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

acpi-bits.rst (6783B)


      1 =============================================================================
      2 ACPI/SMBIOS avocado tests using biosbits
      3 =============================================================================
      4 
      5 Biosbits is a software written by Josh Triplett that can be downloaded
      6 from https://biosbits.org/. The github codebase can be found
      7 `here <https://github.com/biosbits/bits/tree/master>`__. It is a software that executes
      8 the bios components such as acpi and smbios tables directly through acpica
      9 bios interpreter (a freely available C based library written by Intel,
     10 downloadable from https://acpica.org/ and is included with biosbits) without an
     11 operating system getting involved in between.
     12 There are several advantages to directly testing the bios in a real physical
     13 machine or VM as opposed to indirectly discovering bios issues through the
     14 operating system. For one thing, the OSes tend to hide bios problems from the
     15 end user. The other is that we have more control of what we wanted to test
     16 and how by directly using acpica interpreter on top of the bios on a running
     17 system. More details on the inspiration for developing biosbits and its real
     18 life uses can be found in [#a]_ and [#b]_.
     19 For QEMU, we maintain a fork of bios bits in gitlab along with all the
     20 dependent submodules here: https://gitlab.com/qemu-project/biosbits-bits
     21 This fork contains numerous fixes, a newer acpica and changes specific to
     22 running this avocado QEMU tests using bits. The author of this document
     23 is the sole maintainer of the QEMU fork of bios bits repo.
     24 
     25 Under the directory ``tests/avocado/``, ``acpi-bits.py`` is a QEMU avocado
     26 test that drives all this.
     27 
     28 A brief description of the various test files follows.
     29 
     30 Under ``tests/avocado/`` as the root we have:
     31 
     32 ::
     33 
     34    ├── acpi-bits
     35    │ ├── bits-config
     36    │ │ └── bits-cfg.txt
     37    │ ├── bits-tests
     38    │   ├── smbios.py2
     39    │   ├── testacpi.py2
     40    │   └── testcpuid.py2
     41    ├── acpi-bits.py
     42 
     43 * ``tests/avocado``:
     44 
     45    ``acpi-bits.py``:
     46    This is the main python avocado test script that generates a
     47    biosbits iso. It then spawns a QEMU VM with it, collects the log and reports
     48    test failures. This is the script one would be interested in if they wanted
     49    to add or change some component of the log parsing, add a new command line
     50    to alter how QEMU is spawned etc. Test writers typically would not need to
     51    modify this script unless they wanted to enhance or change the log parsing
     52    for their tests. In order to enable debugging, you can set **V=1**
     53    environment variable. This enables verbose mode for the test and also dumps
     54    the entire log from bios bits and more information in case failure happens.
     55 
     56    In order to run this test, please perform the following steps from the QEMU
     57    build directory:
     58    ::
     59 
     60      $ make check-venv (needed only the first time to create the venv)
     61      $ ./tests/venv/bin/avocado run -t acpi tests/avocado
     62 
     63    The above will run all acpi avocado tests including this one.
     64    In order to run the individual tests, perform the following:
     65    ::
     66 
     67      $ ./tests/venv/bin/avocado run tests/avocado/acpi-bits.py --tap -
     68 
     69    The above will produce output in tap format. You can omit "--tap -" in the
     70    end and it will produce output like the following:
     71    ::
     72 
     73       $ ./tests/venv/bin/avocado run tests/avocado/acpi-bits.py
     74       Fetching asset from tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits
     75       JOB ID     : eab225724da7b64c012c65705dc2fa14ab1defef
     76       JOB LOG    : /home/anisinha/avocado/job-results/job-2022-10-10T17.58-eab2257/job.log
     77       (1/1) tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits: PASS (33.09 s)
     78       RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
     79       JOB TIME   : 39.22 s
     80 
     81    You can inspect the log file for more information about the run or in order
     82    to diagnoze issues. If you pass V=1 in the environment, more diagnostic logs
     83    would be found in the test log.
     84 
     85 * ``tests/avocado/acpi-bits/bits-config``:
     86 
     87    This location contains biosbits configuration files that determine how the
     88    software runs the tests.
     89 
     90    ``bits-config.txt``:
     91    This is the biosbits config file that determines what tests
     92    or actions are performed by bits. The description of the config options are
     93    provided in the file itself.
     94 
     95 * ``tests/avocado/acpi-bits/bits-tests``:
     96 
     97    This directory contains biosbits python based tests that are run from within
     98    the biosbits environment in the spawned VM. New additions of test cases can
     99    be made in the appropriate test file. For example, new acpi tests can go
    100    into testacpi.py2 and one would call testsuite.add_test() to register the new
    101    test so that it gets executed as a part of the ACPI tests.
    102    It might be occasionally necessary to disable some subtests or add a new
    103    test that belongs to a test suite not already present in this directory. To
    104    do this, please clone the bits source from
    105    https://gitlab.com/qemu-project/biosbits-bits/-/tree/qemu-bits.
    106    Note that this is the "qemu-bits" branch and not the "bits" branch of the
    107    repository. "qemu-bits" is the branch where we have made all the QEMU
    108    specific enhancements and we must use the source from this branch only.
    109    Copy the test suite/script that needs modification (addition of new tests
    110    or disabling them) from python directory into this directory. For
    111    example, in order to change cpuid related tests, copy the following
    112    file into this directory and rename it with .py2 extension:
    113    https://gitlab.com/qemu-project/biosbits-bits/-/blob/qemu-bits/python/testcpuid.py
    114    Then make your additions and changes here. Therefore, the steps are:
    115 
    116        (a) Copy unmodified test script to this directory from bits source.
    117        (b) Add a SPDX license header.
    118        (c) Perform modifications to the test.
    119 
    120    Commits (a), (b) and (c) should go under separate commits so that the original
    121    test script and the changes we have made are separated and clear.
    122 
    123    The test framework will then use your modified test script to run the test.
    124    No further changes would be needed. Please check the logs to make sure that
    125    appropriate changes have taken effect.
    126 
    127    The tests have an extension .py2 in order to indicate that:
    128 
    129    (a) They are python2.7 based scripts and not python 3 scripts.
    130    (b) They are run from within the bios bits VM and is not subjected to QEMU
    131        build/test python script maintenance and dependency resolutions.
    132    (c) They need not be loaded by avocado framework when running tests.
    133 
    134 
    135 Author: Ani Sinha <ani@anisinha.ca>
    136 
    137 References:
    138 -----------
    139 .. [#a] https://blog.linuxplumbersconf.org/2011/ocw/system/presentations/867/original/bits.pdf
    140 .. [#b] https://www.youtube.com/watch?v=36QIepyUuhg
    141