aboutsummaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
authorKory Maincent <kory.maincent@bootlin.com>2021-05-04 19:31:23 +0200
committerTom Rini <trini@konsulko.com>2021-05-13 13:09:09 -0400
commit95300f203f3249ffb7a08222dc4d8106c5a6ceeb (patch)
treea26fd939eccb3eca623057083a4758507041520b /test/py
parent2f84e9cf06d31aa703ff31301bf811b3fcfc16cf (diff)
downloadu-boot-95300f203f3249ffb7a08222dc4d8106c5a6ceeb.zip
u-boot-95300f203f3249ffb7a08222dc4d8106c5a6ceeb.tar.gz
u-boot-95300f203f3249ffb7a08222dc4d8106c5a6ceeb.tar.bz2
pytest: add sandbox test for "extension" command
This commit extends the sandbox to implement a dummy extension_board_scan() function and enables the extension command in the sandbox configuration. It then adds a test that checks the proper functionality of the extension command by applying two Device Tree overlays to the sandbox Device Tree. Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> [trini: Limit to running on sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'test/py')
-rw-r--r--test/py/tests/test_extension.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/py/tests/test_extension.py b/test/py/tests/test_extension.py
new file mode 100644
index 0000000..267cf2f
--- /dev/null
+++ b/test/py/tests/test_extension.py
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2020
+# Author: Kory Maincent <kory.maincent@bootlin.com>
+
+# Test U-Boot's "extension" commands.
+
+import os
+import pytest
+import u_boot_utils
+
+overlay_addr = 0x1000
+
+SANDBOX_DTB='arch/sandbox/dts/sandbox.dtb'
+OVERLAY_DIR='arch/sandbox/dts/'
+
+def load_dtb(u_boot_console):
+ u_boot_console.log.action('Loading devicetree to RAM...')
+ u_boot_console.run_command('host load hostfs - $fdt_addr_r %s' % (os.path.join(u_boot_console.config.build_dir, SANDBOX_DTB)))
+ u_boot_console.run_command('fdt addr $fdt_addr_r')
+
+@pytest.mark.buildconfigspec('cmd_fdt')
+@pytest.mark.boardspec('sandbox')
+def test_extension(u_boot_console):
+ """Test the 'extension' command."""
+
+ load_dtb(u_boot_console)
+
+ output = u_boot_console.run_command('extension list')
+ assert('No extension' in output)
+
+ output = u_boot_console.run_command('extension scan')
+ assert output == 'Found 2 extension board(s).'
+
+ output = u_boot_console.run_command('extension list')
+ assert('overlay0.dtbo' in output)
+ assert('overlay1.dtbo' in output)
+
+ u_boot_console.run_command_list([
+ 'setenv extension_overlay_addr %s' % (overlay_addr),
+ 'setenv extension_overlay_cmd \'host load hostfs - ${extension_overlay_addr} %s${extension_overlay_name}\'' % (os.path.join(u_boot_console.config.build_dir, OVERLAY_DIR))])
+
+ output = u_boot_console.run_command('extension apply 0')
+ assert('bytes read' in output)
+
+ output = u_boot_console.run_command('fdt print')
+ assert('button3' in output)
+
+ output = u_boot_console.run_command('extension apply all')
+ assert('bytes read' in output)
+
+ output = u_boot_console.run_command('fdt print')
+ assert('button4' in output)
+