aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSean Anderson2023-10-14 16:48:02 -0400
committerTom Rini2023-10-17 20:50:52 -0400
commit6ba8ecaa96cc4ede483a353b18c19715b27ba19a (patch)
tree3b45a725d78f6f8fc331cdcac3897b81105737d6 /include
parent6c5d0d9398cdfa2af7bbe1b98f0d46295e71fb62 (diff)
test: spl: Add a test for the MMC load method
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@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/spl.h4
-rw-r--r--include/test/spl.h30
2 files changed, 34 insertions, 0 deletions
diff --git a/include/spl.h b/include/spl.h
index 03a4a83eb24..ad1543ae16b 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 */
/**
diff --git a/include/test/spl.h b/include/test/spl.h
index 7dba3f03d07..009c6b35462 100644
--- a/include/test/spl.h
+++ b/include/test/spl.h
@@ -80,6 +80,36 @@ 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
+ */
+int do_spl_test_load(struct unit_test_state *uts, const char *test_name,
+ enum spl_test_image type, struct spl_image_loader *loader,
+ write_image_t write_image);
+
+/**
* image_supported() - Determine whether an image type is supported
* @type: The image type to check
*