Merge branch '2021-05-26-assorted-bugfixes'

This commit is contained in:
Tom Rini 2021-05-27 07:41:25 -04:00
commit a0ecfa568d
10 changed files with 89 additions and 61 deletions

View File

@ -189,7 +189,6 @@ sandbox_spl test.py:
<<: *buildman_and_testpy_dfn
sandbox_noinst_test.py:
tags: [ 'all' ]
variables:
TEST_PY_BD: "sandbox_noinst"
TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl"

View File

@ -4,6 +4,7 @@
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
#include <common.h>
#include <init.h>
#include <asm/global_data.h>

View File

@ -714,7 +714,11 @@ static int part_get_info_by_dev_and_name(const char *dev_iface,
int ret;
/* Separate device and partition name specification */
if (dev_part_str)
part_str = strchr(dev_part_str, '#');
else
part_str = NULL;
if (part_str) {
dup_str = strdup(dev_part_str);
dup_str[part_str - dev_part_str] = 0;

View File

@ -509,19 +509,13 @@ static int single_of_to_plat(struct udevice *dev)
return -EINVAL;
}
addr = dev_read_addr_size(dev, "reg", &size);
addr = dev_read_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE) {
dev_err(dev, "failed to get base register size\n");
dev_err(dev, "failed to get base register address\n");
return -EINVAL;
}
pdata->offset = size - pdata->width / BITS_PER_BYTE;
addr = dev_read_addr(dev);
if (addr == FDT_ADDR_T_NONE) {
dev_dbg(dev, "no valid base register address\n");
return -EINVAL;
}
pdata->base = addr;
ret = dev_read_u32(dev, "pinctrl-single,function-mask", &pdata->mask);

View File

@ -291,7 +291,7 @@ error_out:
int btrfs_read_dev_super(struct blk_desc *desc, struct disk_partition *part,
struct btrfs_super_block *sb)
{
char tmp[BTRFS_SUPER_INFO_SIZE];
ALLOC_CACHE_ALIGN_BUFFER(char, tmp, BTRFS_SUPER_INFO_SIZE);
struct btrfs_super_block *buf = (struct btrfs_super_block *)tmp;
int ret;

View File

@ -876,7 +876,7 @@ int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp)
char **token_list = NULL, *path = NULL;
u32 *pos_list = NULL;
dirs = malloc(sizeof(*dirs));
dirs = calloc(1, sizeof(*dirs));
if (!dirs)
return -EINVAL;

View File

@ -177,23 +177,6 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
} \
}
/*
* Assert that two string expressions are equal, up to length of the
* first
*/
#define ut_asserteq_strn(expr1, expr2) { \
const char *_val1 = (expr1), *_val2 = (expr2); \
int _len = strlen(_val1); \
\
if (memcmp(_val1, _val2, _len)) { \
ut_failf(uts, __FILE__, __LINE__, __func__, \
#expr1 " = " #expr2, \
"Expected \"%.*s\", got \"%.*s\"", \
_len, _val1, _len, _val2); \
return CMD_RET_FAILURE; \
} \
}
/* Assert that two memory areas are equal */
#define ut_asserteq_mem(expr1, expr2, len) { \
const u8 *_val1 = (u8 *)(expr1), *_val2 = (u8 *)(expr2); \

View File

@ -11,11 +11,25 @@
#include <dm/test.h>
#include <test/ut.h>
static int dm_test_part(struct unit_test_state *uts)
static inline int do_test(struct unit_test_state *uts, int expected,
const char *part_str, bool whole)
{
char str_disk_guid[UUID_STR_LEN + 1];
struct blk_desc *mmc_dev_desc;
struct disk_partition part_info;
ut_asserteq(expected,
part_get_info_by_dev_and_name_or_num("mmc", part_str,
&mmc_dev_desc,
&part_info, whole));
return 0;
}
static int dm_test_part(struct unit_test_state *uts)
{
char *oldbootdevice;
char str_disk_guid[UUID_STR_LEN + 1];
int ret;
struct blk_desc *mmc_dev_desc;
struct disk_partition parts[2] = {
{
.start = 48, /* GPT data takes up the first 34 blocks or so */
@ -38,16 +52,22 @@ static int dm_test_part(struct unit_test_state *uts)
ut_assertok(gpt_restore(mmc_dev_desc, str_disk_guid, parts,
ARRAY_SIZE(parts)));
#define test(expected, part_str, whole) \
ut_asserteq(expected, \
part_get_info_by_dev_and_name_or_num("mmc", part_str, \
&mmc_dev_desc, \
&part_info, whole))
oldbootdevice = env_get("bootdevice");
#define test(expected, part_str, whole) do { \
ret = do_test(uts, expected, part_str, whole); \
if (ret) \
goto out; \
} while (0)
env_set("bootdevice", NULL);
test(-ENODEV, NULL, true);
test(-ENODEV, "", true);
env_set("bootdevice", "0");
test(0, NULL, true);
test(0, "", true);
env_set("bootdevice", "1");
test(1, NULL, false);
test(1, "", false);
test(1, "-", false);
env_set("bootdevice", "");
@ -70,7 +90,10 @@ static int dm_test_part(struct unit_test_state *uts)
test(-EINVAL, "1#bogus", false);
test(1, "1#test1", false);
test(2, "1#test2", false);
ret = 0;
return 0;
out:
env_set("bootdevice", oldbootdevice);
return ret;
}
DM_TEST(dm_test_part, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);

View File

@ -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)