aboutsummaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-10-29 19:47:19 -0600
committerSimon Glass <sjg@chromium.org>2022-11-07 16:24:30 -0700
commit499503e1578fe385e820170af78525ea2f799a4c (patch)
tree76db6e2144fb76dd1e83b57f743115b4df76e429 /test/py
parent2851cc94f3010d686fca3817f66ec8e9f4b2235b (diff)
dm: Add tests for the sandbox host driver
Add some unit tests for this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/py')
-rw-r--r--test/py/tests/fs_helper.py6
-rw-r--r--test/py/tests/test_ut.py6
2 files changed, 10 insertions, 2 deletions
diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py
index 9882ddb1daa5..17151bcd08ec 100644
--- a/test/py/tests/fs_helper.py
+++ b/test/py/tests/fs_helper.py
@@ -9,7 +9,7 @@ import re
import os
from subprocess import call, check_call, check_output, CalledProcessError
-def mk_fs(config, fs_type, size, prefix):
+def mk_fs(config, fs_type, size, prefix, use_src_dir=False):
"""Create a file system volume
Args:
@@ -17,12 +17,14 @@ def mk_fs(config, fs_type, size, prefix):
fs_type (str): File system type, e.g. 'ext4'
size (int): Size of file system in bytes
prefix (str): Prefix string of volume's file name
+ use_src_dir (bool): true to put the file in the source directory
Raises:
CalledProcessError: if any error occurs when creating the filesystem
"""
fs_img = f'{prefix}.{fs_type}.img'
- fs_img = os.path.join(config.persistent_data_dir, fs_img)
+ fs_img = os.path.join(config.source_dir if use_src_dir
+ else config.persistent_data_dir, fs_img)
if fs_type == 'fat16':
mkfs_opt = '-F 16'
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index 9d423903736d..bab8b97672bb 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -7,6 +7,7 @@ import os.path
import pytest
import u_boot_utils
+from tests import fs_helper
def mkdir_cond(dirname):
"""Create a directory if it doesn't already exist
@@ -123,6 +124,11 @@ def test_ut_dm_init(u_boot_console):
u_boot_utils.run_and_log(
u_boot_console, f'sfdisk {fn}', stdin=b'type=83')
+ fs_helper.mk_fs(u_boot_console.config, 'ext2', 0x200000, '2MB',
+ use_src_dir=True)
+ fs_helper.mk_fs(u_boot_console.config, 'fat32', 0x100000, '1MB',
+ use_src_dir=True)
+
@pytest.mark.buildconfigspec('cmd_bootflow')
def test_ut_dm_init_bootstd(u_boot_console):
"""Initialise data for bootflow tests"""