In this test, "scmi" command is tested against different sub-commands.
Please note that scmi command is for debug purpose and is not intended
in production system.

Signed-off-by: AKASHI Takahiro <takahiro.aka...@linaro.org>
Reviewed-by: Simon Glass <s...@chromium.org>
Reviewed-by: Etienne Carriere <etienne.carri...@foss.st.com>
---
v3
* change char to u8 in vendor/agent names
v2
* use helper functions, removing direct uses of ops
---
 test/dm/scmi.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 57 insertions(+), 5 deletions(-)

diff --git a/test/dm/scmi.c b/test/dm/scmi.c
index 0785948186f0..423b6ef70b29 100644
--- a/test/dm/scmi.c
+++ b/test/dm/scmi.c
@@ -104,8 +104,7 @@ static int dm_test_scmi_base(struct unit_test_state *uts)
        struct scmi_agent_priv *priv;
        u32 version, num_agents, num_protocols, impl_version;
        u32 attributes, agent_id;
-       char *vendor, *agent_name;
-       u8 *protocols;
+       u8 *vendor, *agent_name, *protocols;
        int ret;
 
        /* preparation */
@@ -134,9 +133,9 @@ static int dm_test_scmi_base(struct unit_test_state *uts)
        free(vendor);
 
        /* message attributes */
-       ret = scmi_protocol_message_attrs(base,
-                                         SCMI_BASE_DISCOVER_SUB_VENDOR,
-                                         &attributes);
+       ret = scmi_base_protocol_message_attrs(base,
+                                              SCMI_BASE_DISCOVER_SUB_VENDOR,
+                                              &attributes);
        ut_assertok(ret);
        ut_assertok(attributes);
 
@@ -207,6 +206,59 @@ static int dm_test_scmi_base(struct unit_test_state *uts)
 
 DM_TEST(dm_test_scmi_base, UT_TESTF_SCAN_FDT);
 
+static int dm_test_scmi_cmd(struct unit_test_state *uts)
+{
+       struct udevice *agent_dev;
+
+       /* preparation */
+       ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi",
+                                             &agent_dev));
+       ut_assertnonnull(agent_dev);
+
+       /* scmi info */
+       ut_assertok(run_command("scmi info", 0));
+
+       ut_assert_nextline("SCMI device: scmi");
+       ut_assert_nextline("  protocol version: 0x20000");
+       ut_assert_nextline("  # of agents: 2");
+       ut_assert_nextline("      0: platform");
+       ut_assert_nextline("    > 1: OSPM");
+       ut_assert_nextline("  # of protocols: 3");
+       ut_assert_nextline("      Clock management");
+       ut_assert_nextline("      Reset domain management");
+       ut_assert_nextline("      Voltage domain management");
+       ut_assert_nextline("  vendor: U-Boot");
+       ut_assert_nextline("  sub vendor: Sandbox");
+       ut_assert_nextline("  impl version: 0x1");
+
+       ut_assert_console_end();
+
+       /* scmi perm_dev */
+       ut_assertok(run_command("scmi perm_dev 1 0 1", 0));
+       ut_assert_console_end();
+
+       ut_assert(run_command("scmi perm_dev 1 0 0", 0));
+       ut_assert_nextline("Denying access to device:0 failed (-13)");
+       ut_assert_console_end();
+
+       /* scmi perm_proto */
+       ut_assertok(run_command("scmi perm_proto 1 0 14 1", 0));
+       ut_assert_console_end();
+
+       ut_assert(run_command("scmi perm_proto 1 0 14 0", 0));
+       ut_assert_nextline("Denying access to protocol:0x14 on device:0 failed 
(-13)");
+       ut_assert_console_end();
+
+       /* scmi reset */
+       ut_assert(run_command("scmi reset 1 1", 0));
+       ut_assert_nextline("Reset failed (-13)");
+       ut_assert_console_end();
+
+       return 0;
+}
+
+DM_TEST(dm_test_scmi_cmd, UT_TESTF_SCAN_FDT);
+
 static int dm_test_scmi_clocks(struct unit_test_state *uts)
 {
        struct sandbox_scmi_agent *agent;
-- 
2.34.1

Reply via email to