Kory Maincent | 95300f2 | 2021-05-04 19:31:23 +0200 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
| 2 | # Copyright (c) 2020 |
| 3 | # Author: Kory Maincent <kory.maincent@bootlin.com> |
| 4 | |
| 5 | # Test U-Boot's "extension" commands. |
| 6 | |
| 7 | import os |
| 8 | import pytest |
| 9 | import u_boot_utils |
| 10 | |
| 11 | overlay_addr = 0x1000 |
| 12 | |
| 13 | SANDBOX_DTB='arch/sandbox/dts/sandbox.dtb' |
| 14 | OVERLAY_DIR='arch/sandbox/dts/' |
| 15 | |
| 16 | def load_dtb(u_boot_console): |
| 17 | u_boot_console.log.action('Loading devicetree to RAM...') |
| 18 | u_boot_console.run_command('host load hostfs - $fdt_addr_r %s' % (os.path.join(u_boot_console.config.build_dir, SANDBOX_DTB))) |
| 19 | u_boot_console.run_command('fdt addr $fdt_addr_r') |
| 20 | |
| 21 | @pytest.mark.buildconfigspec('cmd_fdt') |
| 22 | @pytest.mark.boardspec('sandbox') |
| 23 | def test_extension(u_boot_console): |
| 24 | """Test the 'extension' command.""" |
| 25 | |
| 26 | load_dtb(u_boot_console) |
| 27 | |
| 28 | output = u_boot_console.run_command('extension list') |
| 29 | assert('No extension' in output) |
| 30 | |
| 31 | output = u_boot_console.run_command('extension scan') |
| 32 | assert output == 'Found 2 extension board(s).' |
| 33 | |
| 34 | output = u_boot_console.run_command('extension list') |
| 35 | assert('overlay0.dtbo' in output) |
| 36 | assert('overlay1.dtbo' in output) |
| 37 | |
| 38 | u_boot_console.run_command_list([ |
| 39 | 'setenv extension_overlay_addr %s' % (overlay_addr), |
| 40 | '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))]) |
| 41 | |
| 42 | output = u_boot_console.run_command('extension apply 0') |
| 43 | assert('bytes read' in output) |
| 44 | |
| 45 | output = u_boot_console.run_command('fdt print') |
| 46 | assert('button3' in output) |
| 47 | |
| 48 | output = u_boot_console.run_command('extension apply all') |
| 49 | assert('bytes read' in output) |
| 50 | |
| 51 | output = u_boot_console.run_command('fdt print') |
| 52 | assert('button4' in output) |
| 53 | |