summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Kconfig1
-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/cmd/wget.c20
-rw-r--r--test/common/test_autoboot.c1
-rw-r--r--test/dm/Makefile1
-rw-r--r--test/dm/aes.c57
-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/Makefile3
-rw-r--r--test/lib/abuf.c105
-rw-r--r--test/lib/efi_memory.c63
-rw-r--r--test/lib/lmb.c102
-rw-r--r--test/lib/slre.c58
-rw-r--r--test/lib/string.c37
-rw-r--r--test/py/tests/test_efi_selftest.py1
-rw-r--r--test/py/tests/test_fit_mkimage_validate.py58
-rw-r--r--test/py/tests/test_help.py1
-rw-r--r--test/py/tests/test_mmc.py30
-rw-r--r--test/py/tests/test_tpm2.py86
40 files changed, 1003 insertions, 188 deletions
diff --git a/test/Kconfig b/test/Kconfig
index 31016eedbf8..77e7cad3984 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -122,6 +122,7 @@ endif # UNIT_TEST
config POST
bool "Power On Self Test support"
+ depends on ARM || PPC
help
See doc/README.POST for more details
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/cmd/wget.c b/test/cmd/wget.c
index 445750660c2..1005392b952 100644
--- a/test/cmd/wget.c
+++ b/test/cmd/wget.c
@@ -241,3 +241,23 @@ static int net_test_wget(struct unit_test_state *uts)
return 0;
}
CMD_TEST(net_test_wget, UTF_CONSOLE);
+
+static int net_test_wget_uri_validate(struct unit_test_state *uts)
+{
+ ut_asserteq(true, wget_validate_uri("http://foo.com/bar.html"));
+ ut_asserteq(true, wget_validate_uri("http://1.1.2.3/bar.html"));
+ ut_asserteq(false, wget_validate_uri("http://foo/ba r.html"));
+ ut_asserteq(false, wget_validate_uri("http://"));
+
+ if (CONFIG_IS_ENABLED(WGET_HTTPS)) {
+ ut_asserteq(true,
+ wget_validate_uri("https://foo.com/bar.html"));
+ ut_asserteq(true,
+ wget_validate_uri("https://1.1.2.3/bar.html"));
+ ut_asserteq(false, wget_validate_uri("https://foo/ba r.html"));
+ ut_asserteq(false, wget_validate_uri("https://"));
+ }
+
+ return 0;
+}
+CMD_TEST(net_test_wget_uri_validate, UTF_CONSOLE);
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/Makefile b/test/dm/Makefile
index 917dafe7d22..d15859eca30 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -29,6 +29,7 @@ obj-(CONFIG_DM_GPIO) += gpio.o
obj-y += irq.o
endif
obj-$(CONFIG_ADC) += adc.o
+obj-$(CONFIG_AES_SOFTWARE) += aes.o
obj-$(CONFIG_SOUND) += audio.o
obj-$(CONFIG_AXI) += axi.o
obj-$(CONFIG_BLK) += blk.o
diff --git a/test/dm/aes.c b/test/dm/aes.c
new file mode 100644
index 00000000000..702e4db2b35
--- /dev/null
+++ b/test/dm/aes.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for the driver model AES API
+ *
+ * Copyright (c) 2025 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <dm.h>
+#include <dm/test.h>
+#include <uboot_aes.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+#define AES128_KEYSIZE 128
+
+static int dm_test_aes(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+ u8 test_key[AES128_KEY_LENGTH] = { 0x63, 0x68, 0x69, 0x63, 0x6b, 0x65, 0x6e, 0x20,
+ 0x74, 0x65, 0x72, 0x69, 0x79, 0x61, 0x6b, 0x69 };
+ u8 test_iv[AES128_KEY_LENGTH] = { 0 };
+
+ u8 test_input[AES_BLOCK_LENGTH] = { 0x49, 0x20, 0x77, 0x6f, 0x75, 0x6c, 0x64, 0x20,
+ 0x6c, 0x69, 0x6b, 0x65, 0x20, 0x74, 0x68, 0x65 };
+ u8 exp_output[AES_BLOCK_LENGTH] = { 0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
+ 0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84 };
+ u8 exp_cmac[AES_BLOCK_LENGTH] = { 0xfc, 0x89, 0x20, 0xc8, 0x46, 0x97, 0xb1, 0x3d,
+ 0x31, 0x2c, 0xc2, 0x49, 0x5c, 0x5a, 0x0b, 0x9f };
+ u8 test_output[AES_BLOCK_LENGTH];
+
+ ut_assertok(uclass_first_device_err(UCLASS_AES, &dev));
+
+ /* software AES exposes 2 key slots */
+ ut_asserteq(2, dm_aes_get_available_key_slots(dev));
+
+ ut_assertok(dm_aes_select_key_slot(dev, AES128_KEYSIZE, 0));
+ ut_assertok(dm_aes_set_key_for_key_slot(dev, AES128_KEYSIZE, test_key, 0));
+
+ ut_assertok(dm_aes_ecb_encrypt(dev, test_input, test_output, 1));
+ ut_assertok(memcmp(exp_output, test_output, 16));
+
+ ut_assertok(dm_aes_ecb_decrypt(dev, test_output, test_output, 1));
+ ut_assertok(memcmp(test_input, test_output, 16));
+
+ ut_assertok(dm_aes_cbc_encrypt(dev, test_iv, test_input, test_output, 1));
+ ut_assertok(memcmp(exp_output, test_output, 16));
+
+ ut_assertok(dm_aes_cbc_decrypt(dev, test_iv, test_output, test_output, 1));
+ ut_assertok(memcmp(test_input, test_output, 16));
+
+ ut_assertok(dm_aes_cmac(dev, test_input, test_output, 1));
+ ut_assertok(memcmp(exp_cmac, test_output, 16));
+
+ return 0;
+}
+
+DM_TEST(dm_test_aes, UTF_SCAN_FDT);
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..35b40b584c4 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -8,7 +8,7 @@ obj-$(CONFIG_$(PHASE_)UT_COMPRESSION) += compression.o
ifeq ($(CONFIG_XPL_BUILD),)
obj-y += abuf.o
obj-y += alist.o
-obj-$(CONFIG_EFI_LOADER) += efi_device_path.o
+obj-$(CONFIG_EFI_LOADER) += efi_device_path.o efi_memory.o
obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o
obj-y += hexdump.o
obj-$(CONFIG_SANDBOX) += kconfig.o
@@ -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_memory.c b/test/lib/efi_memory.c
new file mode 100644
index 00000000000..d2e1ab6b4a3
--- /dev/null
+++ b/test/lib/efi_memory.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Test memory functions
+ *
+ * Copyright (c) 2025 Heinrich Schuchardt <xypron.glpk@gmx.de>
+ */
+
+#include <efi_loader.h>
+#include <test/lib.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+static int lib_test_efi_alloc_aligned_pages(struct unit_test_state *uts)
+{
+ efi_status_t ret;
+
+ void *addr;
+ unsigned long align = 0x400000;
+
+ addr = efi_alloc_aligned_pages(4096, EFI_PERSISTENT_MEMORY_TYPE,
+ EFI_PAGE_SIZE);
+ ut_asserteq_ptr(NULL, addr);
+
+ addr = efi_alloc_aligned_pages(4096, 0x6FFFFFFF, EFI_PAGE_SIZE);
+ ut_asserteq_ptr(NULL, addr);
+
+ align = 0x200;
+ addr = efi_alloc_aligned_pages(4096, EFI_ACPI_RECLAIM_MEMORY, align);
+ ut_assertnonnull(addr);
+ ut_asserteq_64(0, (uintptr_t)addr & (align - 1));
+
+ ret = efi_free_pages((uintptr_t) addr, 1);
+ ut_asserteq_64(ret, EFI_SUCCESS);
+
+ align = 0x400000;
+ addr = efi_alloc_aligned_pages(4096, EFI_ACPI_RECLAIM_MEMORY, align);
+ ut_assertnonnull(addr);
+ ut_asserteq_64(0, (uintptr_t)addr & (align - 1));
+
+ ret = efi_free_pages((uintptr_t) addr, 1);
+ ut_asserteq_64(ret, EFI_SUCCESS);
+
+ return 0;
+}
+LIB_TEST(lib_test_efi_alloc_aligned_pages, 0);
+
+static int lib_test_efi_allocate_pages(struct unit_test_state *uts)
+{
+ efi_status_t ret;
+ u64 memory;
+
+ ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+ EFI_ACPI_RECLAIM_MEMORY,
+ 1, &memory);
+ ut_asserteq_64(ret, EFI_SUCCESS);
+ ut_asserteq_64(0, memory & EFI_PAGE_MASK);
+
+ ret = efi_free_pages(memory, 1);
+ ut_asserteq_64(ret, EFI_SUCCESS);
+
+ return 0;
+}
+LIB_TEST(lib_test_efi_allocate_pages, 0);
diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index 3bf558f7f4f..b6259bef442 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -71,6 +71,45 @@ static int setup_lmb_test(struct unit_test_state *uts, struct lmb *store,
return 0;
}
+static int lmb_reserve(phys_addr_t addr, phys_size_t size, u32 flags)
+{
+ int err;
+
+ err = lmb_alloc_mem(LMB_MEM_ALLOC_ADDR, 0, &addr, size, flags);
+ if (err)
+ return err;
+
+ return 0;
+}
+
+static phys_addr_t lmb_alloc(phys_size_t size, ulong align)
+{
+ int err;
+ phys_addr_t addr;
+
+ err = lmb_alloc_mem(LMB_MEM_ALLOC_ANY, align, &addr, size, LMB_NONE);
+ if (err)
+ return 0;
+
+ return addr;
+}
+
+static phys_addr_t lmb_alloc_base(phys_size_t size, ulong align,
+ phys_addr_t max_addr, u32 flags)
+{
+ int err;
+ phys_addr_t addr;
+
+ addr = max_addr;
+ err = lmb_alloc_mem(LMB_MEM_ALLOC_MAX, align, &addr, size, flags);
+ if (err)
+ return 0;
+
+ return addr;
+}
+
+#define lmb_alloc_addr(addr, size, flags) lmb_reserve(addr, size, flags)
+
static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram,
const phys_size_t ram_size, const phys_addr_t ram0,
const phys_size_t ram0_size,
@@ -143,7 +182,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram,
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 8, 0, 0);
- ret = lmb_free(a, 4);
+ ret = lmb_free(a, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0);
@@ -152,12 +191,12 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram,
ut_asserteq(a, a2);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 8, 0, 0);
- ret = lmb_free(a2, 4);
+ ret = lmb_free(a2, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0);
- ret = lmb_free(b, 4);
+ ret = lmb_free(b, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 3,
alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000,
@@ -167,17 +206,17 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram,
ut_asserteq(b, b2);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0);
- ret = lmb_free(b2, 4);
+ ret = lmb_free(b2, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 3,
alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000,
ram_end - 8, 4);
- ret = lmb_free(c, 4);
+ ret = lmb_free(c, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000, 0, 0);
- ret = lmb_free(d, 4);
+ ret = lmb_free(d, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 1, alloc_64k_addr, 0x10000,
0, 0, 0, 0);
@@ -281,7 +320,7 @@ static int test_bigblock(struct unit_test_state *uts, const phys_addr_t ram)
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, a,
big_block_size + 0x10000, 0, 0, 0, 0);
- ret = lmb_free(a, big_block_size);
+ ret = lmb_free(a, big_block_size, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, alloc_64k_addr, 0x10000,
0, 0, 0, 0);
@@ -353,12 +392,12 @@ static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram,
- alloc_size_aligned, alloc_size, 0, 0);
}
/* and free them */
- ret = lmb_free(b, alloc_size);
+ ret = lmb_free(b, alloc_size, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1,
ram + ram_size - alloc_size_aligned,
alloc_size, 0, 0, 0, 0);
- ret = lmb_free(a, alloc_size);
+ ret = lmb_free(a, alloc_size, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 0, 0, 0, 0, 0, 0, 0);
@@ -369,7 +408,7 @@ static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram,
ram + ram_size - alloc_size_aligned,
alloc_size, 0, 0, 0, 0);
/* and free it */
- ret = lmb_free(b, alloc_size);
+ ret = lmb_free(b, alloc_size, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 0, 0, 0, 0, 0, 0, 0);
@@ -437,12 +476,12 @@ static int lib_test_lmb_at_0(struct unit_test_state *uts)
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, a, ram_size - 4,
0, 0, 0, 0);
/* check that this was an error by freeing b */
- ret = lmb_free(b, 4);
+ ret = lmb_free(b, 4, LMB_NONE);
ut_asserteq(ret, -1);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, a, ram_size - 4,
0, 0, 0, 0);
- ret = lmb_free(a, ram_size - 4);
+ ret = lmb_free(a, ram_size - 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 0, 0, 0, 0, 0, 0, 0);
@@ -568,20 +607,20 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NONE);
ut_asserteq(b, 0);
b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NOOVERWRITE);
- ut_asserteq(b, -1);
+ ut_asserteq(b, -EEXIST);
b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NONE);
ut_asserteq(b, 0);
b = lmb_alloc_addr(alloc_addr_a, 0x2000, LMB_NONE);
ut_asserteq(b, 0);
- ret = lmb_free(alloc_addr_a, 0x2000);
+ ret = lmb_free(alloc_addr_a, 0x2000, LMB_NONE);
ut_asserteq(ret, 0);
b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NOOVERWRITE);
ut_asserteq(b, 0);
b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NONE);
- ut_asserteq(b, -1);
+ ut_asserteq(b, -EEXIST);
b = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NOOVERWRITE);
- ut_asserteq(b, -1);
- ret = lmb_free(alloc_addr_a, 0x1000);
+ ut_asserteq(b, -EEXIST);
+ ret = lmb_free(alloc_addr_a, 0x1000, LMB_NONE);
ut_asserteq(ret, 0);
/*
@@ -599,13 +638,13 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
alloc_addr_a + 0x4000, 0x1000, 0, 0);
c = lmb_alloc_addr(alloc_addr_a + 0x1000, 0x5000, LMB_NONE);
- ut_asserteq(c, -1);
+ ut_asserteq(c, -EEXIST);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, alloc_addr_a, 0x1000,
alloc_addr_a + 0x4000, 0x1000, 0, 0);
- ret = lmb_free(alloc_addr_a, 0x1000);
+ ret = lmb_free(alloc_addr_a, 0x1000, LMB_NONE);
ut_asserteq(ret, 0);
- ret = lmb_free(alloc_addr_a + 0x4000, 0x1000);
+ ret = lmb_free(alloc_addr_a + 0x4000, 0x1000, LMB_NOOVERWRITE);
ut_asserteq(ret, 0);
/*
@@ -628,7 +667,7 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, alloc_addr_a, 0x6000,
0, 0, 0, 0);
- ret = lmb_free(alloc_addr_a, 0x6000);
+ ret = lmb_free(alloc_addr_a, 0x6000, LMB_NONE);
ut_asserteq(ret, 0);
/*
@@ -646,13 +685,13 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
alloc_addr_a + 0x4000, 0x1000, 0, 0);
c = lmb_alloc_addr(alloc_addr_a + 0x1000, 0x5000, LMB_NOOVERWRITE);
- ut_asserteq(c, -1);
+ ut_asserteq(c, -EEXIST);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, alloc_addr_a, 0x1000,
alloc_addr_a + 0x4000, 0x1000, 0, 0);
- ret = lmb_free(alloc_addr_a, 0x1000);
+ ret = lmb_free(alloc_addr_a, 0x1000, LMB_NOOVERWRITE);
ut_asserteq(ret, 0);
- ret = lmb_free(alloc_addr_a + 0x4000, 0x1000);
+ ret = lmb_free(alloc_addr_a + 0x4000, 0x1000, LMB_NOOVERWRITE);
ut_asserteq(ret, 0);
/* reserve 3 blocks */
@@ -693,7 +732,8 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
0, 0, 0, 0);
/* free thge allocation from d */
- ret = lmb_free(alloc_addr_c + 0x10000, ram_end - alloc_addr_c - 0x10000);
+ ret = lmb_free(alloc_addr_c + 0x10000, ram_end - alloc_addr_c - 0x10000,
+ LMB_NONE);
ut_asserteq(ret, 0);
/* allocate at 3 points in free range */
@@ -702,7 +742,7 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
ut_asserteq(d, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, ram, 0x18010000,
ram_end - 4, 4, 0, 0);
- ret = lmb_free(ram_end - 4, 4);
+ ret = lmb_free(ram_end - 4, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, 0x18010000,
0, 0, 0, 0);
@@ -711,7 +751,7 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
ut_asserteq(d, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, ram, 0x18010000,
ram_end - 128, 4, 0, 0);
- ret = lmb_free(ram_end - 128, 4);
+ ret = lmb_free(ram_end - 128, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, 0x18010000,
0, 0, 0, 0);
@@ -720,13 +760,13 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
ut_asserteq(d, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, 0x18010004,
0, 0, 0, 0);
- ret = lmb_free(alloc_addr_c + 0x10000, 4);
+ ret = lmb_free(alloc_addr_c + 0x10000, 4, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram, 0x18010000,
0, 0, 0, 0);
/* allocate at the bottom a was assigned to ram at the top */
- ret = lmb_free(ram, alloc_addr_a - ram);
+ ret = lmb_free(ram, alloc_addr_a - ram, LMB_NONE);
ut_asserteq(ret, 0);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, ram + 0x8000000,
0x10010000, 0, 0, 0, 0);
@@ -739,11 +779,11 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
/* check that allocating outside memory fails */
if (ram_end != 0) {
ret = lmb_alloc_addr(ram_end, 1, LMB_NONE);
- ut_asserteq(ret, -1);
+ ut_asserteq(ret, -EINVAL);
}
if (ram != 0) {
ret = lmb_alloc_addr(ram - 1, 1, LMB_NONE);
- ut_asserteq(ret, -1);
+ ut_asserteq(ret, -EINVAL);
}
lmb_pop(&store);
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/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py
index 12cbe5caa9b..58dac72fd40 100644
--- a/test/py/tests/test_efi_selftest.py
+++ b/test/py/tests/test_efi_selftest.py
@@ -179,6 +179,7 @@ def test_efi_selftest_text_input_ex(ubman):
@pytest.mark.buildconfigspec('cmd_bootefi_selftest')
@pytest.mark.buildconfigspec('efi_tcg2_protocol')
+@pytest.mark.notbuildconfigspec('sandbox')
def test_efi_selftest_tcg2(ubman):
"""Test the EFI_TCG2 PROTOCOL
diff --git a/test/py/tests/test_fit_mkimage_validate.py b/test/py/tests/test_fit_mkimage_validate.py
new file mode 100644
index 00000000000..af56f08ca10
--- /dev/null
+++ b/test/py/tests/test_fit_mkimage_validate.py
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2025
+#
+# Test that mkimage validates image references in configurations
+
+import os
+import subprocess
+import pytest
+import fit_util
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.requiredtool('dtc')
+def test_fit_invalid_image_reference(ubman):
+ """Test that mkimage fails when configuration references a missing image"""
+
+ its_fname = fit_util.make_fname(ubman, "invalid.its")
+ itb_fname = fit_util.make_fname(ubman, "invalid.itb")
+ kernel = fit_util.make_kernel(ubman, 'kernel.bin', 'kernel')
+
+ # Write ITS with an invalid reference to a nonexistent image
+ its_text = '''
+/dts-v1/;
+
+/ {
+ images {
+ kernel@1 {
+ description = "Test Kernel";
+ data = /incbin/("kernel.bin");
+ type = "kernel";
+ arch = "sandbox";
+ os = "linux";
+ compression = "none";
+ load = <0x40000>;
+ entry = <0x40000>;
+ };
+ };
+
+ configurations {
+ default = "conf@1";
+ conf@1 {
+ kernel = "kernel@1";
+ fdt = "notexist";
+ };
+ };
+};
+'''
+
+ with open(its_fname, 'w') as f:
+ f.write(its_text)
+
+ mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage')
+ cmd = [mkimage, '-f', its_fname, itb_fname]
+
+ result = subprocess.run(cmd, capture_output=True, text=True)
+
+ assert result.returncode != 0, "mkimage should fail due to missing image reference"
+ assert "references undefined image 'notexist'" in result.stderr
+
diff --git a/test/py/tests/test_help.py b/test/py/tests/test_help.py
index 12cb36b7b98..afb57201ba3 100644
--- a/test/py/tests/test_help.py
+++ b/test/py/tests/test_help.py
@@ -4,6 +4,7 @@
import pytest
+@pytest.mark.buildconfigspec('cmd_help')
def test_help(ubman):
"""Test that the "help" command can be executed."""
diff --git a/test/py/tests/test_mmc.py b/test/py/tests/test_mmc.py
index e751a3bd36a..1f738ef3dcb 100644
--- a/test/py/tests/test_mmc.py
+++ b/test/py/tests/test_mmc.py
@@ -99,7 +99,7 @@ def test_mmc_dev(ubman):
devices[x]['detected'] = 'yes'
for y in mmc_modes:
- output = ubman.run_command('mmc dev %d 0 %d' % x, y)
+ output = ubman.run_command('mmc dev %d 0 %d' % (x, y))
if 'Card did not respond to voltage select' in output:
fail = 1
@@ -122,7 +122,7 @@ def test_mmcinfo(ubman):
for x in range(0, controllers):
if devices[x]['detected'] == 'yes':
for y in mmc_modes:
- ubman.run_command('mmc dev %d 0 %d' % x, y)
+ ubman.run_command('mmc dev %d 0 %d' % (x, y))
output = ubman.run_command('mmcinfo')
if 'busy timeout' in output:
pytest.skip('No SD/MMC/eMMC device present')
@@ -146,7 +146,7 @@ def test_mmc_info(ubman):
for x in range(0, controllers):
if devices[x]['detected'] == 'yes':
for y in mmc_modes:
- ubman.run_command('mmc dev %d 0 %d' % x, y)
+ ubman.run_command('mmc dev %d 0 %d' % (x, y))
output = ubman.run_command('mmc info')
assert mmc_modes_name[mmc_modes.index(y)] in output
@@ -172,7 +172,7 @@ def test_mmc_rescan(ubman):
for x in range(0, controllers):
if devices[x]['detected'] == 'yes':
for y in mmc_modes:
- ubman.run_command('mmc dev %d 0 %d' % x, y)
+ ubman.run_command('mmc dev %d 0 %d' % (x, y))
output = ubman.run_command('mmc rescan')
if output:
pytest.fail('mmc rescan has something to check')
@@ -210,7 +210,7 @@ def test_mmc_part(ubman):
elif part_type == '83':
print('ext(2/4) detected')
output = ubman.run_command(
- 'fstype mmc %d:%d' % x, part_id
+ 'fstype mmc %d:%d' % (x, part_id)
)
if 'ext2' in output:
part_ext2.append(part_id)
@@ -246,7 +246,7 @@ def test_mmc_fatls_fatinfo(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
output = ubman.run_command(
'fatls mmc %d:%s' % (x, part))
if 'Unrecognized filesystem type' in output:
@@ -288,7 +288,7 @@ def test_mmc_fatload_fatwrite(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
part_detect = 1
addr = utils.find_ram_base(ubman)
devices[x]['addr_%d' % part] = addr
@@ -357,7 +357,7 @@ def test_mmc_ext4ls(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
output = ubman.run_command(
'%sls mmc %d:%s' % (fs, x, part)
)
@@ -392,7 +392,7 @@ def test_mmc_ext4load_ext4write(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
part_detect = 1
addr = utils.find_ram_base(ubman)
devices[x]['addr_%d' % part] = addr
@@ -454,7 +454,7 @@ def test_mmc_ext2ls(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
part_detect = 1
output = ubman.run_command(
'%sls mmc %d:%s' % (fs, x, part)
@@ -491,7 +491,7 @@ def test_mmc_ext2load(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
part_detect = 1
addr = devices[x]['addr_%d' % part]
size = devices[x]['size_%d' % part]
@@ -534,7 +534,7 @@ def test_mmc_ls(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
part_detect = 1
output = ubman.run_command('ls mmc %d:%s' % (x, part))
if re.search(r'No \w+ table on this device', output):
@@ -566,7 +566,7 @@ def test_mmc_load(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
part_detect = 1
addr = devices[x]['addr_%d' % part]
size = devices[x]['size_%d' % part]
@@ -609,7 +609,7 @@ def test_mmc_save(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
part_detect = 1
addr = devices[x]['addr_%d' % part]
size = 0
@@ -656,7 +656,7 @@ def test_mmc_fat_read_write_files(ubman):
for part in partitions:
for y in mmc_modes:
- ubman.run_command('mmc dev %d %d %d' % x, part, y)
+ ubman.run_command('mmc dev %d %d %d' % (x, part, y))
part_detect = 1
addr = utils.find_ram_base(ubman)
count_f = 0
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)