summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/boot/bootdev.c1
-rw-r--r--test/boot/bootflow.c10
-rw-r--r--test/boot/bootm.c1
-rw-r--r--test/boot/bootmeth.c1
-rw-r--r--test/boot/cedit.c217
-rw-r--r--test/boot/expo.c214
-rw-r--r--test/boot/measurement.c1
-rw-r--r--test/boot/upl.c1
-rw-r--r--test/cmd/fdt.c1
-rw-r--r--test/cmd/hash.c1
-rw-r--r--test/cmd/mem_copy.c1
-rw-r--r--test/cmd/mem_search.c1
-rw-r--r--test/cmd/setexpr.c1
-rw-r--r--test/common/test_autoboot.c1
-rw-r--r--test/dm/blkmap.c1
-rw-r--r--test/dm/button.c1
-rw-r--r--test/dm/clk_ccf.c30
-rw-r--r--test/dm/dsa.c1
-rw-r--r--test/dm/fastboot.c1
-rw-r--r--test/dm/part.c1
-rw-r--r--test/dm/tpm.c77
-rw-r--r--test/env/fdt.c1
-rw-r--r--test/hush/dollar.c1
-rw-r--r--test/hush/if.c1
-rw-r--r--test/hush/loop.c1
-rw-r--r--test/lib/Makefile1
-rw-r--r--test/lib/abuf.c105
-rw-r--r--test/lib/efi_device_path.c1
-rw-r--r--test/lib/slre.c58
-rw-r--r--test/lib/string.c37
-rw-r--r--test/py/conftest.py14
-rw-r--r--test/py/tests/test_000_version.py10
-rw-r--r--test/py/tests/test_bind.py12
-rw-r--r--test/py/tests/test_bootmenu.py4
-rw-r--r--test/py/tests/test_bootstage.py35
-rw-r--r--test/py/tests/test_button.py2
-rw-r--r--test/py/tests/test_efi_fit.py156
-rw-r--r--test/py/tests/test_efi_loader.py89
-rw-r--r--test/py/tests/test_fpga.py4
-rw-r--r--test/py/tests/test_net.py154
-rw-r--r--test/py/tests/test_net_boot.py177
-rw-r--r--test/py/tests/test_tpm2.py86
42 files changed, 1128 insertions, 385 deletions
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index 9af94786870..a5f3d4462a9 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -10,6 +10,7 @@
#include <dm.h>
#include <bootdev.h>
#include <bootflow.h>
+#include <env.h>
#include <mapmem.h>
#include <os.h>
#include <test/ut.h>
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index b261bd5f620..8de5a310add 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -14,6 +14,7 @@
#include <dm.h>
#include <efi.h>
#include <efi_loader.h>
+#include <env.h>
#include <expo.h>
#include <mapmem.h>
#ifdef CONFIG_SANDBOX
@@ -857,7 +858,7 @@ static int check_font(struct unit_test_state *uts, struct scene *scn, uint id,
txt = scene_obj_find(scn, id, SCENEOBJT_TEXT);
ut_assertnonnull(txt);
- ut_asserteq(font_size, txt->font_size);
+ ut_asserteq(font_size, txt->gen.font_size);
return 0;
}
@@ -877,9 +878,10 @@ static int bootflow_menu_theme(struct unit_test_state *uts)
ut_assertok(scan_mmc4_bootdev(uts));
ut_assertok(bootflow_menu_new(&exp));
+ ut_assertok(bootflow_menu_add_all(exp));
node = ofnode_path("/bootstd/theme");
ut_assert(ofnode_valid(node));
- ut_assertok(bootflow_menu_apply_theme(exp, node));
+ ut_assertok(expo_apply_theme(exp, node));
scn = expo_lookup_scene_id(exp, MAIN);
ut_assertnonnull(scn);
@@ -890,8 +892,8 @@ static int bootflow_menu_theme(struct unit_test_state *uts)
*
* Check both menu items, since there are two bootflows
*/
- ut_assertok(check_font(uts, scn, OBJ_PROMPT, font_size));
- ut_assertok(check_font(uts, scn, OBJ_POINTER, font_size));
+ for (i = OBJ_PROMPT1A; i <= OBJ_AUTOBOOT; i++)
+ ut_assertok(check_font(uts, scn, i, font_size));
for (i = 0; i < 2; i++) {
ut_assertok(check_font(uts, scn, ITEM_DESC + i, font_size));
ut_assertok(check_font(uts, scn, ITEM_KEY + i, font_size));
diff --git a/test/boot/bootm.c b/test/boot/bootm.c
index 1d1efe71ad5..ed60094f3c1 100644
--- a/test/boot/bootm.c
+++ b/test/boot/bootm.c
@@ -6,6 +6,7 @@
*/
#include <bootm.h>
+#include <env.h>
#include <asm/global_data.h>
#include <test/test.h>
#include <test/ut.h>
diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c
index 577f259fb37..2ef3569ad83 100644
--- a/test/boot/bootmeth.c
+++ b/test/boot/bootmeth.c
@@ -9,6 +9,7 @@
#include <bootmeth.h>
#include <bootstd.h>
#include <dm.h>
+#include <env.h>
#include <test/ut.h>
#include "bootstd_common.h"
diff --git a/test/boot/cedit.c b/test/boot/cedit.c
index 4d1b99bc2ea..dbf781902fb 100644
--- a/test/boot/cedit.c
+++ b/test/boot/cedit.c
@@ -5,11 +5,13 @@
*/
#include <cedit.h>
+#include <dm.h>
#include <env.h>
#include <expo.h>
#include <mapmem.h>
#include <dm/ofnode.h>
#include <test/ut.h>
+#include <test/video.h>
#include "bootstd_common.h"
#include <test/cedit-test.h>
#include "../../boot/scene_internal.h"
@@ -46,7 +48,7 @@ static int cedit_base(struct unit_test_state *uts)
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_str("AC Power", expo_get_str(exp, txt->gen.str_id));
ut_asserteq(ID_AC_ON, menu->cur_item_id);
@@ -61,6 +63,7 @@ static int cedit_fdt(struct unit_test_state *uts)
struct video_priv *vid_priv;
extern struct expo *cur_exp;
struct scene_obj_menu *menu;
+ struct udevice *dev;
ulong addr = 0x1000;
struct ofprop prop;
struct scene *scn;
@@ -70,9 +73,12 @@ static int cedit_fdt(struct unit_test_state *uts)
void *fdt;
int i;
+ ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
+ vid_priv = dev_get_uclass_priv(dev);
+
ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
- ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn));
+ ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn));
/* get a menu to fiddle with */
menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU);
@@ -132,12 +138,16 @@ static int cedit_env(struct unit_test_state *uts)
struct video_priv *vid_priv;
extern struct expo *cur_exp;
struct scene_obj_menu *menu;
+ struct udevice *dev;
struct scene *scn;
char *str;
ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
- ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn));
+ ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
+ vid_priv = dev_get_uclass_priv(dev);
+
+ ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn));
/* get a menu to fiddle with */
menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU);
@@ -187,11 +197,14 @@ static int cedit_cmos(struct unit_test_state *uts)
struct scene_obj_menu *menu, *menu2;
struct video_priv *vid_priv;
extern struct expo *cur_exp;
+ struct udevice *dev;
struct scene *scn;
ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
- ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn));
+ ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
+ vid_priv = dev_get_uclass_priv(dev);
+ ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn));
/* get the menus to fiddle with */
menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU);
@@ -220,3 +233,199 @@ static int cedit_cmos(struct unit_test_state *uts)
return 0;
}
BOOTSTD_TEST(cedit_cmos, UTF_CONSOLE);
+
+/* Check the cedit displays correctly */
+static int cedit_render(struct unit_test_state *uts)
+{
+ struct scene_obj_menu *menu;
+ struct video_priv *vid_priv;
+ extern struct expo *cur_exp;
+ struct expo_action evt;
+ struct expo_action act;
+ struct udevice *dev, *con;
+ struct stdio_dev *sdev;
+ struct scene *scn;
+ struct expo *exp;
+ int i;
+
+ ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
+
+ exp = cur_exp;
+ sdev = stdio_get_by_name("vidconsole");
+ ut_assertnonnull(sdev);
+ con = sdev->priv;
+
+ dev = dev_get_parent(con);
+ vid_priv = dev_get_uclass_priv(dev);
+ ut_asserteq(ID_SCENE1, cedit_prepare(exp, dev, &scn));
+
+ menu = scene_obj_find(scn, ID_POWER_LOSS, SCENEOBJT_MENU);
+ ut_assertnonnull(menu);
+ ut_asserteq(ID_AC_OFF, menu->cur_item_id);
+
+ ut_assertok(expo_render(exp));
+ ut_asserteq(4929, video_compress_fb(uts, dev, false));
+ ut_assertok(video_check_copy_fb(uts, dev));
+
+ /* move to the second menu */
+ act.type = EXPOACT_POINT_OBJ;
+ act.select.id = ID_POWER_LOSS;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(4986, video_compress_fb(uts, dev, false));
+
+ /* open the menu */
+ act.type = EXPOACT_OPEN;
+ act.select.id = ID_POWER_LOSS;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5393, video_compress_fb(uts, dev, false));
+
+ /* close the menu */
+ act.type = EXPOACT_CLOSE;
+ act.select.id = ID_POWER_LOSS;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(4986, video_compress_fb(uts, dev, false));
+
+ /* open the menu again to check it looks the same */
+ act.type = EXPOACT_OPEN;
+ act.select.id = ID_POWER_LOSS;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5393, video_compress_fb(uts, dev, false));
+
+ /* close the menu */
+ act.type = EXPOACT_CLOSE;
+ act.select.id = ID_POWER_LOSS;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(4986, video_compress_fb(uts, dev, false));
+
+ act.type = EXPOACT_OPEN;
+ act.select.id = ID_POWER_LOSS;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5393, video_compress_fb(uts, dev, false));
+
+ act.type = EXPOACT_POINT_ITEM;
+ act.select.id = ID_AC_ON;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5365, video_compress_fb(uts, dev, false));
+
+ /* select it */
+ act.type = EXPOACT_SELECT;
+ act.select.id = ID_AC_ON;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(4980, video_compress_fb(uts, dev, false));
+
+ ut_asserteq(ID_AC_ON, menu->cur_item_id);
+
+ /* move to the line-edit field */
+ act.type = EXPOACT_POINT_OBJ;
+ act.select.id = ID_MACHINE_NAME;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(4862, video_compress_fb(uts, dev, false));
+
+ /* open it */
+ act.type = EXPOACT_OPEN;
+ act.select.id = ID_MACHINE_NAME;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(4851, video_compress_fb(uts, dev, false));
+
+ /*
+ * Send some keypresses. Note that the console must be enabled so that
+ * the characters actually reach the putc_xy() in console_truetype,
+ * since in scene_textline_send_key(), the lineedit restores the
+ * vidconsole state, outputs the character and then saves the state
+ * again. If the character is never output, then the state won't be
+ * updated and the lineedit will be inconsistent.
+ */
+ ut_unsilence_console(uts);
+ for (i = 'a'; i < 'd'; i++)
+ ut_assertok(scene_send_key(scn, i, &evt));
+ ut_silence_console(uts);
+ ut_assertok(cedit_arange(exp, vid_priv, scn->id));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(4996, video_compress_fb(uts, dev, false));
+
+ expo_destroy(exp);
+ cur_exp = NULL;
+
+ return 0;
+}
+BOOTSTD_TEST(cedit_render, UTF_DM | UTF_SCAN_FDT);
+
+/* Check the cedit displays lineedits correctly */
+static int cedit_render_lineedit(struct unit_test_state *uts)
+{
+ struct scene_obj_textline *tline;
+ struct video_priv *vid_priv;
+ extern struct expo *cur_exp;
+ struct expo_action evt;
+ struct expo_action act;
+ struct udevice *dev, *con;
+ struct stdio_dev *sdev;
+ struct scene *scn;
+ struct expo *exp;
+ char *str;
+ int i;
+
+ ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
+
+ exp = cur_exp;
+ sdev = stdio_get_by_name("vidconsole");
+ ut_assertnonnull(sdev);
+ con = sdev->priv;
+
+ dev = dev_get_parent(con);
+ vid_priv = dev_get_uclass_priv(dev);
+ ut_asserteq(ID_SCENE1, cedit_prepare(exp, dev, &scn));
+
+ /* set up an initial value for the textline */
+ tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_TEXTLINE);
+ ut_assertnonnull(tline);
+ str = abuf_data(&tline->buf);
+ strcpy(str, "my-machine");
+ ut_asserteq(20, tline->pos);
+
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5336, video_compress_fb(uts, dev, false));
+ ut_assertok(video_check_copy_fb(uts, dev));
+
+ /* move to the line-edit field */
+ act.type = EXPOACT_POINT_OBJ;
+ act.select.id = ID_MACHINE_NAME;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5363, video_compress_fb(uts, dev, false));
+
+ /* open it */
+ act.type = EXPOACT_OPEN;
+ act.select.id = ID_MACHINE_NAME;
+ ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
+ // ut_asserteq(0, tline->pos);
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5283, video_compress_fb(uts, dev, false));
+
+ /* delete some characters */
+ ut_unsilence_console(uts);
+ for (i = 0; i < 3; i++)
+ ut_assertok(scene_send_key(scn, '\b', &evt));
+ ut_silence_console(uts);
+ ut_asserteq_str("my-mach", str);
+
+ ut_assertok(cedit_arange(exp, vid_priv, scn->id));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5170, video_compress_fb(uts, dev, false));
+
+ expo_destroy(exp);
+ cur_exp = NULL;
+
+ return 0;
+}
+BOOTSTD_TEST(cedit_render_lineedit, UTF_DM | UTF_SCAN_FDT);
diff --git a/test/boot/expo.c b/test/boot/expo.c
index 1d283a2ac95..ddfb739f9cf 100644
--- a/test/boot/expo.c
+++ b/test/boot/expo.c
@@ -11,6 +11,7 @@
#include <video.h>
#include <linux/input.h>
#include <test/ut.h>
+#include <test/video.h>
#include "bootstd_common.h"
#include <test/cedit-test.h>
#include "../../boot/scene_internal.h"
@@ -24,14 +25,20 @@ enum {
OBJ_LOGO,
OBJ_TEXT,
OBJ_TEXT2,
+ OBJ_TEXT3,
OBJ_MENU,
OBJ_MENU_TITLE,
+ OBJ_BOX,
+ OBJ_BOX2,
+ OBJ_TEXTED,
/* strings */
STR_SCENE_TITLE,
STR_TEXT,
STR_TEXT2,
+ STR_TEXT3,
+ STR_TEXTED,
STR_MENU_TITLE,
STR_POINTER_TEXT,
@@ -270,8 +277,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.dim.x);
- ut_asserteq(456, img->obj.dim.y);
+ ut_asserteq(123, img->obj.bbox.x0);
+ ut_asserteq(456, img->obj.bbox.y0);
ut_asserteq(-ENOENT, scene_obj_set_pos(scn, OBJ_TEXT2, 0, 0));
@@ -280,8 +287,8 @@ static int expo_object_attr(struct unit_test_state *uts)
strcpy(name, "font2");
ut_assertok(scene_txt_set_font(scn, OBJ_TEXT, name, 42));
- ut_asserteq_ptr(name, txt->font_name);
- ut_asserteq(42, txt->font_size);
+ ut_asserteq_ptr(name, txt->gen.font_name);
+ ut_asserteq(42, txt->gen.font_size);
ut_asserteq(-ENOENT, scene_txt_set_font(scn, OBJ_TEXT2, name, 42));
@@ -296,7 +303,7 @@ static int expo_object_attr(struct unit_test_state *uts)
node = ofnode_path("/bootstd/theme");
ut_assert(ofnode_valid(node));
ut_assertok(expo_apply_theme(exp, node));
- ut_asserteq(30, txt->font_size);
+ ut_asserteq(30, txt->gen.font_size);
expo_destroy(exp);
@@ -360,8 +367,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.dim.x);
- ut_asserteq(400, menu->obj.dim.y);
+ ut_asserteq(50, menu->obj.bbox.x0);
+ ut_asserteq(400, menu->obj.bbox.y0);
id = scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
"Main Menu", &tit);
@@ -407,24 +414,24 @@ static int expo_object_menu(struct unit_test_state *uts)
ut_asserteq(id, menu->cur_item_id);
/* the title should be at the top */
- ut_asserteq(menu->obj.dim.x, tit->obj.dim.x);
- ut_asserteq(menu->obj.dim.y, tit->obj.dim.y);
+ ut_asserteq(menu->obj.bbox.x0, tit->obj.bbox.x0);
+ ut_asserteq(menu->obj.bbox.y0, tit->obj.bbox.y0);
/* the first item should be next */
- 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.bbox.x0, name1->obj.bbox.x0);
+ ut_asserteq(menu->obj.bbox.y0 + 32, name1->obj.bbox.y0);
- 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.bbox.x0 + 230, key1->obj.bbox.x0);
+ ut_asserteq(menu->obj.bbox.y0 + 32, key1->obj.bbox.y0);
- 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.bbox.x0 + 200, ptr->obj.bbox.x0);
+ ut_asserteq(menu->obj.bbox.y0 + 32, ptr->obj.bbox.y0);
- ut_asserteq(menu->obj.dim.x + 280, desc1->obj.dim.x);
- ut_asserteq(menu->obj.dim.y + 32, desc1->obj.dim.y);
+ ut_asserteq(menu->obj.bbox.x0 + 280, desc1->obj.bbox.x0);
+ ut_asserteq(menu->obj.bbox.y0 + 32, desc1->obj.bbox.y0);
- ut_asserteq(-4, prev1->obj.dim.x);
- ut_asserteq(menu->obj.dim.y + 32, prev1->obj.dim.y);
+ ut_asserteq(-4, prev1->obj.bbox.x0);
+ ut_asserteq(menu->obj.bbox.y0 + 32, prev1->obj.bbox.y0);
ut_asserteq(true, prev1->obj.flags & SCENEOF_HIDE);
/* check iterating through scene items */
@@ -457,6 +464,7 @@ static int expo_render_image(struct unit_test_state *uts)
{
struct scene_obj_menu *menu;
struct scene *scn, *scn2;
+ struct abuf orig, *text;
struct expo_action act;
struct scene_obj *obj;
struct udevice *dev;
@@ -487,6 +495,15 @@ static int expo_render_image(struct unit_test_state *uts)
60));
ut_assertok(scene_obj_set_pos(scn, OBJ_TEXT2, 200, 600));
+ /* this string is clipped as it extends beyond its bottom bound */
+ id = scene_txt_str(scn, "text", OBJ_TEXT3, STR_TEXT3,
+ "this is yet\nanother string, with word-wrap and it goes on for quite a while",
+ NULL);
+ ut_assert(id > 0);
+ ut_assertok(scene_txt_set_font(scn, OBJ_TEXT3, "nimbus_sans_l_regular",
+ 60));
+ ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXT3, 500, 200, 1000, 350));
+
id = scene_menu(scn, "main", OBJ_MENU, &menu);
ut_assert(id > 0);
@@ -534,6 +551,22 @@ static int expo_render_image(struct unit_test_state *uts)
ut_assertok(scene_obj_set_pos(scn, OBJ_MENU, 50, 400));
+ id = scene_box(scn, "box", OBJ_BOX, 3, NULL);
+ ut_assert(id > 0);
+ ut_assertok(scene_obj_set_bbox(scn, OBJ_BOX, 40, 390, 1000, 510));
+
+ id = scene_box(scn, "box2", OBJ_BOX2, 1, NULL);
+ ut_assert(id > 0);
+ ut_assertok(scene_obj_set_bbox(scn, OBJ_BOX, 500, 200, 1000, 350));
+
+ id = scene_texted(scn, "editor", OBJ_TEXTED, STR_TEXTED, NULL);
+ ut_assert(id > 0);
+ ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXTED, 100, 200, 400, 650));
+ ut_assertok(expo_edit_str(exp, STR_TEXTED, &orig, &text));
+
+ abuf_printf(text, "This\nis the initial contents of the text editor "
+ "but it is quite likely that more will be added later");
+
scn2 = expo_lookup_scene_id(exp, SCENE1);
ut_asserteq_ptr(scn, scn2);
scn2 = expo_lookup_scene_id(exp, SCENE2);
@@ -548,46 +581,98 @@ static int expo_render_image(struct unit_test_state *uts)
/* 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);
+ ut_asserteq(400, obj->bbox.x0);
+ ut_asserteq(100, obj->bbox.y0);
+ ut_asserteq(400 + 126, obj->bbox.x1);
+ ut_asserteq(100 + 40, obj->bbox.y1);
/* 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);
+ ut_asserteq(50, obj->bbox.x0);
+ ut_asserteq(20, obj->bbox.y0);
+ ut_asserteq(50 + 160, obj->bbox.x1);
+ ut_asserteq(20 + 160, obj->bbox.y1);
/* 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);
+ ut_asserteq(50, obj->bbox.x0);
+ ut_asserteq(436, obj->bbox.y0);
+ ut_asserteq(50 + 29, obj->bbox.x1);
+ ut_asserteq(436 + 18, obj->bbox.y1);
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);
+ ut_asserteq(50, obj->bbox.x0);
+ ut_asserteq(454, obj->bbox.y0);
+ ut_asserteq(50 + 29, obj->bbox.x1);
+ ut_asserteq(454 + 18, obj->bbox.y1);
+
+ /* same for the key */
+ obj = scene_obj_find(scn, ITEM1_KEY, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(280, obj->bbox.x0);
+ ut_asserteq(436, obj->bbox.y0);
+ ut_asserteq(280 + 9, obj->bbox.x1);
+ ut_asserteq(436 + 18, obj->bbox.y1);
+
+ obj = scene_obj_find(scn, ITEM2_KEY, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(280, obj->bbox.x0);
+ ut_asserteq(454, obj->bbox.y0);
+ ut_asserteq(280 + 9, obj->bbox.x1);
+ ut_asserteq(454 + 18, obj->bbox.y1);
+
+ /* and the description */
+ obj = scene_obj_find(scn, ITEM1_DESC, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(330, obj->bbox.x0);
+ ut_asserteq(436, obj->bbox.y0);
+ ut_asserteq(330 + 89, obj->bbox.x1);
+ ut_asserteq(436 + 18, obj->bbox.y1);
+
+ obj = scene_obj_find(scn, ITEM2_DESC, SCENEOBJT_NONE);
+ ut_assertnonnull(obj);
+ ut_asserteq(330, obj->bbox.x0);
+ ut_asserteq(454, obj->bbox.y0);
+ ut_asserteq(330 + 89, obj->bbox.x1);
+ ut_asserteq(454 + 18, obj->bbox.y1);
/* 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);
+ ut_asserteq(50, obj->bbox.x0);
+ ut_asserteq(400, obj->bbox.y0);
+ ut_asserteq(50 + 160, obj->bbox.x1);
+ ut_asserteq(400 + 160, obj->bbox.y1);
+
+ scene_obj_set_width(scn, OBJ_MENU, 170);
+ ut_asserteq(50 + 170, obj->bbox.x1);
+ scene_obj_set_bbox(scn, OBJ_MENU, 60, 410, 50 + 160, 400 + 160);
+ ut_asserteq(60, obj->bbox.x0);
+ ut_asserteq(410, obj->bbox.y0);
+ ut_asserteq(50 + 160, obj->bbox.x1);
+ ut_asserteq(400 + 160, obj->bbox.y1);
+
+ /* reset back to normal */
+ scene_obj_set_bbox(scn, OBJ_MENU, 50, 400, 50 + 160, 400 + 160);
/* render it */
expo_set_scene_id(exp, SCENE1);
ut_assertok(expo_render(exp));
+ ut_asserteq(0, scn->highlight_id);
+ ut_assertok(scene_arrange(scn));
+ ut_asserteq(0, scn->highlight_id);
+
+ scene_set_highlight_id(scn, OBJ_MENU);
+ ut_assertok(scene_arrange(scn));
+ ut_asserteq(OBJ_MENU, scn->highlight_id);
+ ut_assertok(expo_render(exp));
+
+ ut_asserteq(19704, video_compress_fb(uts, dev, false));
+
/* move down */
ut_assertok(expo_send_key(exp, BKEY_DOWN));
@@ -595,7 +680,31 @@ static int expo_render_image(struct unit_test_state *uts)
ut_asserteq(EXPOACT_POINT_ITEM, act.type);
ut_asserteq(ITEM2, act.select.id);
+ ut_assertok(scene_menu_select_item(scn, OBJ_MENU, act.select.id));
+ ut_asserteq(ITEM2, scene_menu_get_cur_item(scn, OBJ_MENU));
+ ut_assertok(scene_arrange(scn));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(19673, video_compress_fb(uts, dev, false));
+ ut_assertok(video_check_copy_fb(uts, dev));
+
+ /* hide the text editor since the following tets don't need it */
+ scene_obj_set_hide(scn, OBJ_TEXTED, true);
+
+ /* do some alignment checks */
+ ut_assertok(scene_obj_set_halign(scn, OBJ_TEXT3, SCENEOA_CENTRE));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(16368, video_compress_fb(uts, dev, false));
+ ut_assertok(scene_obj_set_halign(scn, OBJ_TEXT3, SCENEOA_RIGHT));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(16321, video_compress_fb(uts, dev, false));
+
+ ut_assertok(scene_obj_set_halign(scn, OBJ_TEXT3, SCENEOA_LEFT));
+ ut_assertok(scene_obj_set_valign(scn, OBJ_TEXT3, SCENEOA_CENTRE));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(18763, video_compress_fb(uts, dev, false));
+ ut_assertok(scene_obj_set_valign(scn, OBJ_TEXT3, SCENEOA_BOTTOM));
ut_assertok(expo_render(exp));
+ ut_asserteq(18714, video_compress_fb(uts, dev, false));
/* make sure only the preview for the second item is shown */
obj = scene_obj_find(scn, ITEM1_PREVIEW, SCENEOBJT_NONE);
@@ -617,6 +726,12 @@ static int expo_render_image(struct unit_test_state *uts)
/* make sure there was no console output */
ut_assert_console_end();
+ /* now try with the highlight */
+ exp->show_highlight = true;
+ ut_assertok(scene_arrange(scn));
+ ut_assertok(expo_render(exp));
+ ut_asserteq(18844, video_compress_fb(uts, dev, false));
+
/* now try in text mode */
expo_set_text_mode(exp, true);
ut_assertok(expo_render(exp));
@@ -635,6 +750,7 @@ static int expo_render_image(struct unit_test_state *uts)
ut_asserteq(EXPOACT_POINT_ITEM, act.type);
ut_asserteq(ITEM1, act.select.id);
+ ut_assertok(scene_menu_select_item(scn, OBJ_MENU, act.select.id));
ut_assertok(expo_render(exp));
ut_assert_nextline("U-Boot : Boot Menu");
@@ -658,6 +774,7 @@ 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 abuf orig, *copy;
struct scene_obj *obj;
struct scene *scn;
struct expo *exp;
@@ -678,7 +795,7 @@ static int expo_test_build(struct unit_test_state *uts)
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(ID_DYNAMIC_START, scn->title_id);
ut_asserteq(0, scn->highlight_id);
/* check the title */
@@ -690,7 +807,8 @@ static int expo_test_build(struct unit_test_state *uts)
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));
+ ut_asserteq_str("Test Configuration",
+ expo_get_str(exp, txt->gen.str_id));
/* check the menu */
menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_NONE);
@@ -702,7 +820,7 @@ static int expo_test_build(struct unit_test_state *uts)
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_str("CPU speed", expo_get_str(exp, txt->gen.str_id));
ut_asserteq(0, menu->cur_item_id);
ut_asserteq(0, menu->pointer_id);
@@ -719,11 +837,21 @@ static int expo_test_build(struct unit_test_state *uts)
ut_asserteq(0, item->value);
txt = scene_obj_find(scn, item->label_id, SCENEOBJT_NONE);
- ut_asserteq_str("2 GHz", expo_get_str(exp, txt->str_id));
+ ut_asserteq_str("2 GHz", expo_get_str(exp, txt->gen.str_id));
count = list_count_nodes(&menu->item_head);
ut_asserteq(3, count);
+ /* try editing some text */
+ ut_assertok(expo_edit_str(exp, txt->gen.str_id, &orig, &copy));
+ ut_asserteq_str("2 GHz", orig.data);
+ ut_asserteq_str("2 GHz", copy->data);
+
+ /* change it and check that things look right */
+ abuf_printf(copy, "atlantic %d", 123);
+ ut_asserteq_str("2 GHz", orig.data);
+ ut_asserteq_str("atlantic 123", copy->data);
+
expo_destroy(exp);
return 0;
diff --git a/test/boot/measurement.c b/test/boot/measurement.c
index 1d38663fc0f..71f503f1567 100644
--- a/test/boot/measurement.c
+++ b/test/boot/measurement.c
@@ -7,6 +7,7 @@
*/
#include <bootm.h>
+#include <env.h>
#include <malloc.h>
#include <test/test.h>
#include <test/ut.h>
diff --git a/test/boot/upl.c b/test/boot/upl.c
index eec89026fc3..e2dc3d51eda 100644
--- a/test/boot/upl.c
+++ b/test/boot/upl.c
@@ -7,6 +7,7 @@
*/
#include <abuf.h>
+#include <env.h>
#include <mapmem.h>
#include <upl.h>
#include <dm/ofnode.h>
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index c11c181c807..96a8488e172 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -6,6 +6,7 @@
*/
#include <console.h>
+#include <env.h>
#include <fdt_support.h>
#include <mapmem.h>
#include <asm/global_data.h>
diff --git a/test/cmd/hash.c b/test/cmd/hash.c
index 296dd762b31..bb96380c351 100644
--- a/test/cmd/hash.c
+++ b/test/cmd/hash.c
@@ -6,6 +6,7 @@
*/
#include <command.h>
+#include <env.h>
#include <dm.h>
#include <dm/test.h>
#include <test/test.h>
diff --git a/test/cmd/mem_copy.c b/test/cmd/mem_copy.c
index 3e904fc4e4b..8e551f18a85 100644
--- a/test/cmd/mem_copy.c
+++ b/test/cmd/mem_copy.c
@@ -4,6 +4,7 @@
*/
#include <command.h>
+#include <compiler.h>
#include <console.h>
#include <mapmem.h>
#include <dm/test.h>
diff --git a/test/cmd/mem_search.c b/test/cmd/mem_search.c
index df8938bdb6c..61de0dfb9a9 100644
--- a/test/cmd/mem_search.c
+++ b/test/cmd/mem_search.c
@@ -7,6 +7,7 @@
*/
#include <console.h>
+#include <env.h>
#include <mapmem.h>
#include <dm/test.h>
#include <test/ut.h>
diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c
index 85803eb54b8..93b0c4b68f5 100644
--- a/test/cmd/setexpr.c
+++ b/test/cmd/setexpr.c
@@ -7,6 +7,7 @@
*/
#include <console.h>
+#include <env.h>
#include <mapmem.h>
#include <dm/test.h>
#include <test/ut.h>
diff --git a/test/common/test_autoboot.c b/test/common/test_autoboot.c
index e3050d02c60..5feff57c271 100644
--- a/test/common/test_autoboot.c
+++ b/test/common/test_autoboot.c
@@ -6,6 +6,7 @@
*/
#include <autoboot.h>
+#include <env.h>
#include <test/common.h>
#include <test/test.h>
#include <test/ut.h>
diff --git a/test/dm/blkmap.c b/test/dm/blkmap.c
index a6a0b4d4e20..d04b68b50ae 100644
--- a/test/dm/blkmap.c
+++ b/test/dm/blkmap.c
@@ -7,6 +7,7 @@
#include <blk.h>
#include <blkmap.h>
#include <dm.h>
+#include <env.h>
#include <asm/test.h>
#include <dm/test.h>
#include <test/test.h>
diff --git a/test/dm/button.c b/test/dm/button.c
index 3612f308f02..f05f4ca27ce 100644
--- a/test/dm/button.c
+++ b/test/dm/button.c
@@ -8,6 +8,7 @@
#include <dm.h>
#include <adc.h>
#include <button.h>
+#include <env.h>
#include <power/regulator.h>
#include <power/sandbox_pmic.h>
#include <asm/gpio.h>
diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index ac56f17b775..64c21b10c3e 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -32,13 +32,13 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", &test_dev));
/* Test for clk_get_by_id() */
- ret = clk_get_by_id(SANDBOX_CLK_ECSPI_ROOT, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_ECSPI_ROOT), &clk);
ut_assertok(ret);
ut_asserteq_str("ecspi_root", clk->dev->name);
ut_asserteq(CLK_SET_RATE_PARENT, clk->flags);
/* Test for clk_get_parent_rate() */
- ret = clk_get_by_id(SANDBOX_CLK_ECSPI1, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_ECSPI1), &clk);
ut_assertok(ret);
ut_asserteq_str("ecspi1", clk->dev->name);
ut_asserteq(CLK_SET_RATE_PARENT, clk->flags);
@@ -47,7 +47,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
ut_asserteq(rate, 20000000);
/* test the gate of CCF */
- ret = clk_get_by_id(SANDBOX_CLK_ECSPI0, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_ECSPI0), &clk);
ut_assertok(ret);
ut_asserteq_str("ecspi0", clk->dev->name);
ut_asserteq(CLK_SET_RATE_PARENT, clk->flags);
@@ -56,7 +56,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
ut_asserteq(rate, 20000000);
/* Test the mux of CCF */
- ret = clk_get_by_id(SANDBOX_CLK_USDHC1_SEL, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_USDHC1_SEL), &clk);
ut_assertok(ret);
ut_asserteq_str("usdhc1_sel", clk->dev->name);
ut_asserteq(CLK_SET_RATE_NO_REPARENT, clk->flags);
@@ -70,7 +70,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
rate = clk_get_rate(clk);
ut_asserteq(rate, 60000000);
- ret = clk_get_by_id(SANDBOX_CLK_PLL3_80M, &pclk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_PLL3_80M), &pclk);
ut_assertok(ret);
ret = clk_set_parent(clk, pclk);
@@ -79,7 +79,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
rate = clk_get_rate(clk);
ut_asserteq(rate, 80000000);
- ret = clk_get_by_id(SANDBOX_CLK_USDHC2_SEL, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_USDHC2_SEL), &clk);
ut_assertok(ret);
ut_asserteq_str("usdhc2_sel", clk->dev->name);
ut_asserteq(CLK_SET_RATE_NO_REPARENT, clk->flags);
@@ -97,7 +97,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
rate = clk_get_rate(clk);
ut_asserteq(rate, 80000000);
- ret = clk_get_by_id(SANDBOX_CLK_PLL3_60M, &pclk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_PLL3_60M), &pclk);
ut_assertok(ret);
ret = clk_set_parent(clk, pclk);
@@ -107,7 +107,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
ut_asserteq(rate, 60000000);
/* Test the composite of CCF */
- ret = clk_get_by_id(SANDBOX_CLK_I2C, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_I2C), &clk);
ut_assertok(ret);
ut_asserteq_str("i2c", clk->dev->name);
ut_asserteq(CLK_SET_RATE_UNGATE, clk->flags);
@@ -124,12 +124,12 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
ret = clk_get_by_index(test_dev, SANDBOX_CLK_TEST_ID_I2C_ROOT, &clk_ccf);
ut_assertok(ret);
ut_asserteq_str("clk-ccf", clk_ccf.dev->name);
- ut_asserteq(clk_ccf.id, SANDBOX_CLK_I2C_ROOT);
+ ut_asserteq(clk_ccf.id, CLK_ID(clk_ccf.dev, SANDBOX_CLK_I2C_ROOT));
- ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_I2C_ROOT), &clk);
ut_assertok(ret);
ut_asserteq_str("i2c_root", clk->dev->name);
- ut_asserteq(clk->id, SANDBOX_CLK_I2C_ROOT);
+ ut_asserteq(clk_get_id(clk), SANDBOX_CLK_I2C_ROOT);
ret = clk_enable(&clk_ccf);
ut_assertok(ret);
@@ -137,7 +137,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
ret = sandbox_clk_enable_count(clk);
ut_asserteq(ret, 1);
- ret = clk_get_by_id(SANDBOX_CLK_I2C, &pclk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_I2C), &pclk);
ut_assertok(ret);
ret = sandbox_clk_enable_count(pclk);
@@ -153,7 +153,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
ut_asserteq(ret, 0);
/* Test clock re-parenting. */
- ret = clk_get_by_id(SANDBOX_CLK_USDHC1_SEL, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_USDHC1_SEL), &clk);
ut_assertok(ret);
ut_asserteq_str("usdhc1_sel", clk->dev->name);
@@ -167,7 +167,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
clkid = SANDBOX_CLK_PLL3_60M;
}
- ret = clk_get_by_id(clkid, &pclk);
+ ret = clk_get_by_id(CLK_ID(dev, clkid), &pclk);
ut_assertok(ret);
ret = clk_set_parent(clk, pclk);
ut_assertok(ret);
@@ -176,7 +176,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
ut_asserteq_str(clkname, pclk->dev->name);
/* Test disabling critical clock. */
- ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
+ ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_I2C_ROOT), &clk);
ut_assertok(ret);
ut_asserteq_str("i2c_root", clk->dev->name);
diff --git a/test/dm/dsa.c b/test/dm/dsa.c
index 9a31ae39d95..46e48741fba 100644
--- a/test/dm/dsa.c
+++ b/test/dm/dsa.c
@@ -3,6 +3,7 @@
* Copyright 2020-2021 NXP
*/
+#include <env.h>
#include <net/dsa.h>
#include <dm/test.h>
#include <test/ut.h>
diff --git a/test/dm/fastboot.c b/test/dm/fastboot.c
index 73c43f82924..5b51b6bf9dd 100644
--- a/test/dm/fastboot.c
+++ b/test/dm/fastboot.c
@@ -4,6 +4,7 @@
*/
#include <dm.h>
+#include <env.h>
#include <fastboot.h>
#include <fb_mmc.h>
#include <mmc.h>
diff --git a/test/dm/part.c b/test/dm/part.c
index c5c4b3fdba1..caae23bd4aa 100644
--- a/test/dm/part.c
+++ b/test/dm/part.c
@@ -4,6 +4,7 @@
*/
#include <dm.h>
+#include <env.h>
#include <mmc.h>
#include <part.h>
#include <part_efi.h>
diff --git a/test/dm/tpm.c b/test/dm/tpm.c
index 962a3fd1943..87c5c416daa 100644
--- a/test/dm/tpm.c
+++ b/test/dm/tpm.c
@@ -49,14 +49,87 @@ static int test_tpm_init(struct unit_test_state *uts, enum tpm_version version)
return 0;
}
-static int dm_test_tpm(struct unit_test_state *uts)
+static int dm_test_tpm_init(struct unit_test_state *uts)
{
ut_assertok(test_tpm_init(uts, TPM_V1));
ut_assertok(test_tpm_init(uts, TPM_V2));
return 0;
}
-DM_TEST(dm_test_tpm, UTF_SCAN_FDT);
+DM_TEST(dm_test_tpm_init, UTF_SCAN_FDT);
+
+/* check TPM startup */
+static int check_tpm_startup(struct unit_test_state *uts,
+ enum tpm_version version)
+{
+ struct udevice *dev;
+
+ /* check probe success */
+ ut_assertok(get_tpm_version(version, &dev));
+
+ ut_assertok(tpm_init(dev));
+ ut_assertok(tpm_startup(dev, TPM_ST_CLEAR));
+
+ return 0;
+}
+
+/* test TPM startup */
+static int dm_test_tpm_startup(struct unit_test_state *uts)
+{
+ ut_assertok(check_tpm_startup(uts, TPM_V1));
+ ut_assertok(check_tpm_startup(uts, TPM_V2));
+
+ return 0;
+}
+DM_TEST(dm_test_tpm_startup, UTF_SCAN_FDT);
+
+static int check_tpm_self_test_full(struct unit_test_state *uts,
+ enum tpm_version version)
+{
+ struct udevice *dev;
+
+ ut_assertok(check_tpm_startup(uts, version));
+
+ ut_assertok(get_tpm_version(version, &dev));
+ ut_assertok(tpm_self_test_full(dev));
+
+ return 0;
+}
+
+/* Test TPM self-test full */
+static int dm_test_tpm_self_test_full(struct unit_test_state *uts)
+{
+ ut_assertok(check_tpm_self_test_full(uts, TPM_V1));
+ ut_assertok(check_tpm_self_test_full(uts, TPM_V2));
+
+ return 0;
+}
+DM_TEST(dm_test_tpm_self_test_full, UTF_SCAN_FDT);
+
+/* Test TPM self-test continue */
+static int test_tpm_self_test_cont(struct unit_test_state *uts,
+ enum tpm_version version)
+{
+ struct udevice *dev;
+
+ /* check probe success */
+ ut_assertok(get_tpm_version(version, &dev));
+
+ ut_assertok(tpm_init(dev));
+ ut_assertok(tpm_startup(dev, TPM_ST_CLEAR));
+ ut_assertok(tpm_continue_self_test(dev));
+
+ return 0;
+}
+
+static int dm_test_tpm_self_test_cont(struct unit_test_state *uts)
+{
+ ut_assertok(test_tpm_self_test_cont(uts, TPM_V1));
+ ut_assertok(test_tpm_self_test_cont(uts, TPM_V2));
+
+ return 0;
+}
+DM_TEST(dm_test_tpm_self_test_cont, UTF_SCAN_FDT);
/* Test report_state */
static int dm_test_tpm_report_state(struct unit_test_state *uts)
diff --git a/test/env/fdt.c b/test/env/fdt.c
index c495ac7b307..3652563f330 100644
--- a/test/env/fdt.c
+++ b/test/env/fdt.c
@@ -1,4 +1,5 @@
#include <command.h>
+#include <env.h>
#include <env_attr.h>
#include <test/env.h>
#include <test/ut.h>
diff --git a/test/hush/dollar.c b/test/hush/dollar.c
index 820110799a2..b83a64d091d 100644
--- a/test/hush/dollar.c
+++ b/test/hush/dollar.c
@@ -5,6 +5,7 @@
*/
#include <command.h>
+#include <env.h>
#include <env_attr.h>
#include <test/hush.h>
#include <test/ut.h>
diff --git a/test/hush/if.c b/test/hush/if.c
index 8939b7a6c86..ea615b246a9 100644
--- a/test/hush/if.c
+++ b/test/hush/if.c
@@ -5,6 +5,7 @@
*/
#include <command.h>
+#include <env.h>
#include <env_attr.h>
#include <vsprintf.h>
#include <test/hush.h>
diff --git a/test/hush/loop.c b/test/hush/loop.c
index 7154b9bc0ae..ea72ac773ba 100644
--- a/test/hush/loop.c
+++ b/test/hush/loop.c
@@ -5,6 +5,7 @@
*/
#include <command.h>
+#include <env.h>
#include <env_attr.h>
#include <test/hush.h>
#include <test/ut.h>
diff --git a/test/lib/Makefile b/test/lib/Makefile
index d620510f998..ff4ff63270d 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_SHA256) += test_sha256_hmac.o
obj-$(CONFIG_HKDF_MBEDTLS) += test_sha256_hkdf.o
obj-$(CONFIG_GETOPT) += getopt.o
obj-$(CONFIG_CRC8) += test_crc8.o
+obj-$(CONFIG_REGEX) += slre.o
obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o
obj-$(CONFIG_UT_TIME) += time.o
obj-$(CONFIG_$(PHASE_)UT_UNICODE) += unicode.o
diff --git a/test/lib/abuf.c b/test/lib/abuf.c
index b38690fe1a9..97b128c01c0 100644
--- a/test/lib/abuf.c
+++ b/test/lib/abuf.c
@@ -419,3 +419,108 @@ static int lib_test_abuf_init(struct unit_test_state *uts)
return 0;
}
LIB_TEST(lib_test_abuf_init, 0);
+
+/* Test abuf_copy() */
+static int lib_test_abuf_copy(struct unit_test_state *uts)
+{
+ struct abuf buf, copy;
+ ulong start;
+
+ start = ut_check_free();
+
+ abuf_init_set(&buf, test_data, TEST_DATA_LEN);
+ ut_assert(abuf_copy(&buf, &copy));
+ ut_asserteq(buf.size, copy.size);
+ ut_assert(buf.data != copy.data);
+ ut_assert(copy.alloced);
+ abuf_uninit(&copy);
+ abuf_uninit(&buf);
+
+ /* Check for memory leaks */
+ ut_assertok(ut_check_delta(start));
+
+ return 0;
+}
+LIB_TEST(lib_test_abuf_copy, 0);
+
+/* Test abuf_init_size() */
+static int lib_test_abuf_init_size(struct unit_test_state *uts)
+{
+ struct abuf buf;
+ ulong start;
+
+ start = ut_check_free();
+
+ ut_assert(abuf_init_size(&buf, TEST_DATA_LEN));
+ ut_assertnonnull(buf.data);
+ ut_asserteq(TEST_DATA_LEN, buf.size);
+ ut_asserteq(true, buf.alloced);
+ abuf_uninit(&buf);
+
+ /* Check for memory leaks */
+ ut_assertok(ut_check_delta(start));
+
+ return 0;
+}
+LIB_TEST(lib_test_abuf_init_size, 0);
+
+/* Test abuf_printf() */
+static int lib_test_abuf_printf(struct unit_test_state *uts)
+{
+ struct abuf buf, fmt;
+ ulong start;
+ char *ptr;
+
+ start = ut_check_free();
+
+ /* start with a fresh buffer */
+ abuf_init(&buf);
+
+ /* check handling of out-of-memory condition */
+ malloc_enable_testing(0);
+ ut_asserteq(-ENOMEM, abuf_printf(&buf, "%s", ""));
+ malloc_enable_testing(1);
+
+ ut_asserteq(0, abuf_printf(&buf, "%s", ""));
+ ut_asserteq(1, buf.size);
+ ut_asserteq(true, buf.alloced);
+ ut_asserteq_str("", buf.data);
+
+ /* check expanding it, initially failing */
+ ut_asserteq(-ENOMEM, abuf_printf(&buf, "%s", "testing"));
+ malloc_disable_testing();
+
+ ut_asserteq(7, abuf_printf(&buf, "%s", "testing"));
+ ut_asserteq(8, buf.size);
+ ut_asserteq_str("testing", buf.data);
+
+ ut_asserteq(11, abuf_printf(&buf, "testing %d", 123));
+ ut_asserteq(12, buf.size);
+ ut_asserteq_str("testing 123", buf.data);
+
+ /* make it smaller; buffer should not shrink */
+ ut_asserteq(9, abuf_printf(&buf, "test %d", 456));
+ ut_asserteq(12, buf.size);
+ ut_asserteq_str("test 456", buf.data);
+
+ /* test the maximum size */
+ abuf_init(&fmt);
+ ut_assert(abuf_realloc(&fmt, 4100));
+ memset(fmt.data, 'x', 4100);
+ ptr = fmt.data;
+ ptr[4096] = '\0';
+
+ /* we are allowed up to 4K including the terminator */
+ ut_asserteq(-E2BIG, abuf_printf(&buf, "%s", ptr));
+ ptr[4095] = '\0';
+ ut_asserteq(4095, abuf_printf(&buf, "%s", ptr));
+
+ abuf_uninit(&fmt);
+ abuf_uninit(&buf);
+
+ /* Check for memory leaks */
+ ut_assertok(ut_check_delta(start));
+
+ return 0;
+}
+LIB_TEST(lib_test_abuf_printf, 0);
diff --git a/test/lib/efi_device_path.c b/test/lib/efi_device_path.c
index 5cc001e209e..5a358ddcb93 100644
--- a/test/lib/efi_device_path.c
+++ b/test/lib/efi_device_path.c
@@ -5,6 +5,7 @@
* Copyright (c) 2020 Heinrich Schuchardt <xypron.glpk@gmx.de>
*/
+#include <efi_device_path.h>
#include <efi_loader.h>
#include <test/lib.h>
#include <test/test.h>
diff --git a/test/lib/slre.c b/test/lib/slre.c
new file mode 100644
index 00000000000..ff2386d614a
--- /dev/null
+++ b/test/lib/slre.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+
+#include <test/lib.h>
+#include <test/ut.h>
+#include <slre.h>
+
+struct re_test {
+ const char *str;
+ const char *re;
+ int match;
+};
+
+static const struct re_test re_test[] = {
+ { "123", "^\\d+$", 1},
+ { "x23", "^\\d+$", 0},
+ { "banana", "^([bn]a)*$", 1},
+ { "panama", "^([bn]a)*$", 0},
+ { "xby", "^a|b", 1},
+ { "xby", "b|^a", 1},
+ { "xby", "b|c$", 1},
+ { "xby", "c$|b", 1},
+ { "", "x*$", 1},
+ { "", "^x*$", 1},
+ { "yy", "x*$", 1},
+ { "yy", "^x*$", 0},
+ { "Gadsby", "^[^eE]*$", 1},
+ { "Ernest", "^[^eE]*$", 0},
+ { "6d41f0a39d6", "^[0123456789abcdef]*$", 1 },
+ /* DIGIT is 17 */
+ { "##\x11%%\x11", "^[#%\\d]*$", 0 },
+ { "##23%%45", "^[#%\\d]*$", 1 },
+ { "U-Boot", "^[B-Uo-t]*$", 0 },
+ { "U-Boot", "^[A-Zm-v-]*$", 1 },
+ { "U-Boot", "^[-A-Za-z]*$", 1 },
+ /* The range --C covers both - and B. */
+ { "U-Boot", "^[--CUot]*$", 1 },
+ { "U-Boot", "^[^0-9]*$", 1 },
+ { "U-Boot", "^[^0-9<->]*$", 1 },
+ { "U-Boot", "^[^0-9<\\->]*$", 0 },
+ {}
+};
+
+static int lib_slre(struct unit_test_state *uts)
+{
+ const struct re_test *t;
+
+ for (t = re_test; t->str; t++) {
+ struct slre slre;
+
+ ut_assert(slre_compile(&slre, t->re));
+ ut_assertf(!!slre_match(&slre, t->str, strlen(t->str), NULL) == t->match,
+ "'%s' unexpectedly %s '%s'\n", t->str,
+ t->match ? "didn't match" : "matched", t->re);
+ }
+
+ return 0;
+}
+LIB_TEST(lib_slre, 0);
diff --git a/test/lib/string.c b/test/lib/string.c
index 31391a387b9..f56c2e4c946 100644
--- a/test/lib/string.c
+++ b/test/lib/string.c
@@ -261,3 +261,40 @@ static int lib_strstr(struct unit_test_state *uts)
return 0;
}
LIB_TEST(lib_strstr, 0);
+
+static int lib_strim(struct unit_test_state *uts)
+{
+ char buf[BUFLEN], *p;
+
+ strcpy(buf, "abc");
+ ut_asserteq_str("abc", strim(buf));
+
+ /* leading space */
+ strcpy(buf, " abc");
+ ut_asserteq_str("abc", strim(buf));
+
+ /* multiple leading spaces */
+ strcpy(buf, " abc");
+ ut_asserteq_str("abc", strim(buf));
+
+ /* multiple internal spaces */
+ strcpy(buf, " a bc");
+ ut_asserteq_str("a bc", strim(buf));
+
+ /* with trailing space */
+ strcpy(buf, " a bc ");
+ ut_asserteq_str("a bc", strim(buf));
+
+ /* with multiple trailing spaces */
+ strcpy(buf, " a bc ");
+ ut_asserteq_str("a bc", strim(buf));
+
+ /* with only spaces */
+ strcpy(buf, " ");
+ p = strim(buf);
+ ut_asserteq_ptr(p, buf);
+ ut_asserteq_str("", p);
+
+ return 0;
+}
+LIB_TEST(lib_strim, 0);
diff --git a/test/py/conftest.py b/test/py/conftest.py
index 5aea85647af..8ce680a92a0 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -514,8 +514,8 @@ def ubman(request):
handle_exception(ubconfig, ubman_fix, log, err, 'Lab timeout', True)
except BootFail as err:
handle_exception(ubconfig, ubman_fix, log, err, 'Boot fail', True,
- ubman.get_spawn_output())
- except Unexpected:
+ ubman_fix.get_spawn_output())
+ except Unexpected as err:
handle_exception(ubconfig, ubman_fix, log, err, 'Unexpected test output',
False)
return ubman_fix
@@ -711,9 +711,13 @@ def setup_buildconfigspec(item):
"""
for options in item.iter_markers('buildconfigspec'):
- option = options.args[0]
- if not ubconfig.buildconfig.get('config_' + option.lower(), None):
- pytest.skip('.config feature "%s" not enabled' % option.lower())
+ nomatch = True
+ for arg in options.args:
+ if ubconfig.buildconfig.get('config_' + arg.lower(), None):
+ nomatch = False
+ if nomatch:
+ argsString = ', '.join(options.args)
+ pytest.skip(f'.config features "{argsString}" not enabled')
for options in item.iter_markers('notbuildconfigspec'):
option = options.args[0]
if ubconfig.buildconfig.get('config_' + option.lower(), None):
diff --git a/test/py/tests/test_000_version.py b/test/py/tests/test_000_version.py
index b95ceae2346..63d392e956e 100644
--- a/test/py/tests/test_000_version.py
+++ b/test/py/tests/test_000_version.py
@@ -2,10 +2,12 @@
# Copyright (c) 2015 Stephen Warren
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
-# pytest runs tests the order of their module path, which is related to the
-# filename containing the test. This file is named such that it is sorted
-# first, simply as a very basic sanity check of the functionality of the U-Boot
-# command prompt.
+"""
+pytest runs tests the order of their module path, which is related to the
+filename containing the test. This file is named such that it is sorted
+first, simply as a very basic sanity check of the functionality of the U-Boot
+command prompt.
+"""
def test_version(ubman):
"""Test that the "version" command prints the U-Boot version."""
diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py
index 16c63ae9684..850fe113fe2 100644
--- a/test/py/tests/test_bind.py
+++ b/test/py/tests/test_bind.py
@@ -7,6 +7,7 @@ import re
import pytest
def in_tree(response, name, uclass, drv, depth, last_child):
+ """A helper function to confirm contents of the device tree """
lines = [x.strip() for x in response.splitlines()]
leaf = ''
if depth != 0:
@@ -28,7 +29,12 @@ def in_tree(response, name, uclass, drv, depth, last_child):
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_bind')
def test_bind_unbind_with_node(ubman):
+ """Test the bind and unbind commands of a node
+ Verify that the dm tree output contains some expected nodes, and then bind
+ and unbind a USB via node device while verifying that the dm tree output
+ matches the expected values at each step.
+ """
tree = ubman.run_command('dm tree')
assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True)
assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False)
@@ -106,6 +112,7 @@ def test_bind_unbind_with_node(ubman):
assert response == ''
def get_next_line(tree, name):
+ """A helper function to strip content out of dm tree output"""
treelines = [x.strip() for x in tree.splitlines() if x.strip()]
child_line = ''
for idx, line in enumerate(treelines):
@@ -121,6 +128,11 @@ def get_next_line(tree, name):
@pytest.mark.buildconfigspec('cmd_bind')
@pytest.mark.singlethread
def test_bind_unbind_with_uclass(ubman):
+ """Test the bind and unbind commands of a class
+
+ Bind and unbind the simple_bus class while verifying that the dm tree
+ output matches the expected values at each step.
+ """
#bind /bind-test
response = ubman.run_command('bind /bind-test simple_bus')
assert response == ''
diff --git a/test/py/tests/test_bootmenu.py b/test/py/tests/test_bootmenu.py
index 66f3fb8a131..be8257fe3e8 100644
--- a/test/py/tests/test_bootmenu.py
+++ b/test/py/tests/test_bootmenu.py
@@ -8,9 +8,9 @@ import pytest
def test_bootmenu(ubman):
"""Test bootmenu
- ubman -- U-Boot console
+ Args:
+ ubman: U-Boot console
"""
-
with ubman.temporary_timeout(500):
ubman.run_command('setenv bootmenu_default 1')
ubman.run_command('setenv bootmenu_0 test 1=echo ok 1')
diff --git a/test/py/tests/test_bootstage.py b/test/py/tests/test_bootstage.py
index 379c1cae6dd..2505862c5a4 100644
--- a/test/py/tests/test_bootstage.py
+++ b/test/py/tests/test_bootstage.py
@@ -1,8 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# (C) Copyright 2023, Advanced Micro Devices, Inc.
-import pytest
-
"""
Test the bootstage command.
@@ -15,16 +13,32 @@ common/bootstage.c). Without this, bootstage stash and unstash tests will be
automatically skipped.
For example:
-env__bootstage_cmd_file = {
- 'addr': 0x200000,
- 'size': 0x1000,
- 'bootstage_magic_addr': 0xb00757a3,
-}
+
+.. code-block:: python
+
+ env__bootstage_cmd_file = {
+ 'addr': 0x200000,
+ 'size': 0x1000,
+ 'bootstage_magic_addr': 0xb00757a3,
+ }
"""
+import pytest
+
@pytest.mark.buildconfigspec('bootstage')
@pytest.mark.buildconfigspec('cmd_bootstage')
def test_bootstage_report(ubman):
+ """Test the bootstage report subcommand
+
+ This will run the 'bootstage report' subcommand and ensure that we are
+ reporting:
+
+ - A timer summary in microseconds
+ - The accumulated time
+ - That at least the phrase 'dm_r' is in the output
+
+ Note that the time values are not checked.
+ """
output = ubman.run_command('bootstage report')
assert 'Timer summary in microseconds' in output
assert 'Accumulated time:' in output
@@ -34,6 +48,13 @@ def test_bootstage_report(ubman):
@pytest.mark.buildconfigspec('cmd_bootstage')
@pytest.mark.buildconfigspec('bootstage_stash')
def test_bootstage_stash_and_unstash(ubman):
+ """Test the bootstage stash and unstash subcommands
+
+ After checking that we have configured an environment file to use, we will
+ use the stash subcommand to save information. Then we will use the md
+ command to verify the contents in memory. Finally we confirm the unstash
+ subcommand runs successfully.
+ """
f = ubman.config.env.get('env__bootstage_cmd_file', None)
if not f:
pytest.skip('No bootstage environment file is defined')
diff --git a/test/py/tests/test_button.py b/test/py/tests/test_button.py
index f0d85be896d..f3f68169e14 100644
--- a/test/py/tests/test_button.py
+++ b/test/py/tests/test_button.py
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0+
+"""Tests for the button command"""
+
import pytest
@pytest.mark.boardspec('sandbox')
diff --git a/test/py/tests/test_efi_fit.py b/test/py/tests/test_efi_fit.py
index 5f352e7efff..63ee8e6cef2 100644
--- a/test/py/tests/test_efi_fit.py
+++ b/test/py/tests/test_efi_fit.py
@@ -66,9 +66,29 @@ ITS_DATA = '''
#address-cells = <1>;
images {
- efi {
+ helloworld {
description = "Test EFI";
- data = /incbin/("%(efi-bin)s");
+ data = /incbin/("%(hello-bin)s");
+ type = "%(kernel-type)s";
+ arch = "%(sys-arch)s";
+ os = "efi";
+ compression = "%(efi-comp)s";
+ load = <0x0>;
+ entry = <0x0>;
+ };
+ dtbdump {
+ description = "Test EFI fdtdump";
+ data = /incbin/("%(dtbdump-bin)s");
+ type = "%(kernel-type)s";
+ arch = "%(sys-arch)s";
+ os = "efi";
+ compression = "%(efi-comp)s";
+ load = <0x0>;
+ entry = <0x0>;
+ };
+ initrddump {
+ description = "Test EFI initrddump";
+ data = /incbin/("%(initrddump-bin)s");
type = "%(kernel-type)s";
arch = "%(sys-arch)s";
os = "efi";
@@ -83,18 +103,33 @@ ITS_DATA = '''
arch = "%(sys-arch)s";
compression = "%(fdt-comp)s";
};
+ initrd {
+ description = "Initial RAM Disk";
+ data = /incbin/("%(initrd-fs)s");
+ type = "ramdisk";
+ compression = "%(initrd-comp)s";
+ os = "efi";
+ };
};
configurations {
default = "config-efi-fdt";
+
+ config-efi {
+ description = "EFI FIT w/o FDT";
+ kernel = "helloworld";
+ };
+
config-efi-fdt {
description = "EFI FIT w/ FDT";
- kernel = "efi";
+ kernel = "dtbdump";
fdt = "fdt";
};
- config-efi-nofdt {
- description = "EFI FIT w/o FDT";
- kernel = "efi";
+
+ config-efi-initrd {
+ description = "EFI FIT w/ initrd";
+ kernel = "initrddump";
+ ramdisk = "initrd";
};
};
};
@@ -108,7 +143,7 @@ FDT_DATA = '''
#address-cells = <1>;
#size-cells = <1>;
- model = "%(sys-arch)s %(fdt_type)s EFI FIT Boot Test";
+ model = "%(sys-arch)s %(fdt_type)s EFI FIT FDT Boot Test";
compatible = "%(sys-arch)s";
reset@0 {
@@ -120,6 +155,7 @@ FDT_DATA = '''
@pytest.mark.buildconfigspec('bootm_efi')
@pytest.mark.buildconfigspec('BOOTEFI_HELLO_COMPILE')
+@pytest.mark.buildconfigspec('EFI_LOAD_FILE2_INITRD')
@pytest.mark.buildconfigspec('fit')
@pytest.mark.notbuildconfigspec('generate_acpi_table')
@pytest.mark.requiredtool('dtc')
@@ -137,8 +173,10 @@ def test_efi_fit_launch(ubman):
The following test cases are currently defined and enabled:
- Launch uncompressed FIT EFI & internal FDT
- Launch uncompressed FIT EFI & FIT FDT
+ - Launch uncompressed FIT EFI & internal FDT & FIT initrd
- Launch compressed FIT EFI & internal FDT
- Launch compressed FIT EFI & FIT FDT
+ - Launch compressed FIT EFI & internal FDT & FIT initrd
"""
def net_pre_commands():
@@ -210,7 +248,7 @@ def test_efi_fit_launch(ubman):
return os.path.join(ubman.config.build_dir, file_name)
- def make_efi(fname, comp):
+ def make_efi(fname, efi_file, comp):
"""Create an UEFI binary.
This simply copies lib/efi_loader/helloworld.efi into U-Boot
@@ -218,6 +256,7 @@ def test_efi_fit_launch(ubman):
Args:
fname -- The target file name within U-Boot build dir.
+ efi_file -- The source .efi application
comp -- Flag to enable gzip compression.
Return:
The path of the created file.
@@ -225,7 +264,7 @@ def test_efi_fit_launch(ubman):
bin_path = make_fpath(fname)
utils.run_and_log(ubman,
- ['cp', make_fpath('lib/efi_loader/helloworld.efi'),
+ ['cp', make_fpath(f'lib/efi_loader/{efi_file}'),
bin_path])
if comp:
utils.run_and_log(ubman, ['gzip', '-f', bin_path])
@@ -264,6 +303,27 @@ def test_efi_fit_launch(ubman):
dtb += '.gz'
return dtb
+ def make_initrd(comp):
+ """Create a sample initrd.
+
+ Creates an initrd.
+
+ Args:
+ comp -- Flag to enable gzip compression.
+ Return:
+ The path of the created file.
+ """
+
+ # Generate a test initrd file.
+ initrd = make_fpath('test-efi-initrd')
+ with open(initrd, 'w', encoding='ascii') as file:
+ file.write('test-efi-initrd')
+
+ if comp:
+ utils.run_and_log(ubman, ['gzip', '-f', initrd])
+ initrd += '.gz'
+ return initrd
+
def make_fit(comp):
"""Create a sample FIT image.
@@ -275,22 +335,35 @@ def test_efi_fit_launch(ubman):
"""
# Generate resources referenced by ITS.
+ hello_bin = os.path.basename(make_efi('test-efi-helloworld.efi', 'helloworld.efi', comp))
+ dtbdump_bin = os.path.basename(make_efi('test-efi-dtbdump.efi', 'dtbdump.efi', comp))
+ initrddump_bin = os.path.basename(make_efi('test-efi-initrddump.efi', 'initrddump.efi', comp))
+ fdt_bin = os.path.basename(make_dtb('user', comp))
+ initrd_fs = make_initrd(comp)
+ initrd_fs = os.path.basename(initrd_fs)
+ compression = 'gzip' if comp else 'none'
+ kernel_type = 'kernel' if comp else 'kernel_noload'
+
its_params = {
'sys-arch': sys_arch,
- 'efi-bin': os.path.basename(make_efi('test-efi-fit-helloworld.efi', comp)),
- 'kernel-type': 'kernel' if comp else 'kernel_noload',
- 'efi-comp': 'gzip' if comp else 'none',
- 'fdt-bin': os.path.basename(make_dtb('user', comp)),
- 'fdt-comp': 'gzip' if comp else 'none',
+ 'hello-bin': hello_bin,
+ 'dtbdump-bin': dtbdump_bin,
+ 'initrddump-bin': initrddump_bin,
+ 'kernel-type': kernel_type,
+ 'efi-comp': compression,
+ 'fdt-bin': fdt_bin,
+ 'fdt-comp': compression,
+ 'initrd-fs': initrd_fs,
+ 'initrd-comp': compression,
}
# Generate a test ITS file.
- its_path = make_fpath('test-efi-fit-helloworld.its')
+ its_path = make_fpath('test-efi-fit.its')
with open(its_path, 'w', encoding='ascii') as file:
file.write(ITS_DATA % its_params)
# Build the test ITS.
- fit_path = make_fpath('test-efi-fit-helloworld.fit')
+ fit_path = make_fpath('test-efi-fit.fit')
utils.run_and_log(
ubman, [make_fpath('tools/mkimage'), '-f', its_path, fit_path])
return fit_path
@@ -357,7 +430,7 @@ def test_efi_fit_launch(ubman):
return addr
- def launch_efi(enable_fdt, enable_comp):
+ def launch_efi(enable_fdt, enable_initrd, enable_comp):
"""Launch U-Boot's helloworld.efi binary from a FIT image.
An external image file can be downloaded from TFTP, when related
@@ -372,19 +445,20 @@ def test_efi_fit_launch(ubman):
from the host filesystem.
Once the load address is available on U-Boot console, the 'bootm'
- command is executed for either 'config-efi-fdt' or 'config-efi-nofdt'
- FIT configuration, depending on the value of the 'enable_fdt' function
- argument.
+ command is executed for either 'config-efi', 'config-efi-fdt' or
+ 'config-efi-initrd' FIT configuration, depending on the value of the
+ 'enable_fdt' and 'enable_initrd' function arguments.
Eventually the 'Hello, world' message is expected in the U-Boot console.
Args:
enable_fdt -- Flag to enable using the FDT blob inside FIT image.
+ enable_initrd -- Flag to enable using an initrd inside FIT image.
enable_comp -- Flag to enable GZIP compression on EFI and FDT
generated content.
"""
- with ubman.log.section('FDT=%s;COMP=%s' % (enable_fdt, enable_comp)):
+ with ubman.log.section('FDT=%s;INITRD=%s;COMP=%s' % (enable_fdt, enable_initrd, enable_comp)):
if is_sandbox:
fit = {
'dn': ubman.config.build_dir,
@@ -420,14 +494,28 @@ def test_efi_fit_launch(ubman):
addr = load_fit_from_host(fit) if is_sandbox else load_fit_from_tftp(fit)
# Select boot configuration.
- fit_config = 'config-efi-fdt' if enable_fdt else 'config-efi-nofdt'
+ fit_config = 'config-efi'
+ fit_config = fit_config + '-fdt' if enable_fdt else fit_config
+ fit_config = fit_config + '-initrd' if enable_initrd else fit_config
# Try booting.
+ ubman.run_command('setenv bootargs nocolor')
output = ubman.run_command('bootm %x#%s' % (addr, fit_config))
+ assert '## Application failed' not in output
if enable_fdt:
assert 'Booting using the fdt blob' in output
- assert 'Hello, world' in output
- assert '## Application failed' not in output
+ assert 'DTB Dump' in output
+ if enable_initrd:
+ assert 'Loading ramdisk' in output
+ assert 'INITRD Dump' in output
+ if enable_fdt:
+ response = ubman.run_command(cmd = 'dump', wait_for_echo=False)
+ assert 'EFI FIT FDT Boot Test' in response
+ if enable_initrd:
+ response = ubman.run_command('load', wait_for_echo=False)
+ assert f"crc32: 0x0c77b025" in response
+ if not enable_fdt and not enable_initrd:
+ assert 'Hello, world' in output
ubman.restart_uboot()
# Array slice removes leading/trailing quotes.
@@ -449,16 +537,20 @@ def test_efi_fit_launch(ubman):
ubman.config.dtb = control_dtb
# Run tests
- # - fdt OFF, gzip OFF
- launch_efi(False, False)
- # - fdt ON, gzip OFF
- launch_efi(True, False)
+ # - fdt OFF, initrd OFF, gzip OFF
+ launch_efi(False, False, False)
+ # - fdt ON, initrd OFF, gzip OFF
+ launch_efi(True, False, False)
+ # - fdt OFF, initrd ON, gzip OFF
+ launch_efi(False, True, False)
if is_sandbox:
- # - fdt OFF, gzip ON
- launch_efi(False, True)
- # - fdt ON, gzip ON
- launch_efi(True, True)
+ # - fdt OFF, initrd OFF, gzip ON
+ launch_efi(False, False, True)
+ # - fdt ON, initrd OFF, gzip ON
+ launch_efi(True, False, True)
+ # - fdt OFF, initrd ON, gzip ON
+ launch_efi(False, True, True)
finally:
if is_sandbox:
diff --git a/test/py/tests/test_efi_loader.py b/test/py/tests/test_efi_loader.py
index 58f2655191f..dc58c0d4dbd 100644
--- a/test/py/tests/test_efi_loader.py
+++ b/test/py/tests/test_efi_loader.py
@@ -13,43 +13,45 @@ that rely on network will be automatically skipped.
For example:
-# Boolean indicating whether the Ethernet device is attached to USB, and hence
-# USB enumeration needs to be performed prior to network tests.
-# This variable may be omitted if its value is False.
-env__net_uses_usb = False
-
-# Boolean indicating whether the Ethernet device is attached to PCI, and hence
-# PCI enumeration needs to be performed prior to network tests.
-# This variable may be omitted if its value is False.
-env__net_uses_pci = True
-
-# True if a DHCP server is attached to the network, and should be tested.
-# If DHCP testing is not possible or desired, this variable may be omitted or
-# set to False.
-env__net_dhcp_server = True
-
-# A list of environment variables that should be set in order to configure a
-# static IP. If solely relying on DHCP, this variable may be omitted or set to
-# an empty list.
-env__net_static_env_vars = [
- ('ipaddr', '10.0.0.100'),
- ('netmask', '255.255.255.0'),
- ('serverip', '10.0.0.1'),
-]
-
-# Details regarding a file that may be read from a TFTP server. This variable
-# may be omitted or set to None if TFTP testing is not possible or desired.
-env__efi_loader_helloworld_file = {
- 'fn': 'lib/efi_loader/helloworld.efi', # file name
- 'size': 5058624, # file length in bytes
- 'crc32': 'c2244b26', # CRC32 check sum
- 'addr': 0x40400000, # load address
-}
-
-# False if the helloworld EFI over HTTP boot test should be performed.
-# If HTTP boot testing is not possible or desired, set this variable to True or
-# ommit it.
-env__efi_helloworld_net_http_test_skip = True
+.. code-block:: python
+
+ # Boolean indicating whether the Ethernet device is attached to USB, and hence
+ # USB enumeration needs to be performed prior to network tests.
+ # This variable may be omitted if its value is False.
+ env__net_uses_usb = False
+
+ # Boolean indicating whether the Ethernet device is attached to PCI, and hence
+ # PCI enumeration needs to be performed prior to network tests.
+ # This variable may be omitted if its value is False.
+ env__net_uses_pci = True
+
+ # True if a DHCP server is attached to the network, and should be tested.
+ # If DHCP testing is not possible or desired, this variable may be omitted or
+ # set to False.
+ env__net_dhcp_server = True
+
+ # A list of environment variables that should be set in order to configure a
+ # static IP. If solely relying on DHCP, this variable may be omitted or set to
+ # an empty list.
+ env__net_static_env_vars = [
+ ('ipaddr', '10.0.0.100'),
+ ('netmask', '255.255.255.0'),
+ ('serverip', '10.0.0.1'),
+ ]
+
+ # Details regarding a file that may be read from a TFTP server. This variable
+ # may be omitted or set to None if TFTP testing is not possible or desired.
+ env__efi_loader_helloworld_file = {
+ 'fn': 'lib/efi_loader/helloworld.efi', # file name
+ 'size': 5058624, # file length in bytes
+ 'crc32': 'c2244b26', # CRC32 check sum
+ 'addr': 0x40400000, # load address
+ }
+
+ # False if the helloworld EFI over HTTP boot test should be performed.
+ # If HTTP boot testing is not possible or desired, set this variable to True or
+ # ommit it.
+ env__efi_helloworld_net_http_test_skip = True
"""
import pytest
@@ -96,7 +98,7 @@ def test_efi_setup_dhcp(ubman):
global net_set_up
net_set_up = True
-@pytest.mark.buildconfigspec('net')
+@pytest.mark.buildconfigspec('net', 'net_lwip')
def test_efi_setup_static(ubman):
"""Set up the network using a static IP configuration.
@@ -161,6 +163,11 @@ def fetch_file(ubman, env_conf, proto):
return addr
def do_test_efi_helloworld_net(ubman, proto):
+ """Download and execute the helloworld appliation
+
+ The helloworld.efi file is downloaded based on the value passed to us as a
+ protocol and is executed using the fallback device tree at $fdtcontroladdr.
+ """
addr = fetch_file(ubman, 'env__efi_loader_helloworld_file', proto)
output = ubman.run_command('bootefi %x' % addr)
@@ -175,8 +182,7 @@ def do_test_efi_helloworld_net(ubman, proto):
def test_efi_helloworld_net_tftp(ubman):
"""Run the helloworld.efi binary via TFTP.
- The helloworld.efi file is downloaded from the TFTP server and is executed
- using the fallback device tree at $fdtcontroladdr.
+ Call the do_test_efi_helloworld_net function to execute the test via TFTP.
"""
do_test_efi_helloworld_net(ubman, PROTO_TFTP);
@@ -187,8 +193,7 @@ def test_efi_helloworld_net_tftp(ubman):
def test_efi_helloworld_net_http(ubman):
"""Run the helloworld.efi binary via HTTP.
- The helloworld.efi file is downloaded from the HTTP server and is executed
- using the fallback device tree at $fdtcontroladdr.
+ Call the do_test_efi_helloworld_net function to execute the test via HTTP.
"""
if ubman.config.env.get('env__efi_helloworld_net_http_test_skip', True):
pytest.skip('helloworld.efi HTTP test is not enabled!')
diff --git a/test/py/tests/test_fpga.py b/test/py/tests/test_fpga.py
index 74cd42b910e..299a8653f74 100644
--- a/test/py/tests/test_fpga.py
+++ b/test/py/tests/test_fpga.py
@@ -506,7 +506,7 @@ def test_fpga_loadfs(ubman):
@pytest.mark.buildconfigspec('cmd_fpga_load_secure')
@pytest.mark.buildconfigspec('cmd_net')
@pytest.mark.buildconfigspec('cmd_dhcp')
-@pytest.mark.buildconfigspec('net')
+@pytest.mark.buildconfigspec('net', 'net_lwip')
def test_fpga_secure_bit_auth(ubman):
test_net.test_net_dhcp(ubman)
@@ -534,7 +534,7 @@ def test_fpga_secure_bit_auth(ubman):
@pytest.mark.buildconfigspec('cmd_fpga_load_secure')
@pytest.mark.buildconfigspec('cmd_net')
@pytest.mark.buildconfigspec('cmd_dhcp')
-@pytest.mark.buildconfigspec('net')
+@pytest.mark.buildconfigspec('net', 'net_lwip')
def test_fpga_secure_bit_img_auth_kup(ubman):
test_net.test_net_dhcp(ubman)
diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
index 4732e4b57f8..6ef02e53389 100644
--- a/test/py/tests/test_net.py
+++ b/test/py/tests/test_net.py
@@ -4,12 +4,6 @@
# Test various network-related functionality, such as the dhcp, ping, and
# tftpboot commands.
-import pytest
-import utils
-import uuid
-import datetime
-import re
-
"""
Note: This test relies on boardenv_* containing configuration values to define
which network environment is available for testing. Without this, this test
@@ -17,77 +11,85 @@ will be automatically skipped.
For example:
-# Boolean indicating whether the Ethernet device is attached to USB, and hence
-# USB enumeration needs to be performed prior to network tests.
-# This variable may be omitted if its value is False.
-env__net_uses_usb = False
-
-# Boolean indicating whether the Ethernet device is attached to PCI, and hence
-# PCI enumeration needs to be performed prior to network tests.
-# This variable may be omitted if its value is False.
-env__net_uses_pci = True
-
-# True if a DHCP server is attached to the network, and should be tested.
-# If DHCP testing is not possible or desired, this variable may be omitted or
-# set to False.
-env__net_dhcp_server = True
-
-# False or omitted if a DHCP server is attached to the network, and dhcp abort
-# case should be tested.
-# If DHCP abort testing is not possible or desired, set this variable to True.
-# For example: On some setup, dhcp is too fast and this case may not work.
-env__dhcp_abort_test_skip = True
-
-# True if a DHCPv6 server is attached to the network, and should be tested.
-# If DHCPv6 testing is not possible or desired, this variable may be omitted or
-# set to False.
-env__net_dhcp6_server = True
-
-# A list of environment variables that should be set in order to configure a
-# static IP. If solely relying on DHCP, this variable may be omitted or set to
-# an empty list.
-env__net_static_env_vars = [
- ('ipaddr', '10.0.0.100'),
- ('netmask', '255.255.255.0'),
- ('serverip', '10.0.0.1'),
-]
-
-# Details regarding a file that may be read from a TFTP server. This variable
-# may be omitted or set to None if TFTP testing is not possible or desired.
-env__net_tftp_readable_file = {
- 'fn': 'ubtest-readable.bin',
- 'addr': 0x10000000,
- 'size': 5058624,
- 'crc32': 'c2244b26',
- 'timeout': 50000,
- 'fnu': 'ubtest-upload.bin',
-}
-
-# Details regarding a file that may be read from a NFS server. This variable
-# may be omitted or set to None if NFS testing is not possible or desired.
-env__net_nfs_readable_file = {
- 'fn': 'ubtest-readable.bin',
- 'addr': 0x10000000,
- 'size': 5058624,
- 'crc32': 'c2244b26',
-}
-
-# Details regarding a file that may be read from a TFTP server. This variable
-# may be omitted or set to None if PXE testing is not possible or desired.
-env__net_pxe_readable_file = {
- 'fn': 'default',
- 'addr': 0x2000000,
- 'size': 74,
- 'timeout': 50000,
- 'pattern': 'Linux',
-}
-
-# True if a router advertisement service is connected to the network, and should
-# be tested. If router advertisement testing is not possible or desired, this
-variable may be omitted or set to False.
-env__router_on_net = True
+.. code-block:: python
+
+ # Boolean indicating whether the Ethernet device is attached to USB, and hence
+ # USB enumeration needs to be performed prior to network tests.
+ # This variable may be omitted if its value is False.
+ env__net_uses_usb = False
+
+ # Boolean indicating whether the Ethernet device is attached to PCI, and hence
+ # PCI enumeration needs to be performed prior to network tests.
+ # This variable may be omitted if its value is False.
+ env__net_uses_pci = True
+
+ # True if a DHCP server is attached to the network, and should be tested.
+ # If DHCP testing is not possible or desired, this variable may be omitted or
+ # set to False.
+ env__net_dhcp_server = True
+
+ # False or omitted if a DHCP server is attached to the network, and dhcp abort
+ # case should be tested.
+ # If DHCP abort testing is not possible or desired, set this variable to True.
+ # For example: On some setup, dhcp is too fast and this case may not work.
+ env__dhcp_abort_test_skip = True
+
+ # True if a DHCPv6 server is attached to the network, and should be tested.
+ # If DHCPv6 testing is not possible or desired, this variable may be omitted or
+ # set to False.
+ env__net_dhcp6_server = True
+
+ # A list of environment variables that should be set in order to configure a
+ # static IP. If solely relying on DHCP, this variable may be omitted or set to
+ # an empty list.
+ env__net_static_env_vars = [
+ ('ipaddr', '10.0.0.100'),
+ ('netmask', '255.255.255.0'),
+ ('serverip', '10.0.0.1'),
+ ]
+
+ # Details regarding a file that may be read from a TFTP server. This variable
+ # may be omitted or set to None if TFTP testing is not possible or desired.
+ env__net_tftp_readable_file = {
+ 'fn': 'ubtest-readable.bin',
+ 'addr': 0x10000000,
+ 'size': 5058624,
+ 'crc32': 'c2244b26',
+ 'timeout': 50000,
+ 'fnu': 'ubtest-upload.bin',
+ }
+
+ # Details regarding a file that may be read from a NFS server. This variable
+ # may be omitted or set to None if NFS testing is not possible or desired.
+ env__net_nfs_readable_file = {
+ 'fn': 'ubtest-readable.bin',
+ 'addr': 0x10000000,
+ 'size': 5058624,
+ 'crc32': 'c2244b26',
+ }
+
+ # Details regarding a file that may be read from a TFTP server. This variable
+ # may be omitted or set to None if PXE testing is not possible or desired.
+ env__net_pxe_readable_file = {
+ 'fn': 'default',
+ 'addr': 0x2000000,
+ 'size': 74,
+ 'timeout': 50000,
+ 'pattern': 'Linux',
+ }
+
+ # True if a router advertisement service is connected to the network, and should
+ # be tested. If router advertisement testing is not possible or desired, this
+ variable may be omitted or set to False.
+ env__router_on_net = True
"""
+import pytest
+import utils
+import uuid
+import datetime
+import re
+
net_set_up = False
net6_set_up = False
@@ -199,7 +201,7 @@ def test_net_dhcp6(ubman):
global net6_set_up
net6_set_up = True
-@pytest.mark.buildconfigspec('net')
+@pytest.mark.buildconfigspec('net', 'net_lwip')
def test_net_setup_static(ubman):
"""Set up a static IP configuration.
diff --git a/test/py/tests/test_net_boot.py b/test/py/tests/test_net_boot.py
index abf6dfbaf5e..72086a74637 100644
--- a/test/py/tests/test_net_boot.py
+++ b/test/py/tests/test_net_boot.py
@@ -1,11 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# (C) Copyright 2023, Advanced Micro Devices, Inc.
-import pytest
-import utils
-import test_net
-import re
-
"""
Note: This test relies on boardenv_* containing configuration values to define
which the network environment available for testing. Without this, this test
@@ -13,77 +8,88 @@ will be automatically skipped.
For example:
-# Details regarding a boot image file that may be read from a TFTP server. This
-# variable may be omitted or set to None if TFTP boot testing is not possible
-# or desired.
-env__net_tftp_bootable_file = {
- 'fn': 'image.ub',
- 'addr': 0x10000000,
- 'size': 5058624,
- 'crc32': 'c2244b26',
- 'pattern': 'Linux',
- 'config': 'config@2',
- 'timeout': 50000,
- 'check_type': 'boot_error',
- 'check_pattern': 'ERROR',
-}
-
-# False or omitted if a TFTP boot test should be tested.
-# If TFTP boot testing is not possible or desired, set this variable to True.
-# For example: If FIT image is not proper to boot
-env__tftp_boot_test_skip = False
-
-# Here is the example of FIT image configurations:
-configurations {
- default = "config@1";
- config@1 {
- description = "Boot Linux kernel with config@1";
- kernel = "kernel@0";
- fdt = "fdt@0";
- ramdisk = "ramdisk@0";
- hash@1 {
- algo = "sha1";
- };
- };
- config@2 {
- description = "Boot Linux kernel with config@2";
- kernel = "kernel@1";
- fdt = "fdt@1";
- ramdisk = "ramdisk@1";
- hash@1 {
- algo = "sha1";
- };
- };
-};
-
-# Details regarding a file that may be read from a TFTP server. This variable
-# may be omitted or set to None if PXE testing is not possible or desired.
-env__net_pxe_bootable_file = {
- 'fn': 'default',
- 'addr': 0x10000000,
- 'size': 74,
- 'timeout': 50000,
- 'pattern': 'Linux',
- 'valid_label': '1',
- 'invalid_label': '2',
- 'exp_str_invalid': 'Skipping install for failure retrieving',
- 'local_label': '3',
- 'exp_str_local': 'missing environment variable: localcmd',
- 'empty_label': '4',
- 'exp_str_empty': 'No kernel given, skipping boot',
- 'check_type': 'boot_error',
- 'check_pattern': 'ERROR',
-}
-
-# False if a PXE boot test should be tested.
-# If PXE boot testing is not possible or desired, set this variable to True.
-# For example: If pxe configuration file is not proper to boot
-env__pxe_boot_test_skip = False
-
-# Here is the example of pxe configuration file ordered based on the execution
-# flow:
+.. code-block:: python
+
+ # Details regarding a boot image file that may be read from a TFTP server. This
+ # variable may be omitted or set to None if TFTP boot testing is not possible
+ # or desired.
+ env__net_tftp_bootable_file = {
+ 'fn': 'image.ub',
+ 'addr': 0x10000000,
+ 'size': 5058624,
+ 'crc32': 'c2244b26',
+ 'pattern': 'Linux',
+ 'config': 'config@2',
+ 'timeout': 50000,
+ 'check_type': 'boot_error',
+ 'check_pattern': 'ERROR',
+ }
+
+ # False or omitted if a TFTP boot test should be tested.
+ # If TFTP boot testing is not possible or desired, set this variable to True.
+ # For example: If FIT image is not proper to boot
+ env__tftp_boot_test_skip = False
+
+
+Here is the example of FIT image configurations:
+
+.. code-block:: devicetree
+
+ configurations {
+ default = "config@1";
+ config@1 {
+ description = "Boot Linux kernel with config@1";
+ kernel = "kernel@0";
+ fdt = "fdt@0";
+ ramdisk = "ramdisk@0";
+ hash@1 {
+ algo = "sha1";
+ };
+ };
+ config@2 {
+ description = "Boot Linux kernel with config@2";
+ kernel = "kernel@1";
+ fdt = "fdt@1";
+ ramdisk = "ramdisk@1";
+ hash@1 {
+ algo = "sha1";
+ };
+ };
+ };
+
+.. code-block:: python
+
+ # Details regarding a file that may be read from a TFTP server. This variable
+ # may be omitted or set to None if PXE testing is not possible or desired.
+ env__net_pxe_bootable_file = {
+ 'fn': 'default',
+ 'addr': 0x10000000,
+ 'size': 74,
+ 'timeout': 50000,
+ 'pattern': 'Linux',
+ 'valid_label': '1',
+ 'invalid_label': '2',
+ 'exp_str_invalid': 'Skipping install for failure retrieving',
+ 'local_label': '3',
+ 'exp_str_local': 'missing environment variable: localcmd',
+ 'empty_label': '4',
+ 'exp_str_empty': 'No kernel given, skipping boot',
+ 'check_type': 'boot_error',
+ 'check_pattern': 'ERROR',
+ }
+
+ # False if a PXE boot test should be tested.
+ # If PXE boot testing is not possible or desired, set this variable to True.
+ # For example: If pxe configuration file is not proper to boot
+ env__pxe_boot_test_skip = False
+
+Here is the example of pxe configuration file ordered based on the execution
+flow:
+
1) /tftpboot/pxelinux.cfg/default-arm-zynqmp
+.. code-block::
+
menu include pxelinux.cfg/default-arm
timeout 50
@@ -91,6 +97,8 @@ env__pxe_boot_test_skip = False
2) /tftpboot/pxelinux.cfg/default-arm
+.. code-block::
+
menu title Linux boot selections
menu include pxelinux.cfg/default
@@ -110,6 +118,8 @@ env__pxe_boot_test_skip = False
3) /tftpboot/pxelinux.cfg/default
+.. code-block::
+
label Linux
menu label Boot kernel
kernel Image
@@ -117,12 +127,27 @@ env__pxe_boot_test_skip = False
initrd rootfs.cpio.gz.u-boot
"""
+import pytest
+import utils
+import test_net
+import re
+
def setup_networking(ubman):
+ """Setup networking
+
+ Making use of the test_net test, first try and configure networking via
+ DHCP. If this fails, fall back to static configuration.
+ """
test_net.test_net_dhcp(ubman)
if not test_net.net_set_up:
test_net.test_net_setup_static(ubman)
def setup_tftpboot_boot(ubman):
+ """Setup for the tftpboot 'boot' test
+
+ We check that a file to use has been configured. If it has, we download it
+ and ensure it has the expected crc32 value.
+ """
f = ubman.config.env.get('env__net_tftp_bootable_file', None)
if not f:
pytest.skip('No TFTP bootable file to read')
@@ -198,6 +223,10 @@ def test_net_tftpboot_boot(ubman):
ubman.cleanup_spawn()
def setup_pxe_boot(ubman):
+ """Setup for the PXE 'boot' test
+
+ Make sure that the file to load via PXE boot has been configured.
+ """
f = ubman.config.env.get('env__net_pxe_bootable_file', None)
if not f:
pytest.skip('No PXE bootable file to read')
diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py
index 064651c3e23..9be85999d46 100644
--- a/test/py/tests/test_tpm2.py
+++ b/test/py/tests/test_tpm2.py
@@ -27,6 +27,16 @@ behavior.
* Setup env__tpm_device_test_skip to True if tests with TPM devices should be
skipped.
+Parallel tests
+--------------
+
+These tests can be run in parallel on sandbox. In that case any action taken
+by one test may be independent of another. For sandbox, care should be taken to
+ensure that tests are independent.
+
+Unfortunately, tests cannot be made independent on real hardware, since there is
+no way to reset the TPM other than restarting the board. Perhaps that would be
+the best approach?
"""
updates = 0
@@ -50,13 +60,8 @@ def force_init(ubman, force=False):
ubman.run_command('tpm2 clear TPM2_RH_PLATFORM')
ubman.run_command('echo --- end of init ---')
-def is_sandbox(ubman):
- # Array slice removes leading/trailing quotes.
- sys_arch = ubman.config.buildconfig.get('config_sys_arch', '"sandbox"')[1:-1]
- return sys_arch == 'sandbox'
-
@pytest.mark.buildconfigspec('cmd_tpm_v2')
-def test_tpm2_init(ubman):
+def test_tpm2_autostart(ubman):
"""Init the software stack to use TPMv2 commands."""
skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
if skip_test:
@@ -66,56 +71,6 @@ def test_tpm2_init(ubman):
assert output.endswith('0')
@pytest.mark.buildconfigspec('cmd_tpm_v2')
-def test_tpm2_startup(ubman):
- """Execute a TPM2_Startup command.
-
- Initiate the TPM internal state machine.
- """
- skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
- if skip_test:
- pytest.skip('skip TPM device test')
- ubman.run_command('tpm2 startup TPM2_SU_CLEAR')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
-def tpm2_sandbox_init(ubman):
- """Put sandbox back into a known state so we can run a test
-
- This allows all tests to run in parallel, since no test depends on another.
- """
- ubman.restart_uboot()
- ubman.run_command('tpm2 autostart')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
- skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
- if skip_test:
- pytest.skip('skip TPM device test')
-
-@pytest.mark.buildconfigspec('cmd_tpm_v2')
-def test_tpm2_sandbox_self_test_full(ubman):
- """Execute a TPM2_SelfTest (full) command.
-
- Ask the TPM to perform all self tests to also enable full capabilities.
- """
- if is_sandbox(ubman):
- ubman.restart_uboot()
- ubman.run_command('tpm2 autostart')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
- ubman.run_command('tpm2 startup TPM2_SU_CLEAR')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
- skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
- if skip_test:
- pytest.skip('skip TPM device test')
- ubman.run_command('tpm2 self_test full')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
-@pytest.mark.buildconfigspec('cmd_tpm_v2')
def test_tpm2_continue_self_test(ubman):
"""Execute a TPM2_SelfTest (continued) command.
@@ -126,8 +81,6 @@ def test_tpm2_continue_self_test(ubman):
skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
if skip_test:
pytest.skip('skip TPM device test')
- if is_sandbox(ubman):
- tpm2_sandbox_init(ubman)
ubman.run_command('tpm2 self_test continue')
output = ubman.run_command('echo $?')
assert output.endswith('0')
@@ -144,9 +97,6 @@ def test_tpm2_clear(ubman):
not have a password set, otherwise this test will fail. ENDORSEMENT and
PLATFORM hierarchies are also available.
"""
- if is_sandbox(ubman):
- tpm2_sandbox_init(ubman)
-
skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
if skip_test:
pytest.skip('skip TPM device test')
@@ -167,8 +117,6 @@ def test_tpm2_change_auth(ubman):
Use the LOCKOUT hierarchy for this. ENDORSEMENT and PLATFORM hierarchies are
also available.
"""
- if is_sandbox(ubman):
- tpm2_sandbox_init(ubman)
force_init(ubman)
ubman.run_command('tpm2 change_auth TPM2_RH_LOCKOUT unicorn')
@@ -193,9 +141,6 @@ def test_tpm2_get_capability(ubman):
There is no expected default values because it would depend on the chip
used. We can still save them in order to check they have changed later.
"""
- if is_sandbox(ubman):
- tpm2_sandbox_init(ubman)
-
force_init(ubman)
ram = utils.find_ram_base(ubman)
@@ -217,8 +162,6 @@ def test_tpm2_dam_parameters(ubman):
the authentication, otherwise the lockout will be engaged after the first
failed authentication attempt.
"""
- if is_sandbox(ubman):
- tpm2_sandbox_init(ubman)
force_init(ubman)
ram = utils.find_ram_base(ubman)
@@ -236,14 +179,12 @@ def test_tpm2_dam_parameters(ubman):
assert 'Property 0x00000211: 0x00000000' in read_cap
@pytest.mark.buildconfigspec('cmd_tpm_v2')
+@pytest.mark.notbuildconfigspec('target_chromebook_coral')
def test_tpm2_pcr_read(ubman):
"""Execute a TPM2_PCR_Read command.
Perform a PCR read of the 10th PCR. Must be zero.
"""
- if is_sandbox(ubman):
- tpm2_sandbox_init(ubman)
-
force_init(ubman)
ram = utils.find_ram_base(ubman)
@@ -261,6 +202,7 @@ def test_tpm2_pcr_read(ubman):
assert '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' in read_pcr
@pytest.mark.buildconfigspec('cmd_tpm_v2')
+@pytest.mark.notbuildconfigspec('target_chromebook_coral')
def test_tpm2_pcr_extend(ubman):
"""Execute a TPM2_PCR_Extend command.
@@ -270,8 +212,6 @@ def test_tpm2_pcr_extend(ubman):
No authentication mechanism is used here, not protecting against packet
replay, yet.
"""
- if is_sandbox(ubman):
- tpm2_sandbox_init(ubman)
force_init(ubman)
ram = utils.find_ram_base(ubman)