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