mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
expo: Add tests for the configuration editor
Add some simple tests and a helpful script to make the configuration editor easier to set up. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <dm.h>
|
||||
#include <expo.h>
|
||||
#include <menu.h>
|
||||
@@ -668,3 +669,46 @@ static int expo_test_build(struct unit_test_state *uts)
|
||||
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);
|
||||
|
||||
84
test/boot/files/expo_layout.dts
Normal file
84
test/boot/files/expo_layout.dts
Normal file
@@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user