test_spl.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. # SPDX-License-Identifier: GPL-2.0
  2. # Copyright 2020 Google LLC
  3. # Written by Simon Glass <sjg@chromium.org>
  4. import os.path
  5. import pytest
  6. def test_spl(u_boot_console, ut_spl_subtest):
  7. """Execute a "ut" subtest.
  8. The subtests are collected in function generate_ut_subtest() from linker
  9. generated lists by applying a regular expression to the lines of file
  10. spl/u-boot-spl.sym. The list entries are created using the C macro
  11. UNIT_TEST().
  12. Strict naming conventions have to be followed to match the regular
  13. expression. Use UNIT_TEST(foo_test_bar, _flags, foo_test) for a test bar in
  14. test suite foo that can be executed via command 'ut foo bar' and is
  15. implemented in C function foo_test_bar().
  16. Args:
  17. u_boot_console (ConsoleBase): U-Boot console
  18. ut_subtest (str): SPL test to be executed (e.g. 'dm platdata_phandle')
  19. """
  20. try:
  21. cons = u_boot_console
  22. cons.restart_uboot_with_flags(['-u', '-k', ut_spl_subtest.split()[1]])
  23. output = cons.get_spawn_output().replace('\r', '')
  24. assert 'Failures: 0' in output
  25. finally:
  26. # Restart afterward in case a non-SPL test is run next. This should not
  27. # happen since SPL tests are run in their own invocation of test.py, but
  28. # the cost of doing this is not too great at present.
  29. u_boot_console.restart_uboot()