test: log: Give tests names instead of numbers
[platform/kernel/u-boot.git] / test / dm / axi.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2018
4  * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
5  */
6
7 #include <common.h>
8 #include <axi.h>
9 #include <dm.h>
10 #include <log.h>
11 #include <asm/axi.h>
12 #include <dm/test.h>
13 #include <test/test.h>
14 #include <test/ut.h>
15
16 /* Test that sandbox AXI works correctly */
17 static int dm_test_axi_base(struct unit_test_state *uts)
18 {
19         struct udevice *bus;
20
21         ut_assertok(uclass_get_device(UCLASS_AXI, 0, &bus));
22
23         return 0;
24 }
25
26 DM_TEST(dm_test_axi_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
27
28 /* Test that sandbox PCI bus numbering works correctly */
29 static int dm_test_axi_busnum(struct unit_test_state *uts)
30 {
31         struct udevice *bus;
32
33         ut_assertok(uclass_get_device_by_seq(UCLASS_AXI, 0, &bus));
34
35         return 0;
36 }
37
38 DM_TEST(dm_test_axi_busnum, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
39
40 /* Test that we can use the store device correctly */
41 static int dm_test_axi_store(struct unit_test_state *uts)
42 {
43         struct udevice *store;
44         u8 tdata1[] = {0x55, 0x66, 0x77, 0x88};
45         u8 tdata2[] = {0xaa, 0xbb, 0xcc, 0xdd};
46         u32 val;
47         u8 *data;
48
49         /* Check that asking for the device automatically fires up AXI */
50         ut_assertok(uclass_get_device(UCLASS_AXI_EMUL, 0, &store));
51         ut_assert(device_active(store));
52
53         axi_get_store(store, &data);
54
55         /* Test reading */
56         memcpy(data, tdata1, ARRAY_SIZE(tdata1));
57         axi_read(store, 0, &val, AXI_SIZE_32);
58         ut_asserteq(0x55667788, val);
59
60         memcpy(data + 3, tdata2, ARRAY_SIZE(tdata2));
61         axi_read(store, 3, &val, AXI_SIZE_32);
62         ut_asserteq(0xaabbccdd, val);
63
64         /* Reset data store */
65         memset(data, 0, 16);
66
67         /* Test writing */
68         val = 0x55667788;
69         axi_write(store, 0, &val, AXI_SIZE_32);
70         ut_asserteq_mem(data, tdata1, ARRAY_SIZE(tdata1));
71
72         val = 0xaabbccdd;
73         axi_write(store, 3, &val, AXI_SIZE_32);
74         ut_asserteq_mem(data + 3, tdata2, ARRAY_SIZE(tdata1));
75
76         return 0;
77 }
78
79 DM_TEST(dm_test_axi_store, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);