blob: ae4bb02f18078fd8e6694f64f48ff0c809c423c0 [file] [log] [blame]
From 6f998a5e94e2562b5876b88864876c8b03b88f5a Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Tue, 16 Nov 2021 12:38:48 +0000
Subject: [PATCH 09/24] arm_ffa: introducing test module for UCLASS_FFA
This is the test module for the UCLASS_FFA class.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
MAINTAINERS | 1 +
test/dm/Makefile | 1 +
test/dm/ffa.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
test/dm/ffa.h | 19 ++++++++++++++++
4 files changed, 77 insertions(+)
create mode 100644 test/dm/ffa.c
create mode 100644 test/dm/ffa.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 32fc267fcf13..8209dc9319f1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -252,6 +252,7 @@ F: drivers/arm-ffa/
F: include/arm_ffa.h
F: include/arm_ffa_helper.h
F: lib/arm-ffa/
+F: test/dm/ffa.c
ARM FREESCALE IMX
M: Stefano Babic <sbabic@denx.de>
diff --git a/test/dm/Makefile b/test/dm/Makefile
index f0a7c97e3d17..09a3403d2f53 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -79,6 +79,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
obj-$(CONFIG_ACPI_PMC) += pmc.o
obj-$(CONFIG_DM_PMIC) += pmic.o
obj-$(CONFIG_DM_PWM) += pwm.o
+obj-$(CONFIG_ARM_FFA_TRANSPORT) += ffa.o
obj-$(CONFIG_QFW) += qfw.o
obj-$(CONFIG_RAM) += ram.o
obj-y += regmap.o
diff --git a/test/dm/ffa.c b/test/dm/ffa.c
new file mode 100644
index 000000000000..b937cea57b80
--- /dev/null
+++ b/test/dm/ffa.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for UCLASS_FFA class
+ *
+ * (C) Copyright 2021 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <test/test.h>
+#include <test/ut.h>
+#include <arm_ffa_helper.h>
+#include "ffa.h"
+
+/* Basic test of 'armffa' command */
+static int dm_test_armffa_cmd(struct unit_test_state *uts)
+{
+ ut_assertok(ffa_helper_init_device());
+
+ ut_assertok(console_record_reset_enable());
+
+ /* armffa getpart <UUID> */
+ ut_assertok(run_command("armffa getpart " SE_PROXY_PARTITION_UUID, 0));
+ ut_assert_console_end();
+
+ /* armffa ping <ID> */
+ ut_assertok(run_command("armffa ping " SE_PROXY_PARTITION_ID, 0));
+ ut_assert_console_end();
+
+ /* armffa devlist */
+ ut_assertok(run_command("armffa devlist", 0));
+ ut_assert_console_end();
+
+ return 0;
+}
+
+DM_TEST(dm_test_armffa_cmd, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);
+
+static int test_ffa_msg_send_direct_req(void)
+{
+ char *const argv[1] = {SE_PROXY_PARTITION_ID}; /* Corstone1000 SE Proxy ID */
+
+ return do_ffa_msg_send_direct_req(NULL, 0, 1, argv);
+}
+
+/* Basic test of the FFA uclass */
+static int dm_test_ffa_uclass(struct unit_test_state *uts)
+{
+ ut_assertok(ffa_init_device());
+ ut_assertok(test_ffa_msg_send_direct_req());
+ return 0;
+}
+
+DM_TEST(dm_test_ffa_uclass, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/ffa.h b/test/dm/ffa.h
new file mode 100644
index 000000000000..a0802bd6928a
--- /dev/null
+++ b/test/dm/ffa.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2021 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+ */
+
+#ifndef __TEST_DM_FFA_H
+#define __TEST_DM_FFA_H
+
+#define SE_PROXY_PARTITION_ID "0x8002"
+#define SE_PROXY_PARTITION_UUID "46bb39d1-b4d9-45b5-88ff-040027dab249"
+
+/**
+ * do_ffa_msg_send_direct_req - implementation of the ping subcommand
+ */
+int do_ffa_msg_send_direct_req(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[]);
+
+#endif /*__TEST_DM_FFA_H */
--
2.37.1