On 08/09/2018 08:17 AM, Jean-Jacques Hiblot wrote:
In some cases it can be useful to be able to bind a device to a driver from
the command line.
The obvious example is for versatile devices such as USB gadget.
Another use case is when the devices are not yet ready at startup and
require some setup before the drivers are bound (ex: FPGA which bitsream is
fetched from a mass storage or ethernet)

usage example:

bind usb_dev_generic 0 usb_ether
unbind usb_dev_generic 0 usb_ether
or
unbind eth 1

bind /ocp/omap_dwc3@48380000/usb@48390000 usb_ether
unbind /ocp/omap_dwc3@48380000/usb@48390000

diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py

+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.

That line looks wrong.

+def in_tree(response, name, uclass, drv, depth, last_child):
+       lines = [x.strip() for x in response.splitlines()]
+       leaf = ' ' * 4 * depth;
+       if not last_child:
+               leaf = leaf + '\|'
+       else:
+               leaf = leaf + '`'
+       leaf = leaf + '-- ' + name
+       line = ' *{:10.10}  [0-9]*  \[ [ +] \]   {:10.10}  {}$'.format(uclass, 
drv,leaf)

Does Python 2 support that interpolation format? test/py should support both Python 2 and 3.

+@pytest.mark.buildconfigspec('cmd_bind')
+def test_bind_unbind_with_node(u_boot_console):
+
+       #bind /bind-test. Device should come up as well as its children
+       response = u_boot_console.run_command("bind  /bind-test 
generic_simple_bus")

Nit: There are 2 spaces after "bind".

+       #Unbind child #2. No error expected and all devices should be there 
except for bind-test-child2
...
+       assert "bind-test-child2" not in tree
+
+
+       #Bind child #2. No error expected and all devices should be there

Nit: No need for 2 blank lines there.

+       #try binding invalid node with valid driver
+       response = u_boot_console.run_command("bind  /not-a-valid-node 
generic_simple_bus")
+       assert response != ''

Should this check for a specific (partial) error message or format of message?

+       #bind /bind-test. Device should come up as well as its children
...
+       response = u_boot_console.run_command("unbind  /bind-test")
+       assert response == ''

Shouldn't this validate the dm tree output right at the end too?

+def get_next_line(tree, name):
+       treelines = [x.strip() for x in tree.splitlines() if x.strip()]
+       child_line = ""
+       for idx, line in enumerate(treelines):
+               if ("-- " + name) in line:
+                       try:
+                               child_line = treelines[idx+1]
+                       except:
+                               pass

Squashing all exceptions seems a little drastic. What exceptions happen and why?

+
+@pytest.mark.buildconfigspec('cmd_bind')
+def test_bind_unbind_with_uclass(u_boot_console):
...
+       #check that the child is there and its uclass/index pair is right
+       tree = u_boot_console.run_command("dm tree")
+       treelines = [x.strip() for x in tree.splitlines() if x.strip()]

I don't /think/ treelines is used anywhere in this function?
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to