[V3,4/4] test: Add basic tests for remoteproc

Message ID 1442522562-20764-5-git-send-email-nm@ti.com
State Accepted
Commit bfaa2d99dc47b44f4e76bc029c2feb75634ca5c6
Headers show

Commit Message

Nishanth Menon Sept. 17, 2015, 8:42 p.m.
Use the sandbox environment for the basic tests.

Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Nishanth Menon <nm@ti.com>
---

Changes since V1:
	- Comment cleanup (dropped '..')
	- Picked up Simon's Tested and Reviewed tags from V2

V2: https://patchwork.ozlabs.org/patch/511749/
V1: did not exist

 test/dm/Makefile     |  1 +
 test/dm/remoteproc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+)
 create mode 100644 test/dm/remoteproc.c

Comments

Simon Glass Oct. 1, 2015, 10:59 p.m. | #1
On Thursday, 17 September 2015, Nishanth Menon <nm@ti.com> wrote:
>
> Use the sandbox environment for the basic tests.
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Tested-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
>
> Changes since V1:
>         - Comment cleanup (dropped '..')
>         - Picked up Simon's Tested and Reviewed tags from V2
>
> V2: https://patchwork.ozlabs.org/patch/511749/
> V1: did not exist
>
>  test/dm/Makefile     |  1 +
>  test/dm/remoteproc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 68 insertions(+)
>  create mode 100644 test/dm/remoteproc.c


Acked-by: Simon Glass <sjg@chromium.org>
>
>
Tom Rini Oct. 22, 2015, 9:20 p.m. | #2
On Thu, Sep 17, 2015 at 03:42:42PM -0500, Nishanth Menon wrote:

> Use the sandbox environment for the basic tests.
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Tested-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

Patch

diff --git a/test/dm/Makefile b/test/dm/Makefile
index eda964318593..7b3626cb3294 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -24,6 +24,7 @@  obj-$(CONFIG_DM_MMC) += mmc.o
 obj-$(CONFIG_DM_PCI) += pci.o
 obj-$(CONFIG_RAM) += ram.o
 obj-y += regmap.o
+obj-$(CONFIG_REMOTEPROC) += remoteproc.o
 obj-$(CONFIG_RESET) += reset.o
 obj-$(CONFIG_DM_RTC) += rtc.o
 obj-$(CONFIG_DM_SPI_FLASH) += sf.o
diff --git a/test/dm/remoteproc.c b/test/dm/remoteproc.c
new file mode 100644
index 000000000000..0e5f3305a252
--- /dev/null
+++ b/test/dm/remoteproc.c
@@ -0,0 +1,67 @@ 
+/*
+ * (C) Copyright 2015
+ * Texas Instruments Incorporated - http://www.ti.com/
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <remoteproc.h>
+#include <dm/test.h>
+#include <test/ut.h>
+/**
+ * dm_test_remoteproc_base() - test the operations after initializations
+ * @uts:	unit test state
+ *
+ * Return:	0 if test passed, else error
+ */
+static int dm_test_remoteproc_base(struct unit_test_state *uts)
+{
+	if (!rproc_is_initialized())
+		ut_assertok(rproc_init());
+
+	/* Ensure we are initialized */
+	ut_asserteq(true, rproc_is_initialized());
+
+
+	/* platform data device 1 */
+	ut_assertok(rproc_stop(0));
+	ut_assertok(rproc_reset(0));
+	/* -> invalid attempt tests */
+	ut_asserteq(-EINVAL, rproc_start(0));
+	ut_asserteq(-EINVAL, rproc_ping(0));
+	/* Valid tests */
+	ut_assertok(rproc_load(0, 1, 0));
+	ut_assertok(rproc_start(0));
+	ut_assertok(rproc_is_running(0));
+	ut_assertok(rproc_ping(0));
+	ut_assertok(rproc_reset(0));
+	ut_assertok(rproc_stop(0));
+
+	/* dt device device 1 */
+	ut_assertok(rproc_stop(1));
+	ut_assertok(rproc_reset(1));
+	ut_assertok(rproc_load(1, 1, 0));
+	ut_assertok(rproc_start(1));
+	ut_assertok(rproc_is_running(1));
+	ut_assertok(rproc_ping(1));
+	ut_assertok(rproc_reset(1));
+	ut_assertok(rproc_stop(1));
+
+	/* dt device device 2 */
+	ut_assertok(rproc_stop(0));
+	ut_assertok(rproc_reset(0));
+	/* -> invalid attempt tests */
+	ut_asserteq(-EINVAL, rproc_start(0));
+	ut_asserteq(-EINVAL, rproc_ping(0));
+	/* Valid tests */
+	ut_assertok(rproc_load(2, 1, 0));
+	ut_assertok(rproc_start(2));
+	ut_assertok(rproc_is_running(2));
+	ut_assertok(rproc_ping(2));
+	ut_assertok(rproc_reset(2));
+	ut_assertok(rproc_stop(2));
+
+	return 0;
+}
+DM_TEST(dm_test_remoteproc_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);