diff mbox series

[U-Boot,v2,5/7] test: Add AXI test

Message ID 20180523121047.28330-5-mario.six@gdsys.cc
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [U-Boot,v2,1/7] drivers: Add AXI uclass | expand

Commit Message

Mario Six May 23, 2018, 12:10 p.m. UTC
Add tests for the AXI uclass.

Signed-off-by: Mario Six <mario.six@gdsys.cc>

---

v1 -> v2:
* Fixed asserts (moved expected values first)

---
 test/dm/Makefile |  1 +
 test/dm/axi.c    | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 test/dm/axi.c

--
2.11.0

Comments

Simon Glass May 25, 2018, 2:41 a.m. UTC | #1
On 23 May 2018 at 06:10, Mario Six <mario.six@gdsys.cc> wrote:
> Add tests for the AXI uclass.
>
> Signed-off-by: Mario Six <mario.six@gdsys.cc>
>
> ---
>
> v1 -> v2:
> * Fixed asserts (moved expected values first)
>
> ---
>  test/dm/Makefile |  1 +
>  test/dm/axi.c    | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 75 insertions(+)
>  create mode 100644 test/dm/axi.c

Reviewed-by: Simon Glass <sjg@chromium.org>

Can you please use lower-case hex?
Mario Six June 25, 2018, 9:51 a.m. UTC | #2
Hi Simon,

On Fri, May 25, 2018 at 4:41 AM, Simon Glass <sjg@chromium.org> wrote:
> On 23 May 2018 at 06:10, Mario Six <mario.six@gdsys.cc> wrote:
>> Add tests for the AXI uclass.
>>
>> Signed-off-by: Mario Six <mario.six@gdsys.cc>
>>
>> ---
>>
>> v1 -> v2:
>> * Fixed asserts (moved expected values first)
>>
>> ---
>>  test/dm/Makefile |  1 +
>>  test/dm/axi.c    | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 75 insertions(+)
>>  create mode 100644 test/dm/axi.c
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> Can you please use lower-case hex?
>

OK, will switch to lower-case for v3.

Best regards,
Mario
diff mbox series

Patch

diff --git a/test/dm/Makefile b/test/dm/Makefile
index 5511a85700c..de8b9940888 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -43,4 +43,5 @@  obj-$(CONFIG_DM_VIDEO) += video.o
 obj-$(CONFIG_ADC) += adc.o
 obj-$(CONFIG_SPMI) += spmi.o
 obj-$(CONFIG_WDT) += wdt.o
+obj-$(CONFIG_AXI) += axi.o
 endif
diff --git a/test/dm/axi.c b/test/dm/axi.c
new file mode 100644
index 00000000000..cd31efd6126
--- /dev/null
+++ b/test/dm/axi.c
@@ -0,0 +1,74 @@ 
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <axi.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+/* Test that sandbox AXI works correctly */
+static int dm_test_axi_base(struct unit_test_state *uts)
+{
+	struct udevice *bus;
+
+	ut_assertok(uclass_get_device(UCLASS_AXI, 0, &bus));
+
+	return 0;
+}
+DM_TEST(dm_test_axi_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that sandbox PCI bus numbering works correctly */
+static int dm_test_axi_busnum(struct unit_test_state *uts)
+{
+	struct udevice *bus;
+
+	ut_assertok(uclass_get_device_by_seq(UCLASS_AXI, 0, &bus));
+
+	return 0;
+}
+DM_TEST(dm_test_axi_busnum, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that we can use the store device correctly */
+static int dm_test_axi_store(struct unit_test_state *uts)
+{
+	struct udevice *store;
+	u8 tdata1[] = {0x55, 0x66, 0x77, 0x88};
+	u8 tdata2[] = {0xAA, 0xBB, 0xCC, 0xDD};
+	u32 val;
+	u8 *data;
+
+	/* Check that asking for the device automatically fires up AXI */
+	ut_assertok(uclass_get_device(UCLASS_AXI_EMUL, 0, &store));
+	ut_assert(device_active(store));
+
+	axi_get_store(store, &data);
+
+	/* Test reading */
+	memcpy(data, tdata1, ARRAY_SIZE(tdata1));
+	axi_read(store, 0, &val, AXI_SIZE_32);
+	ut_asserteq(0x55667788, val);
+
+	memcpy(data + 3, tdata2, ARRAY_SIZE(tdata2));
+	axi_read(store, 3, &val, AXI_SIZE_32);
+	ut_asserteq(0xAABBCCDD, val);
+
+	/* Reset data store */
+	memset(data, 0, 16);
+
+	/* Test writing */
+	val = 0x55667788;
+	axi_write(store, 0, &val, AXI_SIZE_32);
+	ut_asserteq(0, memcmp(data, tdata1, ARRAY_SIZE(tdata1)));
+
+	val = 0xAABBCCDD;
+	axi_write(store, 3, &val, AXI_SIZE_32);
+	ut_asserteq(0, memcmp(data + 3, tdata2, ARRAY_SIZE(tdata1)));
+
+	return 0;
+}
+DM_TEST(dm_test_axi_store, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);