2
0

acpi-bits.rst 6.8 KB

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