From 4a6105e7830e9e945a6dc556a43ffaf26f0156e5 Mon Sep 17 00:00:00 2001 From: Udit Kumar Date: Tue, 26 Sep 2023 16:54:43 +0530 Subject: test: lmb: Add test for coalescing and overlap range Add test case for an address range which is coalescing with one of range and overlapping with next range Cc: Simon Glass Signed-off-by: Udit Kumar Reviewed-by: Simon Glass --- test/lib/lmb.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 16288750358..15c68ce3961 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -451,12 +451,23 @@ static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts) ut_asserteq(ret, 0); ASSERT_LMB(&lmb, ram, ram_size, 2, 0x40010000, 0x10000, 0x40030000, 0x10000, 0, 0); - /* allocate 2nd region */ + /* allocate 2nd region , This should coalesced all region into one */ ret = lmb_reserve(&lmb, 0x40020000, 0x10000); ut_assert(ret >= 0); ASSERT_LMB(&lmb, ram, ram_size, 1, 0x40010000, 0x30000, 0, 0, 0, 0); + /* allocate 2nd region, which should be added as first region */ + ret = lmb_reserve(&lmb, 0x40000000, 0x8000); + ut_assert(ret >= 0); + ASSERT_LMB(&lmb, ram, ram_size, 2, 0x40000000, 0x8000, + 0x40010000, 0x30000, 0, 0); + + /* allocate 3rd region, coalesce with first and overlap with second */ + ret = lmb_reserve(&lmb, 0x40008000, 0x10000); + ut_assert(ret >= 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, 0x40000000, 0x40000, + 0, 0, 0, 0); return 0; } -- cgit v1.3.1 From 34124ad9a433eb829b7a1942e074dd500302d964 Mon Sep 17 00:00:00 2001 From: Love Kumar Date: Wed, 27 Sep 2023 10:33:55 +0530 Subject: test/py: sleep: Add a test for the time command Execute "time ", and validate that it gives the approximately the correct amount of command execution time. Signed-off-by: Love Kumar --- test/py/tests/test_sleep.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/py/tests/test_sleep.py b/test/py/tests/test_sleep.py index 392af29db22..66a57434bff 100644 --- a/test/py/tests/test_sleep.py +++ b/test/py/tests/test_sleep.py @@ -41,3 +41,21 @@ def test_sleep(u_boot_console): if not u_boot_console.config.gdbserver: # margin is hopefully enough to account for any system overhead. assert elapsed < (sleep_time + sleep_margin) + +@pytest.mark.buildconfigspec("cmd_misc") +def test_time(u_boot_console): + """Test the time command, and validate that it gives approximately the + correct amount of command execution time.""" + + sleep_skip = u_boot_console.config.env.get("env__sleep_accurate", True) + if not sleep_skip: + pytest.skip("sleep is not accurate") + + sleep_time = u_boot_console.config.env.get("env__sleep_time", 10) + sleep_margin = u_boot_console.config.env.get("env__sleep_margin", 0.25) + output = u_boot_console.run_command("time sleep %d" % sleep_time) + execute_time = float(output.split()[1]) + assert sleep_time >= (execute_time - 0.01) + if not u_boot_console.config.gdbserver: + # margin is hopefully enough to account for any system overhead. + assert sleep_time < (execute_time + sleep_margin) -- cgit v1.3.1 From 3f876cb7c57511174d1b6a3e089443ccbaf236ec Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Fri, 29 Sep 2023 12:06:54 -0400 Subject: test: Fix SPL tests not being run SPL doesn't have OF_LIVE enabled, so we can only run tests with a flat tree. Don't skip them even if they don't use the devicetree. Fixes: 6ec5178c0ef ("test: Skip flat-tree tests if devicetree is not used") Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- test/test-main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test-main.c b/test/test-main.c index 778bf0a18a0..edb20bc4b9c 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -476,7 +476,8 @@ static int ut_run_test_live_flat(struct unit_test_state *uts, * (for sandbox we handle this by copying the tree, but not for other * boards) */ - if ((test->flags & UT_TESTF_SCAN_FDT) && + if ((!CONFIG_IS_ENABLED(OF_LIVE) || + (test->flags & UT_TESTF_SCAN_FDT)) && !(test->flags & UT_TESTF_LIVE_TREE) && (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE) || !(test->flags & UT_TESTF_OTHER_FDT)) && -- cgit v1.3.1