blob: 4fb317ba85d291a407c78534226612892673abf4 [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001From c9a2c457648b732292482fae59a7fd61cefffd33 Mon Sep 17 00:00:00 2001
2From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
3Date: Tue, 16 Nov 2021 12:38:48 +0000
4Subject: [PATCH 09/27] arm_ffa: introducing test module for UCLASS_FFA
5
6This is the test module for the UCLASS_FFA class.
7
8Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
9Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
10---
11 MAINTAINERS | 1 +
12 test/dm/Makefile | 1 +
13 test/dm/ffa.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
14 test/dm/ffa.h | 19 ++++++++++++++++
15 4 files changed, 77 insertions(+)
16 create mode 100644 test/dm/ffa.c
17 create mode 100644 test/dm/ffa.h
18
19diff --git a/MAINTAINERS b/MAINTAINERS
20index f3fd559da54a..6510f844fe09 100644
21--- a/MAINTAINERS
22+++ b/MAINTAINERS
23@@ -240,6 +240,7 @@ F: drivers/arm-ffa/
24 F: include/arm_ffa.h
25 F: include/arm_ffa_helper.h
26 F: lib/arm-ffa/
27+F: test/dm/ffa.c
28
29 ARM FREESCALE IMX
30 M: Stefano Babic <sbabic@denx.de>
31diff --git a/test/dm/Makefile b/test/dm/Makefile
32index d46552fbf320..ddac250cdff0 100644
33--- a/test/dm/Makefile
34+++ b/test/dm/Makefile
35@@ -79,6 +79,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
36 obj-$(CONFIG_ACPI_PMC) += pmc.o
37 obj-$(CONFIG_DM_PMIC) += pmic.o
38 obj-$(CONFIG_DM_PWM) += pwm.o
39+obj-$(CONFIG_ARM_FFA_TRANSPORT) += ffa.o
40 obj-$(CONFIG_QFW) += qfw.o
41 obj-$(CONFIG_RAM) += ram.o
42 obj-y += regmap.o
43diff --git a/test/dm/ffa.c b/test/dm/ffa.c
44new file mode 100644
45index 000000000000..b937cea57b80
46--- /dev/null
47+++ b/test/dm/ffa.c
48@@ -0,0 +1,56 @@
49+// SPDX-License-Identifier: GPL-2.0+
50+/*
51+ * Test for UCLASS_FFA class
52+ *
53+ * (C) Copyright 2021 ARM Limited
54+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
55+ */
56+
57+#include <common.h>
58+#include <dm.h>
59+#include <dm/test.h>
60+#include <test/test.h>
61+#include <test/ut.h>
62+#include <arm_ffa_helper.h>
63+#include "ffa.h"
64+
65+/* Basic test of 'armffa' command */
66+static int dm_test_armffa_cmd(struct unit_test_state *uts)
67+{
68+ ut_assertok(ffa_helper_init_device());
69+
70+ ut_assertok(console_record_reset_enable());
71+
72+ /* armffa getpart <UUID> */
73+ ut_assertok(run_command("armffa getpart " SE_PROXY_PARTITION_UUID, 0));
74+ ut_assert_console_end();
75+
76+ /* armffa ping <ID> */
77+ ut_assertok(run_command("armffa ping " SE_PROXY_PARTITION_ID, 0));
78+ ut_assert_console_end();
79+
80+ /* armffa devlist */
81+ ut_assertok(run_command("armffa devlist", 0));
82+ ut_assert_console_end();
83+
84+ return 0;
85+}
86+
87+DM_TEST(dm_test_armffa_cmd, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);
88+
89+static int test_ffa_msg_send_direct_req(void)
90+{
91+ char *const argv[1] = {SE_PROXY_PARTITION_ID}; /* Corstone1000 SE Proxy ID */
92+
93+ return do_ffa_msg_send_direct_req(NULL, 0, 1, argv);
94+}
95+
96+/* Basic test of the FFA uclass */
97+static int dm_test_ffa_uclass(struct unit_test_state *uts)
98+{
99+ ut_assertok(ffa_init_device());
100+ ut_assertok(test_ffa_msg_send_direct_req());
101+ return 0;
102+}
103+
104+DM_TEST(dm_test_ffa_uclass, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
105diff --git a/test/dm/ffa.h b/test/dm/ffa.h
106new file mode 100644
107index 000000000000..a0802bd6928a
108--- /dev/null
109+++ b/test/dm/ffa.h
110@@ -0,0 +1,19 @@
111+/* SPDX-License-Identifier: GPL-2.0+ */
112+/*
113+ * (C) Copyright 2021 ARM Limited
114+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
115+ */
116+
117+#ifndef __TEST_DM_FFA_H
118+#define __TEST_DM_FFA_H
119+
120+#define SE_PROXY_PARTITION_ID "0x8002"
121+#define SE_PROXY_PARTITION_UUID "46bb39d1-b4d9-45b5-88ff-040027dab249"
122+
123+/**
124+ * do_ffa_msg_send_direct_req - implementation of the ping subcommand
125+ */
126+int do_ffa_msg_send_direct_req(struct cmd_tbl *cmdtp, int flag, int argc,
127+ char *const argv[]);
128+
129+#endif /*__TEST_DM_FFA_H */
130--
1312.30.2
132