pci_mps.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Tests that the PCI Maximum Payload Size (MPS) command can set the sandbox
  4. * PCI Express device to safe mode and determine the correct payload size.
  5. *
  6. * Copyright 2023 Microsoft
  7. * Written by Stephen Carlson <stcarlso@linux.microsoft.com>
  8. */
  9. #include <common.h>
  10. #include <console.h>
  11. #include <test/suites.h>
  12. #include <test/ut.h>
  13. #define PCI_MPS_TEST(_name, _flags) UNIT_TEST(_name, _flags, pci_mps_test)
  14. /* Test "pci_mps" command in safe "s" mode */
  15. static int test_pci_mps_safe(struct unit_test_state *uts)
  16. {
  17. /* Enumerate PCI Express first */
  18. ut_assertok(run_command("pci e", 0));
  19. ut_assert_console_end();
  20. /* Test pci_mps s */
  21. ut_assertok(run_command("pci_mps s", 0));
  22. ut_assert_nextline("Setting MPS of all devices to 256B");
  23. ut_assert_console_end();
  24. return 0;
  25. }
  26. PCI_MPS_TEST(test_pci_mps_safe, UT_TESTF_CONSOLE_REC);
  27. int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc,
  28. char * const argv[])
  29. {
  30. struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps_test);
  31. const int n = UNIT_TEST_SUITE_COUNT(pci_mps_test);
  32. return cmd_ut_category("cmd_pci_mps", "pci_mps_test_", tests, n,
  33. argc, argv);
  34. }