summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/boot/bootdev.c11
-rw-r--r--test/boot/bootflow.c2
-rw-r--r--test/cmd/Makefile1
-rw-r--r--test/cmd/command.c31
-rw-r--r--test/cmd/spawn.c32
-rw-r--r--test/common/print.c8
-rw-r--r--test/dm/Makefile2
-rw-r--r--test/dm/dsa.c8
-rw-r--r--test/dm/eth.c77
-rw-r--r--test/dm/power-domain.c2
-rw-r--r--test/lib/Makefile2
-rw-r--r--test/lib/initjmp.c73
-rw-r--r--test/lib/uthread.c146
-rw-r--r--test/py/tests/test_fs/conftest.py2
-rw-r--r--test/py/tests/test_fs/test_basic.py13
-rw-r--r--test/py/tests/test_spi.py29
-rw-r--r--test/py/tests/test_trace.py8
17 files changed, 374 insertions, 73 deletions
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index d5499918249..9af94786870 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -392,8 +392,7 @@ static int bootdev_test_hunter(struct unit_test_state *uts)
ut_assert_console_end();
ut_assertok(bootdev_hunt("usb1", false));
- ut_assert_nextline(
- "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found");
+ ut_assert_skip_to_line("Bus usb@1: 5 USB Device(s) found");
ut_assert_console_end();
/* USB is 7th in the list, so bit 8 */
@@ -448,8 +447,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
ut_assert_nextline("scanning bus for devices...");
ut_assert_skip_to_line("Hunting with: spi_flash");
ut_assert_nextline("Hunting with: usb");
- ut_assert_nextline(
- "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found");
+ ut_assert_skip_to_line("Bus usb@1: 5 USB Device(s) found");
ut_assert_nextline("Hunting with: virtio");
ut_assert_console_end();
@@ -551,8 +549,7 @@ static int bootdev_test_hunt_prio(struct unit_test_state *uts)
ut_assertok(bootdev_hunt_prio(BOOTDEVP_5_SCAN_SLOW, true));
ut_assert_nextline("Hunting with: ide");
ut_assert_nextline("Hunting with: usb");
- ut_assert_nextline(
- "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found");
+ ut_assert_skip_to_line("Bus usb@1: 5 USB Device(s) found");
ut_assert_console_end();
return 0;
@@ -604,7 +601,7 @@ static int bootdev_test_hunt_label(struct unit_test_state *uts)
ut_assertnonnull(dev);
ut_asserteq_str("usb_mass_storage.lun0.bootdev", dev->name);
ut_asserteq(BOOTFLOW_METHF_SINGLE_UCLASS, mflags);
- ut_assert_nextlinen("Bus usb@1: scanning bus usb@1");
+ ut_assert_nextline("Bus usb@1: 5 USB Device(s) found");
ut_assert_console_end();
return 0;
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 5f9c037ff53..b261bd5f620 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -1290,7 +1290,7 @@ static int bootflow_efi(struct unit_test_state *uts)
ut_assertok(run_command("bootflow scan", 0));
ut_assert_skip_to_line(
- "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found");
+ "Bus usb@1: 5 USB Device(s) found");
ut_assertok(run_command("bootflow list", 0));
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 8596c5ad753..595e4cfcada 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -39,3 +39,4 @@ obj-$(CONFIG_CMD_WGET) += wget.o
endif
obj-$(CONFIG_ARM_FFA_TRANSPORT) += armffa.o
endif
+obj-$(CONFIG_CMD_SPAWN) += spawn.o
diff --git a/test/cmd/command.c b/test/cmd/command.c
index 5ec93d490ba..5b1e5a77e5d 100644
--- a/test/cmd/command.c
+++ b/test/cmd/command.c
@@ -45,31 +45,32 @@ static int command_test(struct unit_test_state *uts)
"setenv list ${list}3", strlen("setenv list 1"), 0);
ut_assert(!strcmp("1", env_get("list")));
- ut_asserteq(1, run_command("false", 0));
ut_assertok(run_command("echo", 0));
- ut_asserteq(1, run_command_list("false", -1, 0));
ut_assertok(run_command_list("echo", -1, 0));
-#ifdef CONFIG_HUSH_PARSER
- run_command("setenv foo 'setenv black 1\nsetenv adder 2'", 0);
- run_command("run foo", 0);
- ut_assertnonnull(env_get("black"));
- ut_asserteq(0, strcmp("1", env_get("black")));
- ut_assertnonnull(env_get("adder"));
- ut_asserteq(0, strcmp("2", env_get("adder")));
-#endif
-
- ut_assertok(run_command("", 0));
- ut_assertok(run_command(" ", 0));
+ if (IS_ENABLED(CONFIG_HUSH_PARSER)) {
+ ut_asserteq(1, run_command("false", 0));
+ ut_asserteq(1, run_command_list("false", -1, 0));
+ run_command("setenv foo 'setenv black 1\nsetenv adder 2'", 0);
+ run_command("run foo", 0);
+ ut_assertnonnull(env_get("black"));
+ ut_asserteq(0, strcmp("1", env_get("black")));
+ ut_assertnonnull(env_get("adder"));
+ ut_asserteq(0, strcmp("2", env_get("adder")));
+ ut_assertok(run_command("", 0));
+ ut_assertok(run_command(" ", 0));
+ }
ut_asserteq(1, run_command("'", 0));
/* Variadic function test-cases */
+ if (IS_ENABLED(CONFIG_HUSH_PARSER)) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-zero-length"
- ut_assertok(run_commandf(""));
+ ut_assertok(run_commandf(""));
#pragma GCC diagnostic pop
- ut_assertok(run_commandf(" "));
+ ut_assertok(run_commandf(" "));
+ }
ut_asserteq(1, run_commandf("'"));
ut_assertok(run_commandf("env %s %s", "delete -f", "list"));
diff --git a/test/cmd/spawn.c b/test/cmd/spawn.c
new file mode 100644
index 00000000000..8f48f5ee25c
--- /dev/null
+++ b/test/cmd/spawn.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Tests for spawn and wait commands
+ *
+ * Copyright 2025, Linaro Ltd.
+ */
+
+#include <command.h>
+#include <test/cmd.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+static int test_cmd_spawn(struct unit_test_state *uts)
+{
+ ut_assertok(run_command("wait; spawn sleep 2; setenv j ${job_id}; "
+ "spawn setenv spawned true; "
+ "setenv jj ${job_id}; wait; "
+ "echo ${j} ${jj} ${spawned}", 0));
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+ ut_asserteq_ptr(uts->actual_str,
+ strstr(uts->actual_str, "1 2 true"));
+
+ ut_assertok(run_command("spawn true; wait; setenv t $?; spawn false; "
+ "wait; setenv f $?; wait; echo $t $f $?", 0));
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+ ut_asserteq_ptr(uts->actual_str,
+ strstr(uts->actual_str, "0 1 0"));
+ ut_assert_console_end();
+
+ return 0;
+}
+CMD_TEST(test_cmd_spawn, UTF_CONSOLE);
diff --git a/test/common/print.c b/test/common/print.c
index e3711b10809..c48efc2783f 100644
--- a/test/common/print.c
+++ b/test/common/print.c
@@ -45,11 +45,11 @@ static int print_guid(struct unit_test_state *uts)
sprintf(str, "%pUL", guid);
ut_asserteq_str("04030201-0605-0807-090A-0B0C0D0E0F10", str);
sprintf(str, "%pUs", guid_esp);
- if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { /* brace needed */
- ut_asserteq_str("system", str);
- } else {
+ if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) ||
+ IS_ENABLED(CONFIG_CMD_EFIDEBUG) || IS_ENABLED(CONFIG_EFI))
+ ut_asserteq_str("EFI System Partition", str);
+ else
ut_asserteq_str("c12a7328-f81f-11d2-ba4b-00a0c93ec93b", str);
- }
ret = snprintf(str, 4, "%pUL", guid);
ut_asserteq(0, str[3]);
ut_asserteq(36, ret);
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 3afcc26ca57..917dafe7d22 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -46,9 +46,7 @@ obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o
obj-$(CONFIG_DM_DSA) += dsa.o
obj-$(CONFIG_ECDSA_VERIFY) += ecdsa.o
obj-$(CONFIG_EFI_MEDIA_SANDBOX) += efi_media.o
-ifdef CONFIG_NET
obj-$(CONFIG_DM_ETH) += eth.o
-endif
obj-$(CONFIG_EXTCON) += extcon.o
ifneq ($(CONFIG_EFI_PARTITION),)
obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o
diff --git a/test/dm/dsa.c b/test/dm/dsa.c
index c6b4e12a758..9a31ae39d95 100644
--- a/test/dm/dsa.c
+++ b/test/dm/dsa.c
@@ -63,15 +63,15 @@ DM_TEST(dm_test_dsa_probe, UTF_SCAN_FDT);
*/
static int dm_test_dsa(struct unit_test_state *uts)
{
- net_ping_ip = string_to_ip("1.2.3.5");
+ char *argv[] = { "ping", "1.1.2.2" };
env_set("ethact", "eth2");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
env_set("ethact", "lan0");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
env_set("ethact", "lan1");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
env_set("ethact", "");
diff --git a/test/dm/eth.c b/test/dm/eth.c
index 467495863e1..1087ae9572d 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -171,18 +171,18 @@ DM_TEST(dm_test_ip6_make_lladdr, UTF_SCAN_FDT);
static int dm_test_eth(struct unit_test_state *uts)
{
- net_ping_ip = string_to_ip("1.1.2.2");
+ char *argv[] = { "ping", "1.1.2.2" };
env_set("ethact", "eth@10002000");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10002000", env_get("ethact"));
env_set("ethact", "eth@10003000");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10003000", env_get("ethact"));
env_set("ethact", "eth@10004000");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10004000", env_get("ethact"));
return 0;
@@ -191,22 +191,23 @@ DM_TEST(dm_test_eth, UTF_SCAN_FDT);
static int dm_test_eth_alias(struct unit_test_state *uts)
{
- net_ping_ip = string_to_ip("1.1.2.2");
+ char *argv[] = { "ping", "1.1.2.2" };
+
env_set("ethact", "eth0");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10002000", env_get("ethact"));
env_set("ethact", "eth6");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10004000", env_get("ethact"));
/* Expected to fail since eth1 is not defined in the device tree */
env_set("ethact", "eth1");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10002000", env_get("ethact"));
env_set("ethact", "eth5");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10003000", env_get("ethact"));
return 0;
@@ -215,18 +216,18 @@ DM_TEST(dm_test_eth_alias, UTF_SCAN_FDT);
static int dm_test_eth_prime(struct unit_test_state *uts)
{
- net_ping_ip = string_to_ip("1.1.2.2");
+ char *argv[] = { "ping", "1.1.2.2" };
/* Expected to be "eth@10003000" because of ethprime variable */
env_set("ethact", NULL);
env_set("ethprime", "eth5");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10003000", env_get("ethact"));
/* Expected to be "eth@10002000" because it is first */
env_set("ethact", NULL);
env_set("ethprime", NULL);
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10002000", env_get("ethact"));
return 0;
@@ -249,6 +250,7 @@ DM_TEST(dm_test_eth_prime, UTF_SCAN_FDT);
*/
static int dm_test_eth_act(struct unit_test_state *uts)
{
+ char *argv[] = { "ping", "1.1.2.2" };
struct udevice *dev[DM_TEST_ETH_NUM];
const char *ethname[DM_TEST_ETH_NUM] = {"eth@10002000", "eth@10003000",
"sbe5", "eth@10004000"};
@@ -258,7 +260,6 @@ static int dm_test_eth_act(struct unit_test_state *uts)
int i;
memset(ethaddr, '\0', sizeof(ethaddr));
- net_ping_ip = string_to_ip("1.1.2.2");
/* Prepare the test scenario */
for (i = 0; i < DM_TEST_ETH_NUM; i++) {
@@ -281,7 +282,7 @@ static int dm_test_eth_act(struct unit_test_state *uts)
env_set("ethact", ethname[0]);
/* Segment fault might happen if something is wrong */
- ut_asserteq(-ENODEV, net_loop(PING));
+ ut_asserteq(CMD_RET_FAILURE, do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
for (i = 0; i < DM_TEST_ETH_NUM; i++) {
/* Restore the env */
@@ -334,15 +335,17 @@ DM_TEST(dm_test_ethaddr, UTF_SCAN_FDT);
/* The asserts include a return on fail; cleanup in the caller */
static int _dm_test_eth_rotate1(struct unit_test_state *uts)
{
+ char *argv[] = { "ping", "1.1.2.2" };
+
/* Make sure that the default is to rotate to the next interface */
env_set("ethact", "eth@10004000");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10002000", env_get("ethact"));
/* If ethrotate is no, then we should fail on a bad MAC */
env_set("ethact", "eth@10004000");
env_set("ethrotate", "no");
- ut_asserteq(-EINVAL, net_loop(PING));
+ ut_asserteq(CMD_RET_FAILURE, do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10004000", env_get("ethact"));
return 0;
@@ -350,14 +353,16 @@ static int _dm_test_eth_rotate1(struct unit_test_state *uts)
static int _dm_test_eth_rotate2(struct unit_test_state *uts)
{
+ char *argv[] = { "ping", "1.1.2.2" };
+
/* Make sure we can skip invalid devices */
env_set("ethact", "eth@10004000");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("eth@10004000", env_get("ethact"));
/* Make sure we can handle device name which is not eth# */
env_set("ethact", "sbe5");
- ut_assertok(net_loop(PING));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
ut_asserteq_str("sbe5", env_get("ethact"));
return 0;
@@ -368,9 +373,6 @@ static int dm_test_eth_rotate(struct unit_test_state *uts)
char ethaddr[18];
int retval;
- /* Set target IP to mock ping */
- net_ping_ip = string_to_ip("1.1.2.2");
-
/* Invalidate eth1's MAC address */
memset(ethaddr, '\0', sizeof(ethaddr));
strncpy(ethaddr, env_get("eth6addr"), 17);
@@ -396,6 +398,7 @@ static int dm_test_eth_rotate(struct unit_test_state *uts)
/* Restore the env */
env_set("ethaddr", ethaddr);
}
+
/* Restore the env */
env_set(".flags", NULL);
@@ -406,26 +409,28 @@ DM_TEST(dm_test_eth_rotate, UTF_SCAN_FDT);
/* The asserts include a return on fail; cleanup in the caller */
static int _dm_test_net_retry(struct unit_test_state *uts)
{
+ char *argv[] = { "ping", "1.1.2.2" };
+
/*
- * eth1 is disabled and netretry is yes, so the ping should succeed and
- * the active device should be eth0
+ * eth0 is disabled and netretry is yes, so the ping should succeed and
+ * the active device should be eth1
*/
- sandbox_eth_disable_response(1, true);
- env_set("ethact", "lan1");
+ sandbox_eth_disable_response(0, true);
+ env_set("ethact", "eth@10002000");
env_set("netretry", "yes");
sandbox_eth_skip_timeout();
- ut_assertok(net_loop(PING));
- ut_asserteq_str("eth@10002000", env_get("ethact"));
+ ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
+ ut_asserteq_str("eth@10003000", env_get("ethact"));
/*
- * eth1 is disabled and netretry is no, so the ping should fail and the
- * active device should be eth1
+ * eth0 is disabled and netretry is no, so the ping should fail and the
+ * active device should be eth0
*/
- env_set("ethact", "lan1");
+ env_set("ethact", "eth@10002000");
env_set("netretry", "no");
sandbox_eth_skip_timeout();
- ut_asserteq(-ENONET, net_loop(PING));
- ut_asserteq_str("lan1", env_get("ethact"));
+ ut_asserteq(CMD_RET_FAILURE, do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
+ ut_asserteq_str("eth@10002000", env_get("ethact"));
return 0;
}
@@ -434,8 +439,6 @@ static int dm_test_net_retry(struct unit_test_state *uts)
{
int retval;
- net_ping_ip = string_to_ip("1.1.2.2");
-
retval = _dm_test_net_retry(uts);
/* Restore the env */
@@ -446,6 +449,7 @@ static int dm_test_net_retry(struct unit_test_state *uts)
}
DM_TEST(dm_test_net_retry, UTF_SCAN_FDT);
+#if CONFIG_IS_ENABLED(NET)
static int sb_check_arp_reply(struct udevice *dev, void *packet,
unsigned int len)
{
@@ -511,7 +515,9 @@ static int sb_with_async_arp_handler(struct udevice *dev, void *packet,
return sb_check_arp_reply(dev, packet, len);
}
+#endif
+#if CONFIG_IS_ENABLED(NET)
static int dm_test_eth_async_arp_reply(struct unit_test_state *uts)
{
net_ping_ip = string_to_ip("1.1.2.2");
@@ -529,7 +535,9 @@ static int dm_test_eth_async_arp_reply(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_eth_async_arp_reply, UTF_SCAN_FDT);
+#endif
+#if CONFIG_IS_ENABLED(NET)
static int sb_check_ping_reply(struct udevice *dev, void *packet,
unsigned int len)
{
@@ -613,6 +621,7 @@ static int dm_test_eth_async_ping_reply(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_eth_async_ping_reply, UTF_SCAN_FDT);
+#endif
#if IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY)
diff --git a/test/dm/power-domain.c b/test/dm/power-domain.c
index 8a95f6bdb90..896cf5b2ae9 100644
--- a/test/dm/power-domain.c
+++ b/test/dm/power-domain.c
@@ -27,7 +27,7 @@ static int dm_test_power_domain(struct unit_test_state *uts)
ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "power-domain-test",
&dev_test));
- ut_asserteq(0, sandbox_power_domain_query(dev_power_domain,
+ ut_asserteq(1, sandbox_power_domain_query(dev_power_domain,
TEST_POWER_DOMAIN));
ut_assertok(sandbox_power_domain_test_get(dev_test));
diff --git a/test/lib/Makefile b/test/lib/Makefile
index 97ab71ba5d1..d620510f998 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_SANDBOX) += kconfig.o
obj-y += lmb.o
obj-$(CONFIG_HAVE_SETJMP) += longjmp.o
obj-$(CONFIG_SANDBOX) += membuf.o
+obj-$(CONFIG_HAVE_INITJMP) += initjmp.o
obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
obj-$(CONFIG_SSCANF) += sscanf.o
obj-$(CONFIG_$(PHASE_)STRTO) += str.o
@@ -31,6 +32,7 @@ obj-$(CONFIG_CRC8) += test_crc8.o
obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o
obj-$(CONFIG_UT_TIME) += time.o
obj-$(CONFIG_$(PHASE_)UT_UNICODE) += unicode.o
+obj-$(CONFIG_UTHREAD) += uthread.o
obj-$(CONFIG_LIB_UUID) += uuid.o
else
obj-$(CONFIG_SANDBOX) += kconfig_spl.o
diff --git a/test/lib/initjmp.c b/test/lib/initjmp.c
new file mode 100644
index 00000000000..5b4b50b3f0f
--- /dev/null
+++ b/test/lib/initjmp.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2025 Linaro Limited
+ *
+ * Unit test for initjmp()
+ */
+
+#include <compiler.h>
+#include <setjmp.h>
+#include <stdbool.h>
+#include <test/lib.h>
+#include <test/ut.h>
+#include <vsprintf.h>
+
+static bool ep_entered;
+static jmp_buf return_buf;
+
+static void __noreturn entrypoint(void)
+{
+ ep_entered = true;
+
+ /* Jump back to the main routine */
+ longjmp(return_buf, 1);
+
+ /* Not reached */
+ panic("longjmp failed\n");
+}
+
+static int lib_initjmp(struct unit_test_state *uts)
+{
+ int ret;
+ void *stack;
+ jmp_buf buf;
+ /* Arbitrary but smaller values (< page size?) fail on SANDBOX */
+ size_t stack_sz = 8192;
+
+ (void)entrypoint;
+
+ ep_entered = false;
+
+ stack = malloc(stack_sz);
+ ut_assertnonnull(stack);
+
+ /*
+ * Prepare return_buf so that entrypoint may jump back just after the
+ * if()
+ */
+ if (!setjmp(return_buf)) {
+ /* return_buf initialized, entrypoint not yet called */
+
+ /*
+ * Prepare another jump buffer to jump into entrypoint with the
+ * given stack
+ */
+ ret = initjmp(buf, entrypoint, stack, stack_sz);
+ ut_assertok(ret);
+
+ /* Jump into entrypoint */
+ longjmp(buf, 1);
+ /*
+ * Not reached since entrypoint is expected to branch after
+ * the if()
+ */
+ ut_assert(false);
+ }
+
+ ut_assert(ep_entered);
+
+ free(stack);
+
+ return 0;
+}
+LIB_TEST(lib_initjmp, 0);
diff --git a/test/lib/uthread.c b/test/lib/uthread.c
new file mode 100644
index 00000000000..10a94d1c560
--- /dev/null
+++ b/test/lib/uthread.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 Linaro Limited
+ *
+ * Unit test for uthread
+ */
+
+#include <stdbool.h>
+#include <test/lib.h>
+#include <test/ut.h>
+#include <uthread.h>
+
+static int count;
+
+/* A thread entry point */
+static void worker(void *arg)
+{
+ int loops = (int)(unsigned long)arg;
+ int i;
+
+ for (i = 0; i < loops; i++) {
+ count++;
+ uthread_schedule();
+ }
+}
+
+/*
+ * uthread() - testing the uthread API
+ *
+ * This function creates two threads with the same entry point. The first one
+ * receives 5 as an argument, the second one receives 10. The number indicates
+ * the number of time the worker thread should loop on uthread_schedule()
+ * before returning. The workers increment a global counter each time they loop.
+ * As a result the main thread knows how many times it should call
+ * uthread_schedule() to let the two threads proceed, and it also knows which
+ * value the counter should have at any moment.
+ */
+static int uthread(struct unit_test_state *uts)
+{
+ int i;
+ int id1, id2;
+
+ count = 0;
+ id1 = uthread_grp_new_id();
+ ut_assert(id1 != 0);
+ id2 = uthread_grp_new_id();
+ ut_assert(id2 != 0);
+ ut_assert(id1 != id2);
+ ut_assertok(uthread_create(NULL, worker, (void *)5, 0, id1));
+ ut_assertok(uthread_create(NULL, worker, (void *)10, 0, 0));
+ /*
+ * The first call is expected to schedule the first worker, which will
+ * schedule the second one, which will schedule back to the main thread
+ * (here). Therefore count should be 2.
+ */
+ ut_assert(uthread_schedule());
+ ut_asserteq(2, count);
+ ut_assert(!uthread_grp_done(id1));
+ /* Four more calls should bring the count to 10 */
+ for (i = 0; i < 4; i++) {
+ ut_assert(!uthread_grp_done(id1));
+ ut_assert(uthread_schedule());
+ }
+ ut_asserteq(10, count);
+ /* This one allows the first worker to exit */
+ ut_assert(uthread_schedule());
+ /* At this point there should be no runnable thread in group 'id1' */
+ ut_assert(uthread_grp_done(id1));
+ /* Five more calls for the second worker to finish incrementing */
+ for (i = 0; i < 5; i++)
+ ut_assert(uthread_schedule());
+ ut_asserteq(15, count);
+ /* Plus one call to let the second worker return from its entry point */
+ ut_assert(uthread_schedule());
+ /* Now both tasks should be done, schedule should return false */
+ ut_assert(!uthread_schedule());
+
+ return 0;
+}
+LIB_TEST(uthread, 0);
+
+struct mw_args {
+ struct unit_test_state *uts;
+ struct uthread_mutex *m;
+ int flag;
+};
+
+static int mutex_worker_ret;
+
+static int _mutex_worker(struct mw_args *args)
+{
+ struct unit_test_state *uts = args->uts;
+
+ ut_asserteq(-EBUSY, uthread_mutex_trylock(args->m));
+ ut_assertok(uthread_mutex_lock(args->m));
+ args->flag = 1;
+ ut_assertok(uthread_mutex_unlock(args->m));
+
+ return 0;
+}
+
+static void mutex_worker(void *arg)
+{
+ mutex_worker_ret = _mutex_worker((struct mw_args *)arg);
+}
+
+/*
+ * thread_mutex() - testing uthread mutex operations
+ *
+ */
+static int uthread_mutex(struct unit_test_state *uts)
+{
+ struct uthread_mutex m = UTHREAD_MUTEX_INITIALIZER;
+ struct mw_args args = { .uts = uts, .m = &m, .flag = 0 };
+ int id;
+ int i;
+
+ id = uthread_grp_new_id();
+ ut_assert(id != 0);
+ /* Take the mutex */
+ ut_assertok(uthread_mutex_lock(&m));
+ /* Start a thread */
+ ut_assertok(uthread_create(NULL, mutex_worker, (void *)&args, 0,
+ id));
+ /* Let the thread run for a bit */
+ for (i = 0; i < 100; i++)
+ ut_assert(uthread_schedule());
+ /* Thread should not have set the flag due to the mutex */
+ ut_asserteq(0, args.flag);
+ /* Release the mutex */
+ ut_assertok(uthread_mutex_unlock(&m));
+ /* Schedule the thread until it is done */
+ while (uthread_schedule())
+ ;
+ /* Now the flag should be set */
+ ut_asserteq(1, args.flag);
+ /* And the mutex should be available */
+ ut_assertok(uthread_mutex_trylock(&m));
+ ut_assertok(uthread_mutex_unlock(&m));
+
+ /* Of course no error are expected from the thread routine */
+ ut_assertok(mutex_worker_ret);
+
+ return 0;
+}
+LIB_TEST(uthread_mutex, 0);
diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py
index c73fb4abbcb..0205048e73a 100644
--- a/test/py/tests/test_fs/conftest.py
+++ b/test/py/tests/test_fs/conftest.py
@@ -17,7 +17,7 @@ supported_fs_fat = ['fat12', 'fat16']
supported_fs_mkdir = ['fat12', 'fat16', 'fat32', 'exfat', 'fs_generic']
supported_fs_unlink = ['fat12', 'fat16', 'fat32', 'exfat', 'fs_generic']
supported_fs_symlink = ['ext4']
-supported_fs_rename = ['fat12', 'fat16', 'fat32']
+supported_fs_rename = ['fat12', 'fat16', 'fat32', 'exfat', 'fs_generic']
#
# Filesystem test specific setup
diff --git a/test/py/tests/test_fs/test_basic.py b/test/py/tests/test_fs/test_basic.py
index 64a3b50f52a..88b163ce305 100644
--- a/test/py/tests/test_fs/test_basic.py
+++ b/test/py/tests/test_fs/test_basic.py
@@ -35,6 +35,19 @@ class TestFsBasic(object):
'%sls host 0:0 invalid_d' % fs_cmd_prefix)
assert('' == output)
+ with ubman.log.section('Test Case 1c - test -e'):
+ # Test Case 1 - test -e
+ output = ubman.run_command_list([
+ 'host bind 0 %s' % fs_img,
+ 'test -e host 0:0 1MB.file && echo PASS'])
+ assert('PASS' in ''.join(output))
+
+ with ubman.log.section('Test Case 1d - test -e (invalid file)'):
+ # In addition, test with a nonexistent file to see if we crash.
+ output = ubman.run_command(
+ 'test -e host 0:0 2MB.file || echo PASS')
+ assert('PASS' in ''.join(output))
+
def test_fs2(self, ubman, fs_obj_basic):
"""
Test Case 2 - size command for a small file
diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py
index dd767528dbf..09174f91e98 100644
--- a/test/py/tests/test_spi.py
+++ b/test/py/tests/test_spi.py
@@ -703,4 +703,33 @@ def test_spi_negative(ubman):
ubman, 'read', start, size, res_area, 1, error_msg, EXPECTED_READ
)
+ # Start reading from the reserved area
+ m = re.search(r'reserved\[0\]\s*\[(0x.+)-(0x.+)\]', output)
+ if not m or int(m.group(1), 16) == 0:
+ ubman.log.info('No reserved area is defined or start addr is 0x0!')
+ else:
+ rstart_area = int(m.group(1), 16)
+ rend_area = int(m.group(2), 16)
+
+ # Case 1: Start reading from the middle of the reserved area
+ r_size = rend_area - rstart_area
+ r_area = rstart_area + r_size
+ flash_ops(
+ ubman, 'read', start, size, r_area, 1, error_msg, EXPECTED_READ
+ )
+
+ # Case 2: Start reading from before the reserved area to cross-over
+ # the reserved area
+ rstart_area = rstart_area - int(size/2)
+ flash_ops(
+ ubman, 'read', start, size, rstart_area, 1, error_msg, EXPECTED_READ
+ )
+
+ # Case 3: Start reading till after the reserved area to cross-over
+ # the reserved area
+ rend_area = rend_area - int(size/2)
+ flash_ops(
+ ubman, 'read', start, size, rend_area, 1, error_msg, EXPECTED_READ
+ )
+
i = i + 1
diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py
index 6ac1b225465..fcdcbe2c6db 100644
--- a/test/py/tests/test_trace.py
+++ b/test/py/tests/test_trace.py
@@ -201,7 +201,7 @@ def check_funcgraph(ubman, fname, proftool, map_fname, trace_dat):
# Then look for this:
# u-boot-1 0..... 282.101375: funcgraph_exit: 0.006 us | }
# Then check for this:
- # u-boot-1 0..... 282.101375: funcgraph_entry: 0.000 us | calc_reloc_ofs();
+ # u-boot-1 0..... 282.101375: funcgraph_entry: 0.000 us | event_init();
expected_indent = None
found_start = False
@@ -224,8 +224,8 @@ def check_funcgraph(ubman, fname, proftool, map_fname, trace_dat):
found_end = True
# The next function after initf_bootstage() exits should be
- # initcall_is_event()
- assert upto == 'calc_reloc_ofs()'
+ # event_init()
+ assert upto == 'event_init()'
# Now look for initf_dm() and dm_timer_init() so we can check the bootstage
# time
@@ -274,7 +274,7 @@ def check_flamegraph(ubman, fname, proftool, map_fname, trace_fg):
# We expect dm_timer_init() to be called twice: once before relocation and
# once after
look1 = 'initf_dm;dm_timer_init 1'
- look2 = 'board_init_r;initcall_run_list;initr_dm_devices;dm_timer_init 1'
+ look2 = 'board_init_r;initcall_run_r;initr_dm_devices;dm_timer_init 1'
found = 0
with open(trace_fg, 'r') as fd:
for line in fd: