mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-09-23 23:01:28 +02:00
expo: Update tests to include textline
Provide test coverage for the new expo object type, including building and reading/writing settings. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
7318e0eff2
commit
c2bd2d33d9
@ -51,6 +51,14 @@
|
|||||||
|
|
||||||
item-id = <ID_AC_OFF ID_AC_ON ID_AC_MEMORY>;
|
item-id = <ID_AC_OFF ID_AC_ON ID_AC_MEMORY>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
machine-name {
|
||||||
|
id = <ID_MACHINE_NAME>;
|
||||||
|
type = "textline";
|
||||||
|
max-chars = <20>;
|
||||||
|
title = "Machine name";
|
||||||
|
edit-id = <ID_MACHINE_NAME_EDIT>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
#define ID_AC_ON 11
|
#define ID_AC_ON 11
|
||||||
#define ID_AC_MEMORY 12
|
#define ID_AC_MEMORY 12
|
||||||
|
|
||||||
#define ID_DYNAMIC_START 13
|
#define ID_MACHINE_NAME 13
|
||||||
|
#define ID_MACHINE_NAME_EDIT 14
|
||||||
|
|
||||||
|
#define ID_DYNAMIC_START 15
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,6 +58,7 @@ BOOTSTD_TEST(cedit_base, 0);
|
|||||||
/* Check the cedit write_fdt and read_fdt commands */
|
/* Check the cedit write_fdt and read_fdt commands */
|
||||||
static int cedit_fdt(struct unit_test_state *uts)
|
static int cedit_fdt(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
struct scene_obj_textline *tline;
|
||||||
struct video_priv *vid_priv;
|
struct video_priv *vid_priv;
|
||||||
extern struct expo *cur_exp;
|
extern struct expo *cur_exp;
|
||||||
struct scene_obj_menu *menu;
|
struct scene_obj_menu *menu;
|
||||||
@ -66,6 +67,7 @@ static int cedit_fdt(struct unit_test_state *uts)
|
|||||||
struct scene *scn;
|
struct scene *scn;
|
||||||
oftree tree;
|
oftree tree;
|
||||||
ofnode node;
|
ofnode node;
|
||||||
|
char *str;
|
||||||
void *fdt;
|
void *fdt;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -79,6 +81,12 @@ static int cedit_fdt(struct unit_test_state *uts)
|
|||||||
ut_assertnonnull(menu);
|
ut_assertnonnull(menu);
|
||||||
menu->cur_item_id = ID_CPU_SPEED_2;
|
menu->cur_item_id = ID_CPU_SPEED_2;
|
||||||
|
|
||||||
|
/* get a textline to fiddle with too */
|
||||||
|
tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_TEXTLINE);
|
||||||
|
ut_assertnonnull(tline);
|
||||||
|
str = abuf_data(&tline->buf);
|
||||||
|
strcpy(str, "my-machine");
|
||||||
|
|
||||||
ut_assertok(run_command("cedit write_fdt hostfs - settings.dtb", 0));
|
ut_assertok(run_command("cedit write_fdt hostfs - settings.dtb", 0));
|
||||||
ut_assertok(run_commandf("load hostfs - %lx settings.dtb", addr));
|
ut_assertok(run_commandf("load hostfs - %lx settings.dtb", addr));
|
||||||
ut_assert_nextlinen("1024 bytes read");
|
ut_assert_nextlinen("1024 bytes read");
|
||||||
@ -86,26 +94,29 @@ static int cedit_fdt(struct unit_test_state *uts)
|
|||||||
fdt = map_sysmem(addr, 1024);
|
fdt = map_sysmem(addr, 1024);
|
||||||
tree = oftree_from_fdt(fdt);
|
tree = oftree_from_fdt(fdt);
|
||||||
node = ofnode_find_subnode(oftree_root(tree), CEDIT_NODE_NAME);
|
node = ofnode_find_subnode(oftree_root(tree), CEDIT_NODE_NAME);
|
||||||
|
ut_assert(ofnode_valid(node));
|
||||||
|
|
||||||
ut_asserteq(ID_CPU_SPEED_2,
|
ut_asserteq(ID_CPU_SPEED_2,
|
||||||
ofnode_read_u32_default(node, "cpu-speed", 0));
|
ofnode_read_u32_default(node, "cpu-speed", 0));
|
||||||
ut_asserteq_str("2.5 GHz", ofnode_read_string(node, "cpu-speed-str"));
|
ut_asserteq_str("2.5 GHz", ofnode_read_string(node, "cpu-speed-str"));
|
||||||
ut_assert(ofnode_valid(node));
|
ut_asserteq_str("my-machine", ofnode_read_string(node, "machine-name"));
|
||||||
|
|
||||||
/* There should only be 4 properties */
|
/* There should only be 5 properties */
|
||||||
for (i = 0, ofnode_first_property(node, &prop); ofprop_valid(&prop);
|
for (i = 0, ofnode_first_property(node, &prop); ofprop_valid(&prop);
|
||||||
i++, ofnode_next_property(&prop))
|
i++, ofnode_next_property(&prop))
|
||||||
;
|
;
|
||||||
ut_asserteq(4, i);
|
ut_asserteq(5, i);
|
||||||
|
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
/* reset the expo */
|
/* reset the expo */
|
||||||
menu->cur_item_id = ID_CPU_SPEED_1;
|
menu->cur_item_id = ID_CPU_SPEED_1;
|
||||||
|
*str = '\0';
|
||||||
|
|
||||||
/* load in the settings and make sure they update */
|
/* load in the settings and make sure they update */
|
||||||
ut_assertok(run_command("cedit read_fdt hostfs - settings.dtb", 0));
|
ut_assertok(run_command("cedit read_fdt hostfs - settings.dtb", 0));
|
||||||
ut_asserteq(ID_CPU_SPEED_2, menu->cur_item_id);
|
ut_asserteq(ID_CPU_SPEED_2, menu->cur_item_id);
|
||||||
|
ut_asserteq_str("my-machine", ofnode_read_string(node, "machine-name"));
|
||||||
|
|
||||||
ut_assertnonnull(menu);
|
ut_assertnonnull(menu);
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
@ -117,10 +128,12 @@ BOOTSTD_TEST(cedit_fdt, 0);
|
|||||||
/* Check the cedit write_env and read_env commands */
|
/* Check the cedit write_env and read_env commands */
|
||||||
static int cedit_env(struct unit_test_state *uts)
|
static int cedit_env(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
|
struct scene_obj_textline *tline;
|
||||||
struct video_priv *vid_priv;
|
struct video_priv *vid_priv;
|
||||||
extern struct expo *cur_exp;
|
extern struct expo *cur_exp;
|
||||||
struct scene_obj_menu *menu;
|
struct scene_obj_menu *menu;
|
||||||
struct scene *scn;
|
struct scene *scn;
|
||||||
|
char *str;
|
||||||
|
|
||||||
console_record_reset_enable();
|
console_record_reset_enable();
|
||||||
ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
|
ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
|
||||||
@ -132,25 +145,36 @@ static int cedit_env(struct unit_test_state *uts)
|
|||||||
ut_assertnonnull(menu);
|
ut_assertnonnull(menu);
|
||||||
menu->cur_item_id = ID_CPU_SPEED_2;
|
menu->cur_item_id = ID_CPU_SPEED_2;
|
||||||
|
|
||||||
|
/* get a textline to fiddle with too */
|
||||||
|
tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_TEXTLINE);
|
||||||
|
ut_assertnonnull(tline);
|
||||||
|
str = abuf_data(&tline->buf);
|
||||||
|
strcpy(str, "my-machine");
|
||||||
|
|
||||||
ut_assertok(run_command("cedit write_env -v", 0));
|
ut_assertok(run_command("cedit write_env -v", 0));
|
||||||
ut_assert_nextlinen("c.cpu-speed=7");
|
ut_assert_nextlinen("c.cpu-speed=7");
|
||||||
ut_assert_nextlinen("c.cpu-speed-str=2.5 GHz");
|
ut_assert_nextlinen("c.cpu-speed-str=2.5 GHz");
|
||||||
ut_assert_nextlinen("c.power-loss=10");
|
ut_assert_nextlinen("c.power-loss=10");
|
||||||
ut_assert_nextlinen("c.power-loss-str=Always Off");
|
ut_assert_nextlinen("c.power-loss-str=Always Off");
|
||||||
|
ut_assert_nextlinen("c.machine-name=my-machine");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
ut_asserteq(7, env_get_ulong("c.cpu-speed", 10, 0));
|
ut_asserteq(7, env_get_ulong("c.cpu-speed", 10, 0));
|
||||||
ut_asserteq_str("2.5 GHz", env_get("c.cpu-speed-str"));
|
ut_asserteq_str("2.5 GHz", env_get("c.cpu-speed-str"));
|
||||||
|
ut_asserteq_str("my-machine", env_get("c.machine-name"));
|
||||||
|
|
||||||
/* reset the expo */
|
/* reset the expo */
|
||||||
menu->cur_item_id = ID_CPU_SPEED_1;
|
menu->cur_item_id = ID_CPU_SPEED_1;
|
||||||
|
*str = '\0';
|
||||||
|
|
||||||
ut_assertok(run_command("cedit read_env -v", 0));
|
ut_assertok(run_command("cedit read_env -v", 0));
|
||||||
ut_assert_nextlinen("c.cpu-speed=7");
|
ut_assert_nextlinen("c.cpu-speed=7");
|
||||||
ut_assert_nextlinen("c.power-loss=10");
|
ut_assert_nextlinen("c.power-loss=10");
|
||||||
|
ut_assert_nextlinen("c.machine-name=my-machine");
|
||||||
ut_assert_console_end();
|
ut_assert_console_end();
|
||||||
|
|
||||||
ut_asserteq(ID_CPU_SPEED_2, menu->cur_item_id);
|
ut_asserteq(ID_CPU_SPEED_2, menu->cur_item_id);
|
||||||
|
ut_asserteq_str("my-machine", env_get("c.machine-name"));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -654,7 +654,7 @@ static int expo_test_build(struct unit_test_state *uts)
|
|||||||
|
|
||||||
ut_asserteq_str("name", exp->name);
|
ut_asserteq_str("name", exp->name);
|
||||||
ut_asserteq(0, exp->scene_id);
|
ut_asserteq(0, exp->scene_id);
|
||||||
ut_asserteq(ID_DYNAMIC_START + 20, exp->next_id);
|
ut_asserteq(ID_DYNAMIC_START + 24, exp->next_id);
|
||||||
ut_asserteq(false, exp->popup);
|
ut_asserteq(false, exp->popup);
|
||||||
|
|
||||||
/* check the scene */
|
/* check the scene */
|
||||||
|
@ -21,5 +21,8 @@ enum {
|
|||||||
ID_AC_ON,
|
ID_AC_ON,
|
||||||
ID_AC_MEMORY,
|
ID_AC_MEMORY,
|
||||||
|
|
||||||
|
ID_MACHINE_NAME,
|
||||||
|
ID_MACHINE_NAME_EDIT,
|
||||||
|
|
||||||
ID_DYNAMIC_START,
|
ID_DYNAMIC_START,
|
||||||
};
|
};
|
||||||
|
@ -55,6 +55,14 @@
|
|||||||
start-bit = <0x422>;
|
start-bit = <0x422>;
|
||||||
bit-length = <2>;
|
bit-length = <2>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
machine-name {
|
||||||
|
id = <ID_MACHINE_NAME>;
|
||||||
|
type = "textline";
|
||||||
|
max-chars = <20>;
|
||||||
|
title = "Machine name";
|
||||||
|
edit-id = <ID_MACHINE_NAME_EDIT>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user