summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2016-01-26 11:10:14 -0700
committerSimon Glass <sjg@chromium.org>2016-01-28 21:01:23 -0700
commit56382a81f38bed423791d7b80e95c1f65bd83b9b (patch)
tree237fb0a2277981ee3b9d292b8ff5d49ca5f35f76 /test
parent986691fb97bc245be517a9db1297cfa71dd865cf (diff)
downloadu-boot-imx-56382a81f38bed423791d7b80e95c1f65bd83b9b.zip
u-boot-imx-56382a81f38bed423791d7b80e95c1f65bd83b9b.tar.gz
u-boot-imx-56382a81f38bed423791d7b80e95c1f65bd83b9b.tar.bz2
test/py: make net test aware of USB and PCI enumeration
The existing net test executes a list of commands supplied by boardenv variable env__net_pre_commands. The idea was that boardenv would know whether the Ethernet device was attached to USB, PCI, ... and hence was the best place to put any commands required to probe the device. However, this approach doesn't scale well when attempting to use a single boardenv across multiple branches of U-Boot, some of which require "pci enum" to enumerate PCI and others of which don't, or don't /yet/ simply because various upstream changes haven't been merged down. This patch updates the test to require that the boardenv state which HW features are required for Ethernet to work, and lets the test itself map that knowledge to the set of commands to execute. Since this mapping is part of the test script, which is part of the U-Boot code/branch, this approach is more scalable. It also feels cleaner, since again boardenv is only providing data, rather than test logic. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/py/tests/test_net.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
index c73854e..9c46551 100644
--- a/test/py/tests/test_net.py
+++ b/test/py/tests/test_net.py
@@ -15,14 +15,15 @@ will be automatically skipped.
For example:
-# Any commands that need to be executed prior to testing,
-# to get the network hardware into an operational state.
-#
-# If no commands are required, this variable may be omitted, or set to an
-# empty list.
-env__net_pre_commands = [
- "usb start",
-]
+# Boolean indicating whether the Ethernet device is attached to USB, and hence
+# USB enumeration needs to be performed prior to network tests.
+# This variable may be omitted if its value is False.
+env__net_uses_usb = False
+
+# Boolean indicating whether the Ethernet device is attached to PCI, and hence
+# PCI enumeration needs to be performed prior to network tests.
+# This variable may be omitted if its value is False.
+env__net_uses_pci = True
# True if a DHCP server is attached to the network, and should be tested.
# If DHCP testing is not possible or desired, this variable may be omitted or
@@ -56,12 +57,13 @@ def test_net_pre_commands(u_boot_console):
beginning of this file.
'''
- cmds = u_boot_console.config.env.get('env__net_pre_commands', None)
- if not cmds:
- pytest.skip('No network pre-commands defined')
+ init_usb = u_boot_console.config.env.get('env__net_uses_usb', False)
+ if init_usb:
+ u_boot_console.run_command('usb start')
- for cmd in cmds:
- u_boot_console.run_command(cmd)
+ init_pci = u_boot_console.config.env.get('env__net_uses_pci', False)
+ if init_pci:
+ u_boot_console.run_command('pci enum')
@pytest.mark.buildconfigspec('cmd_dhcp')
def test_net_dhcp(u_boot_console):