blob: 2a64143eecd30ecef06b168ee6303673ae01494b [file] [log] [blame]
Stephen Carlsone5c05ae2023-03-10 11:07:15 -08001// 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
Stephen Carlsone5c05ae2023-03-10 11:07:15 -080010#include <console.h>
11#include <test/suites.h>
12#include <test/ut.h>
13
14#define PCI_MPS_TEST(_name, _flags) UNIT_TEST(_name, _flags, pci_mps_test)
15
16/* Test "pci_mps" command in safe "s" mode */
17static int test_pci_mps_safe(struct unit_test_state *uts)
18{
19 /* Enumerate PCI Express first */
20 ut_assertok(run_command("pci e", 0));
21 ut_assert_console_end();
22
23 /* Test pci_mps s */
24 ut_assertok(run_command("pci_mps s", 0));
25 ut_assert_nextline("Setting MPS of all devices to 256B");
26 ut_assert_console_end();
27
28 return 0;
29}
30
31PCI_MPS_TEST(test_pci_mps_safe, UT_TESTF_CONSOLE_REC);
32
33int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc,
34 char * const argv[])
35{
36 struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps_test);
37 const int n = UNIT_TEST_SUITE_COUNT(pci_mps_test);
38
39 return cmd_ut_category("cmd_pci_mps", "pci_mps_test_", tests, n,
40 argc, argv);
41}