summaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
Diffstat (limited to 'test/py')
-rw-r--r--test/py/tests/test_env.py5
-rw-r--r--test/py/tests/test_fs/conftest.py6
-rw-r--r--test/py/tests/test_fs/test_squashfs/sqfs_common.py42
-rw-r--r--test/py/tests/test_fs/test_squashfs/test_sqfs_load.py33
-rw-r--r--test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py26
-rw-r--r--test/py/tests/test_shell_basics.py6
6 files changed, 112 insertions, 6 deletions
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 86ec1b36d3..2ae8f25381 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -416,7 +416,10 @@ def mk_env_ext4(state_test_env):
else:
try:
u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
- u_boot_utils.run_and_log(c, 'mkfs.ext4 -O ^metadata_csum %s' % persistent)
+ u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)
+ sb_content = u_boot_utils.run_and_log(c, 'tune2fs -l %s' % persistent)
+ if 'metadata_csum' in sb_content:
+ u_boot_utils.run_and_log(c, 'tune2fs -O ^metadata_csum %s' % persistent)
except CalledProcessError:
call('rm -f %s' % persistent, shell=True)
raise
diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py
index ee82169c2a..58e8cd46ee 100644
--- a/test/py/tests/test_fs/conftest.py
+++ b/test/py/tests/test_fs/conftest.py
@@ -149,8 +149,6 @@ def mk_fs(config, fs_type, size, id):
mkfs_opt = '-F 16'
elif fs_type == 'fat32':
mkfs_opt = '-F 32'
- elif fs_type == 'ext4':
- mkfs_opt = '-O ^metadata_csum'
else:
mkfs_opt = ''
@@ -167,6 +165,10 @@ def mk_fs(config, fs_type, size, id):
% (fs_img, count), shell=True)
check_call('mkfs.%s %s %s'
% (fs_lnxtype, mkfs_opt, fs_img), shell=True)
+ if fs_type == 'ext4':
+ sb_content = check_output('tune2fs -l %s' % fs_img, shell=True).decode()
+ if 'metadata_csum' in sb_content:
+ check_call('tune2fs -O ^metadata_csum %s' % fs_img, shell=True)
return fs_img
except CalledProcessError:
call('rm -f %s' % fs_img, shell=True)
diff --git a/test/py/tests/test_fs/test_squashfs/sqfs_common.py b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
new file mode 100644
index 0000000000..9ef7b19ad9
--- /dev/null
+++ b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 Bootlin
+# Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+
+import os
+import random
+import string
+
+def sqfs_get_random_letters(size):
+ letters = []
+ for i in range(0, size):
+ letters.append(random.choice(string.ascii_letters))
+
+ return ''.join(letters)
+
+def sqfs_generate_file(path, size):
+ content = sqfs_get_random_letters(size)
+ file = open(path, "w")
+ file.write(content)
+ file.close()
+
+# generate image with three files and a symbolic link
+def sqfs_generate_image():
+ src = "test/py/tests/test_fs/test_squashfs/sqfs_src/"
+ dest = "test/py/tests/test_fs/test_squashfs/sqfs"
+ os.mkdir(src)
+ sqfs_generate_file(src + "frag_only", 100)
+ sqfs_generate_file(src + "blks_frag", 5100)
+ sqfs_generate_file(src + "blks_only", 4096)
+ os.symlink("frag_only", src + "sym")
+ os.system("mksquashfs " + src + " " + dest + " -b 4096 -always-use-fragments")
+
+# removes all files created by sqfs_generate_image()
+def sqfs_clean():
+ src = "test/py/tests/test_fs/test_squashfs/sqfs_src/"
+ dest = "test/py/tests/test_fs/test_squashfs/sqfs"
+ os.remove(src + "frag_only")
+ os.remove(src + "blks_frag")
+ os.remove(src + "blks_only")
+ os.remove(src + "sym")
+ os.rmdir(src)
+ os.remove(dest)
diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py
new file mode 100644
index 0000000000..9b828fdf04
--- /dev/null
+++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 Bootlin
+# Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+
+import os
+import pytest
+from sqfs_common import *
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('cmd_fs_generic')
+@pytest.mark.buildconfigspec('cmd_squashfs')
+@pytest.mark.buildconfigspec('fs_squashfs')
+@pytest.mark.requiredtool('mksquashfs')
+def test_sqfs_load(u_boot_console):
+ sqfs_generate_image()
+ command = "sqfsload host 0 $kernel_addr_r "
+ path = "test/py/tests/test_fs/test_squashfs/sqfs"
+
+ try:
+ output = u_boot_console.run_command("host bind 0 " + path)
+ output = u_boot_console.run_command(command + "xxx")
+ assert "File not found." in output
+ output = u_boot_console.run_command(command + "frag_only")
+ assert "100 bytes read in" in output
+ output = u_boot_console.run_command(command + "blks_frag")
+ assert "5100 bytes read in" in output
+ output = u_boot_console.run_command(command + "blks_only")
+ assert "4096 bytes read in" in output
+ output = u_boot_console.run_command(command + "sym")
+ assert "100 bytes read in" in output
+ except:
+ sqfs_clean()
+ sqfs_clean()
diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
new file mode 100644
index 0000000000..dc31f1a50e
--- /dev/null
+++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 Bootlin
+# Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+
+import os
+import pytest
+from sqfs_common import *
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('cmd_fs_generic')
+@pytest.mark.buildconfigspec('cmd_squashfs')
+@pytest.mark.buildconfigspec('fs_squashfs')
+@pytest.mark.requiredtool('mksquashfs')
+def test_sqfs_ls(u_boot_console):
+ sqfs_generate_image()
+ path = "test/py/tests/test_fs/test_squashfs/sqfs"
+ try:
+ output = u_boot_console.run_command("host bind 0 " + path)
+ output = u_boot_console.run_command("sqfsls host 0")
+ assert "4 file(s), 0 dir(s)" in output
+ assert "<SYM> sym" in output
+ output = u_boot_console.run_command("sqfsls host 0 xxx")
+ assert "** Cannot find directory. **" in output
+ except:
+ sqfs_clean()
+ sqfs_clean()
diff --git a/test/py/tests/test_shell_basics.py b/test/py/tests/test_shell_basics.py
index f54f7b7425..68a3f892f6 100644
--- a/test/py/tests/test_shell_basics.py
+++ b/test/py/tests/test_shell_basics.py
@@ -34,11 +34,11 @@ def test_shell_semicolon_three(u_boot_console):
def test_shell_run(u_boot_console):
"""Test the "run" shell command."""
- u_boot_console.run_command('setenv foo "setenv monty 1; setenv python 2"')
+ u_boot_console.run_command('setenv foo \'setenv monty 1; setenv python 2\'')
u_boot_console.run_command('run foo')
- response = u_boot_console.run_command('echo $monty')
+ response = u_boot_console.run_command('echo ${monty}')
assert response.strip() == '1'
- response = u_boot_console.run_command('echo $python')
+ response = u_boot_console.run_command('echo ${python}')
assert response.strip() == '2'
u_boot_console.run_command('setenv foo')
u_boot_console.run_command('setenv monty')