summaryrefslogtreecommitdiff
path: root/test/cmd/pci_mps.c
diff options
context:
space:
mode:
authorStephen Carlson <stcarlso@linux.microsoft.com>2023-03-10 11:07:15 -0800
committerTom Rini <trini@konsulko.com>2023-03-30 15:09:59 -0400
commit447dfbc0638f65accaeba1afa3b33840bdb46b6e (patch)
tree8bcd6106c63f87c1f702d95a5a18950aecc1f38a /test/cmd/pci_mps.c
parent713db6f6d3a3212270fd12ba5c47e986b36dbc39 (diff)
test: Add test for new command pci_mps
Adds a test for the new pci_mps command to ensure that it can set the Maximum Payload Size (MPS) of all devices to 256 bytes in the sandbox environment. Enables the pci_mps command in the sandbox environment so that this test can be run. Signed-off-by: Stephen Carlson <stcarlso@linux.microsoft.com>
Diffstat (limited to 'test/cmd/pci_mps.c')
-rw-r--r--test/cmd/pci_mps.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/cmd/pci_mps.c b/test/cmd/pci_mps.c
new file mode 100644
index 00000000000..fd96f4fba6c
--- /dev/null
+++ b/test/cmd/pci_mps.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests that the PCI Maximum Payload Size (MPS) command can set the sandbox
+ * PCI Express device to safe mode and determine the correct payload size.
+ *
+ * Copyright 2023 Microsoft
+ * Written by Stephen Carlson <stcarlso@linux.microsoft.com>
+ */
+
+#include <common.h>
+#include <console.h>
+#include <test/suites.h>
+#include <test/ut.h>
+
+#define PCI_MPS_TEST(_name, _flags) UNIT_TEST(_name, _flags, pci_mps_test)
+
+/* Test "pci_mps" command in safe "s" mode */
+static int test_pci_mps_safe(struct unit_test_state *uts)
+{
+ /* Enumerate PCI Express first */
+ ut_assertok(run_command("pci e", 0));
+ ut_assert_console_end();
+
+ /* Test pci_mps s */
+ ut_assertok(run_command("pci_mps s", 0));
+ ut_assert_nextline("Setting MPS of all devices to 256B");
+ ut_assert_console_end();
+
+ return 0;
+}
+
+PCI_MPS_TEST(test_pci_mps_safe, UT_TESTF_CONSOLE_REC);
+
+int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps_test);
+ const int n = UNIT_TEST_SUITE_COUNT(pci_mps_test);
+
+ return cmd_ut_category("cmd_pci_mps", "pci_mps_test_", tests, n,
+ argc, argv);
+}