]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
test/py: make net test aware of USB and PCI enumeration
authorStephen Warren <swarren@nvidia.com>
Tue, 26 Jan 2016 18:10:14 +0000 (11:10 -0700)
committerSimon Glass <sjg@chromium.org>
Fri, 29 Jan 2016 04:01:23 +0000 (21:01 -0700)
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>
test/py/tests/test_net.py

index c73854ea74e016b12362265ebfe7e0b0455c4f15..9c46551e8cbf3e7804475d3234925422ec98cdda 100644 (file)
@@ -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):