diff options
| author | Tom Rini <[email protected]> | 2024-03-04 10:13:01 -0500 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2024-03-04 10:25:47 -0500 |
| commit | bd465ada0e1172910f64feac6035f2344449c381 (patch) | |
| tree | e749428436685ab25dcfe109309adee6f45cdf39 /test | |
| parent | bdbbf1d7b55434973402c390a822490ce6e14994 (diff) | |
| parent | 68c4d3098b9cf59a20c470df385eb5422fe32bbe (diff) | |
Merge branch '2024-03-02-assorted-updates' into next
- Assorted MediaTek, ASPEED, xenguest, s5p4418 and qemu-arm fixes
- Assorted test fixes/updates/additions.
- A few bootstd/related fixes.
- Remove common.h from some files
- Drop reiserfs
- A few other assorted fixes throughout the tree.
Diffstat (limited to 'test')
| -rw-r--r-- | test/boot/bootflow.c | 2 | ||||
| -rw-r--r-- | test/boot/bootstd_common.c | 3 | ||||
| -rw-r--r-- | test/cmd/mbr.c | 6 | ||||
| -rw-r--r-- | test/cmd/setexpr.c | 10 | ||||
| -rw-r--r-- | test/py/tests/test_net.py | 58 |
5 files changed, 77 insertions, 2 deletions
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index fa54dde661c..4845b7121c8 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -544,7 +544,7 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev, "bootmeth_script", 0, ofnode_null(), &dev)); /* Enable the cros bootmeth if needed */ - if (bind_cros) { + if (IS_ENABLED(CONFIG_BOOTMETH_CROS) && bind_cros) { ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_cros), "cros", 0, ofnode_null(), &dev)); diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c index e71a2975c53..cc97e255e5c 100644 --- a/test/boot/bootstd_common.c +++ b/test/boot/bootstd_common.c @@ -74,6 +74,9 @@ int bootstd_test_check_mmc_hunter(struct unit_test_state *uts) struct bootstd_priv *std; uint seq; + if (!IS_ENABLED(CONFIG_MMC)) + return 0; + /* get access to the used hunters */ ut_assertok(bootstd_get_priv(&std)); diff --git a/test/cmd/mbr.c b/test/cmd/mbr.c index 46b78e706ca..235b363290e 100644 --- a/test/cmd/mbr.c +++ b/test/cmd/mbr.c @@ -240,7 +240,11 @@ static int mbr_test_run(struct unit_test_state *uts) ut_assert(ofnode_valid(node)); ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false)); - mbr_parts_max = sizeof('\0') + 2 + + /* + * 1 byte for null character + * 2 reserved bytes + */ + mbr_parts_max = 1 + 2 + strlen(mbr_parts_header) + strlen(mbr_parts_p1) + strlen(mbr_parts_p2) + diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index 312593e1e32..ee329e94b85 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -179,6 +179,16 @@ static int setexpr_test_regex(struct unit_test_state *uts) val = env_get("mary"); ut_asserteq_str("this is a test", val); + /* No match */ + ut_assertok(run_command("setenv fred 'this is a test'", 0)); + ut_assertok(run_command("setenv mary ''", 0)); + ut_assertok(run_command("setexpr fred gsub us is \"${fred}\"", 0)); + ut_assertok(run_command("setexpr mary gsub us is \"${fred}\"", 0)); + val = env_get("fred"); + ut_asserteq_str("this is a test", val); + val = env_get("mary"); + ut_asserteq_str("this is a test", val); + unmap_sysmem(buf); return 0; diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index 4ff3dafd629..038a473b239 100644 --- a/test/py/tests/test_net.py +++ b/test/py/tests/test_net.py @@ -8,6 +8,7 @@ import pytest import u_boot_utils import uuid import datetime +import re """ Note: This test relies on boardenv_* containing configuration values to define @@ -31,6 +32,12 @@ env__net_uses_pci = True # set to False. env__net_dhcp_server = True +# False or omitted if a DHCP server is attached to the network, and dhcp abort +# case should be tested. +# If DHCP abort testing is not possible or desired, set this variable to True. +# For example: On some setup, dhcp is too fast and this case may not work. +env__dhcp_abort_test_skip = True + # True if a DHCPv6 server is attached to the network, and should be tested. # If DHCPv6 testing is not possible or desired, this variable may be omitted or # set to False. @@ -120,6 +127,57 @@ def test_net_dhcp(u_boot_console): global net_set_up net_set_up = True [email protected]('cmd_dhcp') [email protected]('cmd_mii') +def test_net_dhcp_abort(u_boot_console): + """Test the dhcp command by pressing ctrl+c in the middle of dhcp request + + The boardenv_* file may be used to enable/disable this test; see the + comment at the beginning of this file. + """ + + test_dhcp = u_boot_console.config.env.get('env__net_dhcp_server', False) + if not test_dhcp: + pytest.skip('No DHCP server available') + + if u_boot_console.config.env.get('env__dhcp_abort_test_skip', True): + pytest.skip('DHCP abort test is not enabled!') + + u_boot_console.run_command('setenv autoload no') + + # Phy reset before running dhcp command + output = u_boot_console.run_command('mii device') + if not re.search(r"Current device: '(.+?)'", output): + pytest.skip('PHY device does not exist!') + eth_num = re.search(r"Current device: '(.+?)'", output).groups()[0] + u_boot_console.run_command(f'mii device {eth_num}') + output = u_boot_console.run_command('mii info') + eth_addr = hex(int(re.search(r'PHY (.+?):', output).groups()[0], 16)) + u_boot_console.run_command(f'mii modify {eth_addr} 0 0x8000 0x8000') + + u_boot_console.run_command('dhcp', wait_for_prompt=False) + try: + u_boot_console.wait_for('Waiting for PHY auto negotiation to complete') + except: + pytest.skip('Timeout waiting for PHY auto negotiation to complete') + + u_boot_console.wait_for('done') + + try: + # Sending Ctrl-C + output = u_boot_console.run_command( + chr(3), wait_for_echo=False, send_nl=False + ) + assert 'TIMEOUT' not in output + assert 'DHCP client bound to address ' not in output + assert 'Abort' in output + finally: + # Provide a time to recover from Abort - if it is not performed + # There is message like: ethernet@ff0e0000: No link. + u_boot_console.run_command('sleep 1') + # Run the dhcp test to setup the network configuration + test_net_dhcp(u_boot_console) + @pytest.mark.buildconfigspec('cmd_dhcp6') def test_net_dhcp6(u_boot_console): """Test the dhcp6 command. |
