summaryrefslogtreecommitdiff
path: root/test/dm
diff options
context:
space:
mode:
Diffstat (limited to 'test/dm')
-rw-r--r--test/dm/fdtdec.c73
-rw-r--r--test/dm/gpio.c2
-rw-r--r--test/dm/spi.c6
-rw-r--r--test/dm/video.c60
4 files changed, 113 insertions, 28 deletions
diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c
index b2f75b5843..56f6f4f6cc 100644
--- a/test/dm/fdtdec.c
+++ b/test/dm/fdtdec.c
@@ -9,6 +9,8 @@
#include <dm/test.h>
#include <test/ut.h>
+DECLARE_GLOBAL_DATA_PTR;
+
static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts)
{
struct fdt_memory resv;
@@ -20,7 +22,7 @@ static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts)
blob = malloc(blob_sz);
ut_assertnonnull(blob);
- /* Make a writtable copy of the fdt blob */
+ /* Make a writable copy of the fdt blob */
ut_assertok(fdt_open_into(gd->fdt_blob, blob, blob_sz));
resv.start = 0x1000;
@@ -57,3 +59,72 @@ static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts)
}
DM_TEST(dm_test_fdtdec_set_carveout,
DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
+
+static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
+{
+ struct fdt_memory resv;
+ fdt_addr_t addr;
+ fdt_size_t size;
+ void *blob;
+ int blob_sz, parent, subnode;
+ uint32_t phandle, phandle1;
+
+ blob_sz = fdt_totalsize(gd->fdt_blob) + 128;
+ blob = malloc(blob_sz);
+ ut_assertnonnull(blob);
+
+ /* Make a writable copy of the fdt blob */
+ ut_assertok(fdt_open_into(gd->fdt_blob, blob, blob_sz));
+
+ /* Insert a memory region in /reserved-memory node */
+ resv.start = 0x1000;
+ resv.end = 0x1fff;
+ ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region",
+ &resv, &phandle));
+
+ /* Test /reserve-memory and its subnode should exist */
+ parent = fdt_path_offset(blob, "/reserved-memory");
+ ut_assert(parent > 0);
+ subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region");
+ ut_assert(subnode > 0);
+
+ /* Test reg property of /reserved-memory/rsvd_region node */
+ addr = fdtdec_get_addr_size_auto_parent(blob, parent, subnode,
+ "reg", 0, &size, false);
+ ut_assert(addr == resv.start);
+ ut_assert(size == resv.end - resv.start + 1);
+
+ /* Insert another memory region in /reserved-memory node */
+ subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region1");
+ ut_assert(subnode < 0);
+
+ resv.start = 0x2000;
+ resv.end = 0x2fff;
+ ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region1",
+ &resv, &phandle1));
+ subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region1");
+ ut_assert(subnode > 0);
+
+ /* phandles must be different */
+ ut_assert(phandle != phandle1);
+
+ /*
+ * Insert a 3rd memory region with the same addr/size as the 1st one,
+ * but a new node should not be inserted due to the same addr/size.
+ */
+ resv.start = 0x1000;
+ resv.end = 0x1fff;
+ ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region2",
+ &resv, &phandle1));
+ subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region2");
+ ut_assert(subnode < 0);
+
+ /* phandle must be same as the 1st one */
+ ut_assert(phandle == phandle1);
+
+ free(blob);
+
+ return 0;
+}
+DM_TEST(dm_test_fdtdec_add_reserved_memory,
+ DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index fcee1fe598..e3be57b602 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -244,7 +244,7 @@ static int dm_test_gpio_anon(struct unit_test_state *uts)
/* And the anonymous bank */
ut_assertok(gpio_lookup_name("14", &dev, &offset, &gpio));
- ut_asserteq_str(dev->name, "gpio_sandbox");
+ ut_asserteq_str(dev->name, "sandbox_gpio");
ut_asserteq(14, offset);
ut_asserteq(14, gpio);
diff --git a/test/dm/spi.c b/test/dm/spi.c
index 474008cde0..ff2cddd245 100644
--- a/test/dm/spi.c
+++ b/test/dm/spi.c
@@ -58,7 +58,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
*/
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
ut_asserteq(-ENOENT, spi_get_bus_and_cs(busnum, cs, speed, mode,
- "spi_flash_std", "name", &bus,
+ "jedec_spi_nor", "name", &bus,
&slave));
sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
ut_assertok(spi_cs_info(bus, cs, &info));
@@ -69,7 +69,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
"name"));
ut_assertok(spi_find_bus_and_cs(busnum, cs, &bus, &dev));
ut_assertok(spi_get_bus_and_cs(busnum, cs, speed, mode,
- "spi_flash_std", "name", &bus, &slave));
+ "jedec_spi_nor", "name", &bus, &slave));
ut_assertok(spi_cs_info(bus, cs, &info));
ut_asserteq_ptr(info.dev, slave->dev);
@@ -78,7 +78,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, node,
"name"));
ut_asserteq(-EINVAL, spi_get_bus_and_cs(busnum, cs_b, speed, mode,
- "spi_flash_std", "name", &bus, &slave));
+ "jedec_spi_nor", "name", &bus, &slave));
ut_asserteq(-EINVAL, spi_cs_info(bus, cs_b, &info));
ut_asserteq_ptr(NULL, info.dev);
diff --git a/test/dm/video.c b/test/dm/video.c
index 0664e3f22b..19f78b6239 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -51,12 +51,18 @@ DM_TEST(dm_test_video_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
* size of the compressed data. This provides a pretty good level of
* certainty and the resulting tests need only check a single value.
*
+ * If the copy framebuffer is enabled, this compares it to the main framebuffer
+ * too.
+ *
+ * @uts: Test state
* @dev: Video device
* @return compressed size of the frame buffer, or -ve on error
*/
-static int compress_frame_buffer(struct udevice *dev)
+static int compress_frame_buffer(struct unit_test_state *uts,
+ struct udevice *dev)
{
struct video_priv *priv = dev_get_uclass_priv(dev);
+ struct video_priv *uc_priv = dev_get_uclass_priv(dev);
uint destlen;
void *dest;
int ret;
@@ -72,6 +78,13 @@ static int compress_frame_buffer(struct udevice *dev)
if (ret)
return ret;
+ /* Check here that the copy frame buffer is working correctly */
+ if (IS_ENABLED(CONFIG_VIDEO_COPY)) {
+ ut_assertf(!memcmp(uc_priv->fb, uc_priv->copy_fb,
+ uc_priv->fb_size),
+ "Copy framebuffer does not match fb");
+ }
+
return destlen;
}
@@ -110,25 +123,25 @@ static int dm_test_video_text(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
- ut_asserteq(46, compress_frame_buffer(dev));
+ ut_asserteq(46, compress_frame_buffer(uts, dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
vidconsole_putc_xy(con, 0, 0, 'a');
- ut_asserteq(79, compress_frame_buffer(dev));
+ ut_asserteq(79, compress_frame_buffer(uts, dev));
vidconsole_putc_xy(con, 0, 0, ' ');
- ut_asserteq(46, compress_frame_buffer(dev));
+ ut_asserteq(46, compress_frame_buffer(uts, dev));
for (i = 0; i < 20; i++)
vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- ut_asserteq(273, compress_frame_buffer(dev));
+ ut_asserteq(273, compress_frame_buffer(uts, dev));
vidconsole_set_row(con, 0, WHITE);
- ut_asserteq(46, compress_frame_buffer(dev));
+ ut_asserteq(46, compress_frame_buffer(uts, dev));
for (i = 0; i < 20; i++)
vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- ut_asserteq(273, compress_frame_buffer(dev));
+ ut_asserteq(273, compress_frame_buffer(uts, dev));
return 0;
}
@@ -144,7 +157,7 @@ static int dm_test_video_chars(struct unit_test_state *uts)
ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
vidconsole_put_string(con, test_string);
- ut_asserteq(466, compress_frame_buffer(dev));
+ ut_asserteq(466, compress_frame_buffer(uts, dev));
return 0;
}
@@ -164,20 +177,20 @@ static int dm_test_video_ansi(struct unit_test_state *uts)
/* reference clear: */
video_clear(con->parent);
video_sync(con->parent, false);
- ut_asserteq(46, compress_frame_buffer(dev));
+ ut_asserteq(46, compress_frame_buffer(uts, dev));
/* test clear escape sequence: [2J */
vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J");
- ut_asserteq(46, compress_frame_buffer(dev));
+ ut_asserteq(46, compress_frame_buffer(uts, dev));
/* test set-cursor: [%d;%df */
vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd");
- ut_asserteq(143, compress_frame_buffer(dev));
+ ut_asserteq(143, compress_frame_buffer(uts, dev));
/* test colors (30-37 fg color, 40-47 bg color) */
vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */
vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */
- ut_asserteq(272, compress_frame_buffer(dev));
+ ut_asserteq(272, compress_frame_buffer(uts, dev));
return 0;
}
@@ -188,7 +201,8 @@ DM_TEST(dm_test_video_ansi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
* check_vidconsole_output() - Run a text console test
*
* @uts: Test state
- * @rot: Console rotation (0, 90, 180, 270)
+ * @rot: Console rotation (0=normal orientation, 1=90 degrees clockwise,
+ * 2=upside down, 3=90 degree counterclockwise)
* @wrap_size: Expected size of compressed frame buffer for the wrap test
* @scroll_size: Same for the scroll test
* @return 0 on success
@@ -207,24 +221,24 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot,
ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_asserteq(46, compress_frame_buffer(dev));
+ ut_asserteq(46, compress_frame_buffer(uts, dev));
/* Check display wrap */
for (i = 0; i < 120; i++)
vidconsole_put_char(con, 'A' + i % 50);
- ut_asserteq(wrap_size, compress_frame_buffer(dev));
+ ut_asserteq(wrap_size, compress_frame_buffer(uts, dev));
/* Check display scrolling */
for (i = 0; i < SCROLL_LINES; i++) {
vidconsole_put_char(con, 'A' + i % 50);
vidconsole_put_char(con, '\n');
}
- ut_asserteq(scroll_size, compress_frame_buffer(dev));
+ ut_asserteq(scroll_size, compress_frame_buffer(uts, dev));
/* If we scroll enough, the screen becomes blank again */
for (i = 0; i < SCROLL_LINES; i++)
vidconsole_put_char(con, '\n');
- ut_asserteq(46, compress_frame_buffer(dev));
+ ut_asserteq(46, compress_frame_buffer(uts, dev));
return 0;
}
@@ -251,7 +265,7 @@ DM_TEST(dm_test_video_rotation1, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
/* Test rotated text output through the console uclass */
static int dm_test_video_rotation2(struct unit_test_state *uts)
{
- ut_assertok(check_vidconsole_output(uts, 2, 785, 446));
+ ut_assertok(check_vidconsole_output(uts, 2, 783, 445));
return 0;
}
@@ -298,7 +312,7 @@ static int dm_test_video_bmp(struct unit_test_state *uts)
ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- ut_asserteq(1368, compress_frame_buffer(dev));
+ ut_asserteq(1368, compress_frame_buffer(uts, dev));
return 0;
}
@@ -314,7 +328,7 @@ static int dm_test_video_bmp_comp(struct unit_test_state *uts)
ut_assertok(read_file(uts, "tools/logos/denx-comp.bmp", &addr));
ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- ut_asserteq(1368, compress_frame_buffer(dev));
+ ut_asserteq(1368, compress_frame_buffer(uts, dev));
return 0;
}
@@ -329,7 +343,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts)
ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
vidconsole_put_string(con, test_string);
- ut_asserteq(12237, compress_frame_buffer(dev));
+ ut_asserteq(12237, compress_frame_buffer(uts, dev));
return 0;
}
@@ -350,7 +364,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
vidconsole_put_string(con, test_string);
- ut_asserteq(35030, compress_frame_buffer(dev));
+ ut_asserteq(35030, compress_frame_buffer(uts, dev));
return 0;
}
@@ -371,7 +385,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
vidconsole_put_string(con, test_string);
- ut_asserteq(29018, compress_frame_buffer(dev));
+ ut_asserteq(29018, compress_frame_buffer(uts, dev));
return 0;
}