summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-07-14 13:26:42 -0400
committerTom Rini <trini@konsulko.com>2023-07-14 13:26:42 -0400
commitb3bbad816e97538c8c3b8acad7c7e134261cf3a3 (patch)
tree0cfdcc657a9e0b3a5cf91e5fbb3ef2415aa2b12f /test
parentcef36755094f0c5463ff34ac89de8d88ef68982b (diff)
parent04f3dcd503a537fab50329686874559dae8a1a22 (diff)
Merge branch '2023-07-14-expo-initial-config-editor'
To quote the author: This series provides a means to edit board configuration in U-Boot in a graphical manner. It supports multiple menu items and allows moving between them and selecting items. The configuration is defined in a data format so that code is not needed in most cases. This allows the board configuration to be provided in the devicetree. This is still at an early stage, since it only supports menus. Numeric values are not supported. Most importantly it does not yet support loading or saving the configuration selected by the user. To try it out you can use something like: ./tools/expo.py -e test/boot/files/expo_layout.dts \ -l test/boot/files/expo_layout.dts -o cedit.dtb ./u-boot -Tl -c "cedit load hostfs - cedit.dtb; cedit run" Use the arrow keys to move between menus, enter to open a menu, escape to exit. Various minor fixes and improvements are provided in this series: - Update STB TrueType library to latest - Support clearing part of the video display - Support multiple livetrees loaded at runtime - Support loading and allocating a file - Support proper measuring of text in expo - Support simple themes for expo
Diffstat (limited to 'test')
-rw-r--r--test/boot/expo.c241
-rw-r--r--test/boot/files/expo_layout.dts84
-rw-r--r--test/cmd/bdinfo.c79
-rw-r--r--test/dm/ofnode.c45
-rw-r--r--test/dm/video.c6
-rw-r--r--test/py/tests/test_ut.py10
6 files changed, 399 insertions, 66 deletions
diff --git a/test/boot/expo.c b/test/boot/expo.c
index 7104dff05e8..3898f853a75 100644
--- a/test/boot/expo.c
+++ b/test/boot/expo.c
@@ -5,6 +5,7 @@
*/
#include <common.h>
+#include <command.h>
#include <dm.h>
#include <expo.h>
#include <menu.h>
@@ -13,6 +14,7 @@
#include <test/suites.h>
#include <test/ut.h>
#include "bootstd_common.h"
+#include <test/cedit-test.h>
#include "../../boot/scene_internal.h"
enum {
@@ -28,6 +30,8 @@ enum {
OBJ_MENU_TITLE,
/* strings */
+ STR_SCENE_TITLE,
+
STR_TEXT,
STR_TEXT2,
STR_MENU_TITLE,
@@ -120,7 +124,7 @@ static int expo_scene(struct unit_test_state *uts)
struct expo *exp;
ulong start_mem;
char name[100];
- int id;
+ int id, title_id;
start_mem = ut_check_free();
@@ -141,21 +145,20 @@ static int expo_scene(struct unit_test_state *uts)
ut_asserteq_str(SCENE_NAME1, scn->name);
/* Set the title */
- strcpy(name, SCENE_TITLE);
- ut_assertok(scene_title_set(scn, name));
- *name = '\0';
- ut_assertnonnull(scn->title);
- ut_asserteq_str(SCENE_TITLE, scn->title);
+ title_id = expo_str(exp, "title", STR_SCENE_TITLE, SCENE_TITLE);
+ ut_assert(title_id >= 0);
- /* Use an allocated ID */
+ /* Use an allocated ID - this will be allocated after the title str */
scn = NULL;
id = scene_new(exp, SCENE_NAME2, 0, &scn);
ut_assertnonnull(scn);
- ut_asserteq(SCENE2, id);
- ut_asserteq(SCENE2 + 1, exp->next_id);
+ ut_assertok(scene_title_set(scn, title_id));
+ ut_asserteq(STR_SCENE_TITLE + 1, id);
+ ut_asserteq(STR_SCENE_TITLE + 2, exp->next_id);
ut_asserteq_ptr(exp, scn->expo);
ut_asserteq_str(SCENE_NAME2, scn->name);
+ ut_asserteq(title_id, scn->title_id);
expo_destroy(exp);
@@ -225,7 +228,7 @@ static int expo_object(struct unit_test_state *uts)
}
BOOTSTD_TEST(expo_object, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
-/* Check setting object attributes */
+/* Check setting object attributes and using themes */
static int expo_object_attr(struct unit_test_state *uts)
{
struct scene_obj_menu *menu;
@@ -235,6 +238,7 @@ static int expo_object_attr(struct unit_test_state *uts)
struct expo *exp;
ulong start_mem;
char name[100];
+ ofnode node;
char *data;
int id;
@@ -249,8 +253,8 @@ static int expo_object_attr(struct unit_test_state *uts)
ut_assert(id > 0);
ut_assertok(scene_obj_set_pos(scn, OBJ_LOGO, 123, 456));
- ut_asserteq(123, img->obj.x);
- ut_asserteq(456, img->obj.y);
+ ut_asserteq(123, img->obj.dim.x);
+ ut_asserteq(456, img->obj.dim.y);
ut_asserteq(-ENOENT, scene_obj_set_pos(scn, OBJ_TEXT2, 0, 0));
@@ -272,6 +276,11 @@ static int expo_object_attr(struct unit_test_state *uts)
ut_asserteq(-ENOENT, scene_menu_set_title(scn, OBJ_TEXT2, OBJ_TEXT));
ut_asserteq(-EINVAL, scene_menu_set_title(scn, OBJ_MENU, OBJ_TEXT2));
+ node = ofnode_path("/bootstd/theme");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(expo_apply_theme(exp, node));
+ ut_asserteq(30, txt->font_size);
+
expo_destroy(exp);
ut_assertok(ut_check_delta(start_mem));
@@ -306,8 +315,8 @@ static int expo_object_menu(struct unit_test_state *uts)
ut_asserteq(0, menu->pointer_id);
ut_assertok(scene_obj_set_pos(scn, OBJ_MENU, 50, 400));
- ut_asserteq(50, menu->obj.x);
- ut_asserteq(400, menu->obj.y);
+ ut_asserteq(50, menu->obj.dim.x);
+ ut_asserteq(400, menu->obj.dim.y);
id = scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
"Main Menu", &tit);
@@ -347,29 +356,31 @@ static int expo_object_menu(struct unit_test_state *uts)
ut_asserteq(desc_id, item->desc_id);
ut_asserteq(preview_id, item->preview_id);
- /* adding an item should cause the first item to become current */
+ ut_assertok(scene_arrange(scn));
+
+ /* arranging the scene should cause the first item to become current */
ut_asserteq(id, menu->cur_item_id);
/* the title should be at the top */
- ut_asserteq(menu->obj.x, tit->obj.x);
- ut_asserteq(menu->obj.y, tit->obj.y);
+ ut_asserteq(menu->obj.dim.x, tit->obj.dim.x);
+ ut_asserteq(menu->obj.dim.y, tit->obj.dim.y);
/* the first item should be next */
- ut_asserteq(menu->obj.x, name1->obj.x);
- ut_asserteq(menu->obj.y + 32, name1->obj.y);
+ ut_asserteq(menu->obj.dim.x, name1->obj.dim.x);
+ ut_asserteq(menu->obj.dim.y + 32, name1->obj.dim.y);
- ut_asserteq(menu->obj.x + 230, key1->obj.x);
- ut_asserteq(menu->obj.y + 32, key1->obj.y);
+ ut_asserteq(menu->obj.dim.x + 230, key1->obj.dim.x);
+ ut_asserteq(menu->obj.dim.y + 32, key1->obj.dim.y);
- ut_asserteq(menu->obj.x + 200, ptr->obj.x);
- ut_asserteq(menu->obj.y + 32, ptr->obj.y);
+ ut_asserteq(menu->obj.dim.x + 200, ptr->obj.dim.x);
+ ut_asserteq(menu->obj.dim.y + 32, ptr->obj.dim.y);
- ut_asserteq(menu->obj.x + 280, desc1->obj.x);
- ut_asserteq(menu->obj.y + 32, desc1->obj.y);
+ ut_asserteq(menu->obj.dim.x + 280, desc1->obj.dim.x);
+ ut_asserteq(menu->obj.dim.y + 32, desc1->obj.dim.y);
- ut_asserteq(-4, prev1->obj.x);
- ut_asserteq(menu->obj.y + 32, prev1->obj.y);
- ut_asserteq(false, prev1->obj.hide);
+ ut_asserteq(-4, prev1->obj.dim.x);
+ ut_asserteq(menu->obj.dim.y + 32, prev1->obj.dim.y);
+ ut_asserteq(true, prev1->obj.flags & SCENEOF_HIDE);
expo_destroy(exp);
@@ -470,6 +481,48 @@ static int expo_render_image(struct unit_test_state *uts)
/* render without a scene */
ut_asserteq(-ECHILD, expo_render(exp));
+ ut_assertok(expo_calc_dims(exp));
+ ut_assertok(scene_arrange(scn));
+
+ /* check dimensions of text */
+ obj = scene_obj_find(scn, OBJ_TEXT, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(400, obj->dim.x);
+ ut_asserteq(100, obj->dim.y);
+ ut_asserteq(126, obj->dim.w);
+ ut_asserteq(40, obj->dim.h);
+
+ /* check dimensions of image */
+ obj = scene_obj_find(scn, OBJ_LOGO, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(50, obj->dim.x);
+ ut_asserteq(20, obj->dim.y);
+ ut_asserteq(160, obj->dim.w);
+ ut_asserteq(160, obj->dim.h);
+
+ /* check dimensions of menu labels - both should be the same width */
+ obj = scene_obj_find(scn, ITEM1_LABEL, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(50, obj->dim.x);
+ ut_asserteq(436, obj->dim.y);
+ ut_asserteq(29, obj->dim.w);
+ ut_asserteq(18, obj->dim.h);
+
+ obj = scene_obj_find(scn, ITEM2_LABEL, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(50, obj->dim.x);
+ ut_asserteq(454, obj->dim.y);
+ ut_asserteq(29, obj->dim.w);
+ ut_asserteq(18, obj->dim.h);
+
+ /* check dimensions of menu */
+ obj = scene_obj_find(scn, OBJ_MENU, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(50, obj->dim.x);
+ ut_asserteq(400, obj->dim.y);
+ ut_asserteq(160, obj->dim.w);
+ ut_asserteq(160, obj->dim.h);
+
/* render it */
expo_set_scene_id(exp, SCENE1);
ut_assertok(expo_render(exp));
@@ -479,16 +532,16 @@ static int expo_render_image(struct unit_test_state *uts)
ut_assertok(expo_action_get(exp, &act));
- ut_asserteq(EXPOACT_POINT, act.type);
+ ut_asserteq(EXPOACT_POINT_ITEM, act.type);
ut_asserteq(ITEM2, act.select.id);
ut_assertok(expo_render(exp));
/* make sure only the preview for the second item is shown */
obj = scene_obj_find(scn, ITEM1_PREVIEW, SCENEOBJT_NONE);
- ut_asserteq(true, obj->hide);
+ ut_asserteq(true, obj->flags & SCENEOF_HIDE);
obj = scene_obj_find(scn, ITEM2_PREVIEW, SCENEOBJT_NONE);
- ut_asserteq(false, obj->hide);
+ ut_asserteq(false, obj->flags & SCENEOF_HIDE);
/* select it */
ut_assertok(expo_send_key(exp, BKEY_SELECT));
@@ -504,7 +557,7 @@ static int expo_render_image(struct unit_test_state *uts)
ut_assert_console_end();
/* now try in text mode */
- exp_set_text_mode(exp, true);
+ expo_set_text_mode(exp, true);
ut_assertok(expo_render(exp));
ut_assert_nextline("U-Boot : Boot Menu");
@@ -519,7 +572,7 @@ static int expo_render_image(struct unit_test_state *uts)
ut_assertok(expo_action_get(exp, &act));
- ut_asserteq(EXPOACT_POINT, act.type);
+ ut_asserteq(EXPOACT_POINT_ITEM, act.type);
ut_asserteq(ITEM1, act.select.id);
ut_assertok(expo_render(exp));
@@ -537,3 +590,125 @@ static int expo_render_image(struct unit_test_state *uts)
return 0;
}
BOOTSTD_TEST(expo_render_image, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check building an expo from a devicetree description */
+static int expo_test_build(struct unit_test_state *uts)
+{
+ struct scene_obj_menu *menu;
+ struct scene_menitem *item;
+ struct scene_obj_txt *txt;
+ struct scene_obj *obj;
+ struct scene *scn;
+ struct expo *exp;
+ int count;
+ ofnode node;
+
+ node = ofnode_path("/cedit");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(expo_build(node, &exp));
+
+ ut_asserteq_str("name", exp->name);
+ ut_asserteq(0, exp->scene_id);
+ ut_asserteq(ID_DYNAMIC_START + 20, exp->next_id);
+ ut_asserteq(false, exp->popup);
+
+ /* check the scene */
+ scn = expo_lookup_scene_id(exp, ID_SCENE1);
+ ut_assertnonnull(scn);
+ ut_asserteq_str("main", scn->name);
+ ut_asserteq(ID_SCENE1, scn->id);
+ ut_asserteq(ID_DYNAMIC_START + 1, scn->title_id);
+ ut_asserteq(0, scn->highlight_id);
+
+ /* check the title */
+ txt = scene_obj_find(scn, scn->title_id, SCENEOBJT_NONE);
+ ut_assertnonnull(txt);
+ obj = &txt->obj;
+ ut_asserteq_ptr(scn, obj->scene);
+ ut_asserteq_str("title", obj->name);
+ ut_asserteq(scn->title_id, obj->id);
+ ut_asserteq(SCENEOBJT_TEXT, obj->type);
+ ut_asserteq(0, obj->flags);
+ ut_asserteq_str("Test Configuration", expo_get_str(exp, txt->str_id));
+
+ /* check the menu */
+ menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_NONE);
+ obj = &menu->obj;
+ ut_asserteq_ptr(scn, obj->scene);
+ ut_asserteq_str("cpu-speed", obj->name);
+ ut_asserteq(ID_CPU_SPEED, obj->id);
+ ut_asserteq(SCENEOBJT_MENU, obj->type);
+ ut_asserteq(0, obj->flags);
+
+ txt = scene_obj_find(scn, menu->title_id, SCENEOBJT_NONE);
+ ut_asserteq_str("CPU speed", expo_get_str(exp, txt->str_id));
+
+ ut_asserteq(0, menu->cur_item_id);
+ ut_asserteq(0, menu->pointer_id);
+
+ /* check the items */
+ item = list_first_entry(&menu->item_head, struct scene_menitem,
+ sibling);
+ ut_asserteq_str("00", item->name);
+ ut_asserteq(ID_CPU_SPEED_1, item->id);
+ ut_asserteq(0, item->key_id);
+ ut_asserteq(0, item->desc_id);
+ ut_asserteq(0, item->preview_id);
+ ut_asserteq(0, item->flags);
+
+ txt = scene_obj_find(scn, item->label_id, SCENEOBJT_NONE);
+ ut_asserteq_str("2 GHz", expo_get_str(exp, txt->str_id));
+
+ count = 0;
+ list_for_each_entry(item, &menu->item_head, sibling)
+ count++;
+ ut_asserteq(3, count);
+
+ expo_destroy(exp);
+
+ return 0;
+}
+BOOTSTD_TEST(expo_test_build, UT_TESTF_DM);
+
+/* Check the cedit command */
+static int expo_cedit(struct unit_test_state *uts)
+{
+ extern struct expo *cur_exp;
+ struct scene_obj_menu *menu;
+ struct scene_obj_txt *txt;
+ struct expo *exp;
+ struct scene *scn;
+
+ if (!IS_ENABLED(CONFIG_CMD_CEDIT))
+ return -EAGAIN;
+
+ ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
+
+ console_record_reset_enable();
+
+ /*
+ * ^N Move down to second menu
+ * ^M Open menu
+ * ^N Move down to second item
+ * ^M Select item
+ * \e Quit
+ */
+ console_in_puts("\x0e\x0d\x0e\x0d\e");
+ ut_assertok(run_command("cedit run", 0));
+
+ exp = cur_exp;
+ scn = expo_lookup_scene_id(exp, exp->scene_id);
+ ut_assertnonnull(scn);
+
+ menu = scene_obj_find(scn, scn->highlight_id, SCENEOBJT_NONE);
+ ut_assertnonnull(menu);
+
+ txt = scene_obj_find(scn, menu->title_id, SCENEOBJT_NONE);
+ ut_assertnonnull(txt);
+ ut_asserteq_str("AC Power", expo_get_str(exp, txt->str_id));
+
+ ut_asserteq(ID_AC_ON, menu->cur_item_id);
+
+ return 0;
+}
+BOOTSTD_TEST(expo_cedit, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
diff --git a/test/boot/files/expo_layout.dts b/test/boot/files/expo_layout.dts
new file mode 100644
index 00000000000..55d5c910dd5
--- /dev/null
+++ b/test/boot/files/expo_layout.dts
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Sample expo screen layout
+ */
+
+/dts-v1/;
+
+/*
+enum {
+ ZERO,
+ ID_PROMPT,
+
+ ID_SCENE1,
+ ID_SCENE1_TITLE,
+
+ ID_CPU_SPEED,
+ ID_CPU_SPEED_TITLE,
+ ID_CPU_SPEED_1,
+ ID_CPU_SPEED_2,
+ ID_CPU_SPEED_3,
+
+ ID_POWER_LOSS,
+ ID_AC_OFF,
+ ID_AC_ON,
+ ID_AC_MEMORY,
+
+ ID_DYNAMIC_START,
+};
+*/
+
+/ {
+ dynamic-start = <ID_DYNAMIC_START>;
+
+ scenes {
+ main {
+ id = <ID_SCENE1>;
+
+ /* value refers to the matching id in /strings */
+ title-id = <ID_SCENE1_TITLE>;
+
+ /* simple string is used as it is */
+ prompt = "UP and DOWN to choose, ENTER to select";
+
+ /* defines a menu within the scene */
+ cpu-speed {
+ type = "menu";
+ id = <ID_CPU_SPEED>;
+
+ /*
+ * has both string and ID. The string is ignored
+ * if the ID is present and points to a string
+ */
+ title = "CPU speed";
+ title-id = <ID_CPU_SPEED_TITLE>;
+
+ /* menu items as simple strings */
+ item-label = "2 GHz", "2.5 GHz", "3 GHz";
+
+ /* IDs for the menu items */
+ item-id = <ID_CPU_SPEED_1 ID_CPU_SPEED_2
+ ID_CPU_SPEED_3>;
+ };
+
+ power-loss {
+ type = "menu";
+ id = <ID_POWER_LOSS>;
+
+ title = "AC Power";
+ item-label = "Always Off", "Always On",
+ "Memory";
+
+ item-id = <ID_AC_OFF ID_AC_ON ID_AC_MEMORY>;
+ };
+ };
+ };
+
+ strings {
+ title {
+ id = <ID_SCENE1_TITLE>;
+ value = "Test Configuration";
+ value-es = "configuración de prueba";
+ };
+ };
+};
diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c
index 9068df79c4f..cddf1a46d49 100644
--- a/test/cmd/bdinfo.c
+++ b/test/cmd/bdinfo.c
@@ -27,19 +27,25 @@ DECLARE_GLOBAL_DATA_PTR;
/* Declare a new bdinfo test */
#define BDINFO_TEST(_name, _flags) UNIT_TEST(_name, _flags, bdinfo_test)
-static void bdinfo_test_num_l(struct unit_test_state *uts,
- const char *name, ulong value)
+static int test_num_l(struct unit_test_state *uts, const char *name,
+ ulong value)
{
- ut_assert_nextline("%-12s= 0x%0*lx", name, 2 * (int)sizeof(value), value);
+ ut_assert_nextline("%-12s= 0x%0*lx", name, 2 * (int)sizeof(value),
+ value);
+
+ return 0;
}
-static void bdinfo_test_num_ll(struct unit_test_state *uts,
- const char *name, unsigned long long value)
+static int test_num_ll(struct unit_test_state *uts, const char *name,
+ unsigned long long value)
{
- ut_assert_nextline("%-12s= 0x%.*llx", name, 2 * (int)sizeof(ulong), value);
+ ut_assert_nextline("%-12s= 0x%.*llx", name, 2 * (int)sizeof(ulong),
+ value);
+
+ return 0;
}
-static void test_eth(struct unit_test_state *uts)
+static int test_eth(struct unit_test_state *uts)
{
const int idx = eth_get_dev_index();
uchar enetaddr[6];
@@ -59,9 +65,11 @@ static void test_eth(struct unit_test_state *uts)
else
ut_assert_nextline("%-12s= %pM", name, enetaddr);
ut_assert_nextline("IP addr = %s", env_get("ipaddr"));
+
+ return 0;
}
-static void test_video_info(struct unit_test_state *uts)
+static int test_video_info(struct unit_test_state *uts)
{
const struct udevice *dev;
struct uclass *uc;
@@ -73,22 +81,25 @@ static void test_video_info(struct unit_test_state *uts)
struct video_priv *upriv = dev_get_uclass_priv(dev);
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
- bdinfo_test_num_ll(uts, "FB base", (ulong)upriv->fb);
+ ut_assertok(test_num_ll(uts, "FB base",
+ (ulong)upriv->fb));
if (upriv->copy_fb) {
- bdinfo_test_num_ll(uts, "FB copy",
- (ulong)upriv->copy_fb);
- bdinfo_test_num_l(uts, " copy size",
- plat->copy_size);
+ ut_assertok(test_num_ll(uts, "FB copy",
+ (ulong)upriv->copy_fb));
+ ut_assertok(test_num_l(uts, " copy size",
+ plat->copy_size));
}
ut_assert_nextline("%-12s= %dx%dx%d", "FB size",
upriv->xsize, upriv->ysize,
1 << upriv->bpix);
}
}
+
+ return 0;
}
-static void lmb_test_dump_region(struct unit_test_state *uts,
- struct lmb_region *rgn, char *name)
+static int lmb_test_dump_region(struct unit_test_state *uts,
+ struct lmb_region *rgn, char *name)
{
unsigned long long base, size, end;
enum lmb_flags flags;
@@ -105,13 +116,17 @@ static void lmb_test_dump_region(struct unit_test_state *uts,
ut_assert_nextline(" %s[%d]\t[0x%llx-0x%llx], 0x%08llx bytes flags: %x",
name, i, base, end, size, flags);
}
+
+ return 0;
}
-static void lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb)
+static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb)
{
ut_assert_nextline("lmb_dump_all:");
lmb_test_dump_region(uts, &lmb->memory, "memory");
lmb_test_dump_region(uts, &lmb->reserved, "reserved");
+
+ return 0;
}
static int bdinfo_test_move(struct unit_test_state *uts)
@@ -123,44 +138,48 @@ static int bdinfo_test_move(struct unit_test_state *uts)
ut_assertok(console_record_reset_enable());
ut_assertok(run_commandf("bdinfo"));
- bdinfo_test_num_l(uts, "boot_params", 0);
+ ut_assertok(test_num_l(uts, "boot_params", 0));
for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
if (bd->bi_dram[i].size) {
- bdinfo_test_num_l(uts, "DRAM bank", i);
- bdinfo_test_num_ll(uts, "-> start", bd->bi_dram[i].start);
- bdinfo_test_num_ll(uts, "-> size", bd->bi_dram[i].size);
+ ut_assertok(test_num_l(uts, "DRAM bank", i));
+ ut_assertok(test_num_ll(uts, "-> start",
+ bd->bi_dram[i].start));
+ ut_assertok(test_num_ll(uts, "-> size",
+ bd->bi_dram[i].size));
}
}
/* CONFIG_SYS_HAS_SRAM testing not supported */
- bdinfo_test_num_l(uts, "flashstart", 0);
- bdinfo_test_num_l(uts, "flashsize", 0);
- bdinfo_test_num_l(uts, "flashoffset", 0);
+ ut_assertok(test_num_l(uts, "flashstart", 0));
+ ut_assertok(test_num_l(uts, "flashsize", 0));
+ ut_assertok(test_num_l(uts, "flashoffset", 0));
ut_assert_nextline("baudrate = %lu bps",
env_get_ulong("baudrate", 10, 1234));
- bdinfo_test_num_l(uts, "relocaddr", gd->relocaddr);
- bdinfo_test_num_l(uts, "reloc off", gd->reloc_off);
+ ut_assertok(test_num_l(uts, "relocaddr", gd->relocaddr));
+ ut_assertok(test_num_l(uts, "reloc off", gd->reloc_off));
ut_assert_nextline("%-12s= %u-bit", "Build", (uint)sizeof(void *) * 8);
if (IS_ENABLED(CONFIG_CMD_NET))
- test_eth(uts);
+ ut_assertok(test_eth(uts));
/*
* Make sure environment variable "fdtcontroladdr" address
* matches mapped control DT address.
*/
ut_assert(map_to_sysmem(gd->fdt_blob) == env_get_hex("fdtcontroladdr", 0x1234));
- bdinfo_test_num_l(uts, "fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob));
- bdinfo_test_num_l(uts, "new_fdt", (ulong)map_to_sysmem(gd->new_fdt));
- bdinfo_test_num_l(uts, "fdt_size", (ulong)gd->fdt_size);
+ ut_assertok(test_num_l(uts, "fdt_blob",
+ (ulong)map_to_sysmem(gd->fdt_blob)));
+ ut_assertok(test_num_l(uts, "new_fdt",
+ (ulong)map_to_sysmem(gd->new_fdt)));
+ ut_assertok(test_num_l(uts, "fdt_size", (ulong)gd->fdt_size));
if (IS_ENABLED(CONFIG_VIDEO))
test_video_info(uts);
/* The gd->multi_dtb_fit may not be available, hence, #if below. */
#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
- bdinfo_test_num_l(uts, "multi_dtb_fit", (ulong)gd->multi_dtb_fit);
+ ut_assertok(test_num_l(uts, "multi_dtb_fit", (ulong)gd->multi_dtb_fit));
#endif
if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 473a8cef578..6fbebc7da08 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -1240,3 +1240,48 @@ static int dm_test_ofnode_copy_props_ot(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_copy_props_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT);
+
+/* check that the livetree is aligned to a structure boundary */
+static int dm_test_livetree_align(struct unit_test_state *uts)
+{
+ const int align = __alignof__(struct unit_test_state);
+ struct device_node *node;
+ u32 *sentinel;
+ ulong start;
+
+ start = (ulong)gd_of_root();
+ ut_asserteq(start, ALIGN(start, align));
+
+ node = gd_of_root();
+ sentinel = (void *)node - sizeof(u32);
+
+ /*
+ * The sentinel should be overwritten with the root node. If it isn't,
+ * then the root node is not at the very start of the livetree memory
+ * area, and free(root) will fail to free the memory used by the
+ * livetree.
+ */
+ ut_assert(*sentinel != BAD_OF_ROOT);
+
+ return 0;
+}
+DM_TEST(dm_test_livetree_align, UT_TESTF_LIVE_TREE);
+
+/* check that it is possible to load an arbitrary livetree */
+static int dm_test_livetree_ensure(struct unit_test_state *uts)
+{
+ oftree tree;
+ ofnode node;
+
+ /* read from other.dtb */
+ ut_assertok(test_load_other_fdt(uts));
+ tree = oftree_from_fdt(uts->other_fdt);
+ ut_assert(oftree_valid(tree));
+ node = oftree_path(tree, "/node/subnode");
+ ut_assert(ofnode_valid(node));
+ ut_asserteq_str("sandbox-other2",
+ ofnode_read_string(node, "compatible"));
+
+ return 0;
+}
+DM_TEST(dm_test_livetree_ensure, 0);
diff --git a/test/dm/video.c b/test/dm/video.c
index 30778157d94..0534ee93a3d 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -556,7 +556,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts)
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
vidconsole_put_string(con, test_string);
- ut_asserteq(12237, compress_frame_buffer(uts, dev));
+ ut_asserteq(12174, compress_frame_buffer(uts, dev));
return 0;
}
@@ -577,7 +577,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
vidconsole_put_string(con, test_string);
- ut_asserteq(35030, compress_frame_buffer(uts, dev));
+ ut_asserteq(34287, compress_frame_buffer(uts, dev));
return 0;
}
@@ -598,7 +598,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
vidconsole_put_string(con, test_string);
- ut_asserteq(29018, compress_frame_buffer(uts, dev));
+ ut_asserteq(29471, compress_frame_buffer(uts, dev));
return 0;
}
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index 0b45863b438..aa1d477cd56 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -282,6 +282,15 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
copy_prepared_image(cons, mmc_dev, fname)
+def setup_cedit_file(cons):
+ infname = os.path.join(cons.config.source_dir,
+ 'test/boot/files/expo_layout.dts')
+ expo_tool = os.path.join(cons.config.source_dir, 'tools/expo.py')
+ outfname = 'cedit.dtb'
+ u_boot_utils.run_and_log(
+ cons, f'{expo_tool} -e {infname} -l {infname} -o {outfname}')
+
+
@pytest.mark.buildconfigspec('ut_dm')
def test_ut_dm_init(u_boot_console):
"""Initialize data for ut dm tests."""
@@ -319,6 +328,7 @@ def test_ut_dm_init_bootstd(u_boot_console):
setup_bootflow_image(u_boot_console)
setup_bootmenu_image(u_boot_console)
+ setup_cedit_file(u_boot_console)
# Restart so that the new mmc1.img is picked up
u_boot_console.restart_uboot()