summaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
Diffstat (limited to 'test/py')
-rw-r--r--test/py/conftest.py2
-rw-r--r--test/py/requirements.txt1
-rw-r--r--test/py/tests/test_extension.py53
-rw-r--r--test/py/tests/test_fs/conftest.py48
4 files changed, 91 insertions, 13 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py
index 1b909cde9d3..11a3f307ea8 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -226,7 +226,7 @@ def pytest_configure(config):
import u_boot_console_exec_attach
console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig)
-re_ut_test_list = re.compile(r'_u_boot_list_2_ut_(.*)_test_2_\1_test_(.*)\s*$')
+re_ut_test_list = re.compile(r'[^a-zA-Z0-9_]_u_boot_list_2_ut_(.*)_test_2_\1_test_(.*)\s*$')
def generate_ut_subtest(metafunc, fixture_name, sym_path):
"""Provide parametrization for a ut_subtest fixture.
diff --git a/test/py/requirements.txt b/test/py/requirements.txt
index 5b4829256d3..33c5c0bbc41 100644
--- a/test/py/requirements.txt
+++ b/test/py/requirements.txt
@@ -17,6 +17,7 @@ pyparsing==2.4.2
pytest==5.2.1
python-mimeparse==1.6.0
python-subunit==1.3.0
+requests==2.25.1
six==1.12.0
testtools==2.3.0
traceback2==1.4.0
diff --git a/test/py/tests/test_extension.py b/test/py/tests/test_extension.py
new file mode 100644
index 00000000000..267cf2ff27c
--- /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)
+
diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py
index 50af9efcf76..410a675b971 100644
--- a/test/py/tests/test_fs/conftest.py
+++ b/test/py/tests/test_fs/conftest.py
@@ -278,14 +278,19 @@ def fs_obj_basic(request, u_boot_config):
check_call('mkdir -p %s' % mount_dir, shell=True)
except CalledProcessError as err:
pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err))
- return
- finally:
call('rm -f %s' % fs_img, shell=True)
+ return
try:
# Mount the image so we can populate it.
mount_fs(fs_type, fs_img, mount_dir)
+ except CalledProcessError as err:
+ pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err))
+ call('rmdir %s' % mount_dir, shell=True)
+ call('rm -f %s' % fs_img, shell=True)
+ return
+ try:
# Create a subdirectory.
check_call('mkdir %s/SUBDIR' % mount_dir, shell=True)
@@ -348,11 +353,12 @@ def fs_obj_basic(request, u_boot_config):
except CalledProcessError as err:
pytest.skip('Setup failed for filesystem: ' + fs_type + '. {}'.format(err))
+ umount_fs(mount_dir)
return
else:
+ umount_fs(mount_dir)
yield [fs_ubtype, fs_img, md5val]
finally:
- umount_fs(mount_dir)
call('rmdir %s' % mount_dir, shell=True)
call('rm -f %s' % fs_img, shell=True)
@@ -394,14 +400,19 @@ def fs_obj_ext(request, u_boot_config):
check_call('mkdir -p %s' % mount_dir, shell=True)
except CalledProcessError as err:
pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err))
- return
- finally:
call('rm -f %s' % fs_img, shell=True)
+ return
try:
# Mount the image so we can populate it.
mount_fs(fs_type, fs_img, mount_dir)
+ except CalledProcessError as err:
+ pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err))
+ call('rmdir %s' % mount_dir, shell=True)
+ call('rm -f %s' % fs_img, shell=True)
+ return
+ try:
# Create a test directory
check_call('mkdir %s/dir1' % mount_dir, shell=True)
@@ -443,11 +454,12 @@ def fs_obj_ext(request, u_boot_config):
check_call('rm %s' % tmp_file, shell=True)
except CalledProcessError:
pytest.skip('Setup failed for filesystem: ' + fs_type)
+ umount_fs(mount_dir)
return
else:
+ umount_fs(mount_dir)
yield [fs_ubtype, fs_img, md5val]
finally:
- umount_fs(mount_dir)
call('rmdir %s' % mount_dir, shell=True)
call('rm -f %s' % fs_img, shell=True)
@@ -517,14 +529,19 @@ def fs_obj_unlink(request, u_boot_config):
check_call('mkdir -p %s' % mount_dir, shell=True)
except CalledProcessError as err:
pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err))
- return
- finally:
call('rm -f %s' % fs_img, shell=True)
+ return
try:
# Mount the image so we can populate it.
mount_fs(fs_type, fs_img, mount_dir)
+ except CalledProcessError as err:
+ pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err))
+ call('rmdir %s' % mount_dir, shell=True)
+ call('rm -f %s' % fs_img, shell=True)
+ return
+ try:
# Test Case 1 & 3
check_call('mkdir %s/dir1' % mount_dir, shell=True)
check_call('dd if=/dev/urandom of=%s/dir1/file1 bs=1K count=1'
@@ -548,11 +565,12 @@ def fs_obj_unlink(request, u_boot_config):
except CalledProcessError:
pytest.skip('Setup failed for filesystem: ' + fs_type)
+ umount_fs(mount_dir)
return
else:
+ umount_fs(mount_dir)
yield [fs_ubtype, fs_img]
finally:
- umount_fs(mount_dir)
call('rmdir %s' % mount_dir, shell=True)
call('rm -f %s' % fs_img, shell=True)
@@ -594,14 +612,19 @@ def fs_obj_symlink(request, u_boot_config):
check_call('mkdir -p %s' % mount_dir, shell=True)
except CalledProcessError as err:
pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err))
- return
- finally:
call('rm -f %s' % fs_img, shell=True)
+ return
try:
# Mount the image so we can populate it.
mount_fs(fs_type, fs_img, mount_dir)
+ except CalledProcessError as err:
+ pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err))
+ call('rmdir %s' % mount_dir, shell=True)
+ call('rm -f %s' % fs_img, shell=True)
+ return
+ try:
# Create a subdirectory.
check_call('mkdir %s/SUBDIR' % mount_dir, shell=True)
@@ -625,10 +648,11 @@ def fs_obj_symlink(request, u_boot_config):
except CalledProcessError:
pytest.skip('Setup failed for filesystem: ' + fs_type)
+ umount_fs(mount_dir)
return
else:
+ umount_fs(mount_dir)
yield [fs_ubtype, fs_img, md5val]
finally:
- umount_fs(mount_dir)
call('rmdir %s' % mount_dir, shell=True)
call('rm -f %s' % fs_img, shell=True)