[PATCH 23/26] test: spl: Add a test for the MMC load method

Sean Anderson seanga2 at gmail.com
Thu Oct 12 06:12:52 CEST 2023


On 10/11/23 23:41, Simon Glass wrote:
> Hi Sean,
> 
> On Wed, 11 Oct 2023 at 18:56, Sean Anderson <seanga2 at gmail.com> wrote:
>>
>> Add a test for the MMC load method. This shows the general shape of tests
>> to come: The main test function calls do_spl_test_load with an appropriate
>> callback to write the image to the medium.
>>
>> Signed-off-by: Sean Anderson <seanga2 at gmail.com>
>> ---
>>
>>   configs/sandbox_noinst_defconfig |  2 +
>>   include/spl.h                    |  4 ++
>>   include/test/spl.h               | 30 +++++++++++++++
>>   test/image/Kconfig               |  1 +
>>   test/image/spl_load.c            | 36 +++++++++++++++++
>>   test/image/spl_load_fs.c         | 66 +++++++++++++++++++++++++++++---
>>   6 files changed, 134 insertions(+), 5 deletions(-)
>>
>> diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig
>> index 11be2dccf7d..4f16d9860d2 100644
>> --- a/configs/sandbox_noinst_defconfig
>> +++ b/configs/sandbox_noinst_defconfig
>> @@ -41,6 +41,8 @@ CONFIG_SPL_SYS_MALLOC=y
>>   CONFIG_SPL_HAS_CUSTOM_MALLOC_START=y
>>   CONFIG_SPL_CUSTOM_SYS_MALLOC_ADDR=0xa000000
>>   CONFIG_SPL_SYS_MALLOC_SIZE=0x4000000
>> +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
>> +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x0
>>   CONFIG_SPL_ENV_SUPPORT=y
>>   CONFIG_SPL_FS_EXT4=y
>>   CONFIG_SPL_I2C=y
>> diff --git a/include/spl.h b/include/spl.h
>> index 7d30fb57dac..8229d40adab 100644
>> --- a/include/spl.h
>> +++ b/include/spl.h
>> @@ -673,6 +673,10 @@ static inline const char *spl_loader_name(const struct spl_image_loader *loader)
>>          }
>>   #endif
>>
>> +#define SPL_LOAD_IMAGE_GET(_priority, _boot_device, _method) \
>> +       ll_entry_get(struct spl_image_loader, \
>> +                    _boot_device ## _priority ## _method, spl_image_loader)
>> +
>>   /* SPL FAT image functions */
>>   int spl_load_image_fat(struct spl_image_info *spl_image,
>>                         struct spl_boot_device *bootdev,
>> diff --git a/include/test/spl.h b/include/test/spl.h
>> index 7ae32a1020b..cfb52c90855 100644
>> --- a/include/test/spl.h
>> +++ b/include/test/spl.h
>> @@ -79,6 +79,36 @@ size_t create_image(void *dst, enum spl_test_image type,
>>   int check_image_info(struct unit_test_state *uts, struct spl_image_info *info1,
>>                       struct spl_image_info *info2);
>>
>> +/**
>> + * typedef write_image_t - Callback for writing an image
>> + * @uts: Current unit test state
>> + * @img: Image to write
>> + * @size: Size of @img
>> + *
>> + * Write @img to a location which will be read by a &struct spl_image_loader.
>> + *
>> + * Return: 0 on success or -1 on failure
>> + */
>> +typedef int write_image_t(struct unit_test_state *its, void *img, size_t size);
>> +
>> +/**
>> + * do_spl_test_load() - Test loading with an SPL image loader
>> + * @uts: Current unit test state
>> + * @test_name: Name of the current test
>> + * @type: Type of image to try loading
>> + * @loader: The loader to test
>> + * @write_image: Callback to write the image to the backing storage
>> + *
>> + * Test @loader, performing the common tasks of setting up the image and
>> + * checking it was loaded correctly. The caller must supply a @write_image
>> + * callback to write the image to a location which will be read by @loader.
>> + *
>> + * Return: 0 on success or -1 on failure
> 
> Do you mean 1 ?
> 
> Reviewed-by: Simon Glass <sjg at chromium.org>

Huh... I guess I do.

--Sean


More information about the U-Boot mailing list