Message ID | 1453831814-23973-4-git-send-email-swarren@wwwdotorg.org |
---|---|
State | Accepted |
Commit | 56382a81f38bed423791d7b80e95c1f65bd83b9b |
Delegated to: | Simon Glass |
Headers | show |
On 26 January 2016 at 11:10, Stephen Warren <swarren@wwwdotorg.org> wrote: > From: Stephen Warren <swarren@nvidia.com> > > 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> > --- > test/py/tests/test_net.py | 28 +++++++++++++++------------- > 1 file changed, 15 insertions(+), 13 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org>
On 26 January 2016 at 13:00, Simon Glass <sjg@chromium.org> wrote: > On 26 January 2016 at 11:10, Stephen Warren <swarren@wwwdotorg.org> wrote: >> From: Stephen Warren <swarren@nvidia.com> >> >> 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> >> --- >> test/py/tests/test_net.py | 28 +++++++++++++++------------- >> 1 file changed, 15 insertions(+), 13 deletions(-) > > Reviewed-by: Simon Glass <sjg@chromium.org> Applied to u-boot-dm, thanks!
diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index c73854ea74e0..9c46551e8cbf 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):