expo: Move cedit test into its own file and tidy

Move this test out so it can have its own file. Rename the test to use
a cedit_ prefix.

This allows us to drop the check for CONFIG_CMD_CEDIT in the test.

Also we don't need driver model objects for this test, so drop them.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2023-08-14 16:40:26 -06:00 committed by Tom Rini
parent 040b04685e
commit f80ebb2fe1
3 changed files with 54 additions and 43 deletions

View File

@ -6,6 +6,7 @@ obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o
obj-$(CONFIG_FIT) += image.o
obj-$(CONFIG_EXPO) += expo.o
obj-$(CONFIG_CEDIT) += cedit.o
ifdef CONFIG_OF_LIVE
obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o

53
test/boot/cedit.c Normal file
View File

@ -0,0 +1,53 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2023 Google LLC
* Written by Simon Glass <sjg@chromium.org>
*/
#include <common.h>
#include <cedit.h>
#include <expo.h>
#include <test/ut.h>
#include "bootstd_common.h"
#include <test/cedit-test.h>
#include "../../boot/scene_internal.h"
/* Check the cedit command */
static int cedit_base(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;
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(cedit_base, 0);

View File

@ -714,46 +714,3 @@ 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);