[PATCH 03/12] test: Add a private buffer for tests

Simon Glass sjg at chromium.org
Sun Apr 12 03:34:31 CEST 2026


From: Simon Glass <simon.glass at canonical.com>

Add a priv[] buffer to struct unit_test_state that tests can use for
their own data. This avoids the need to allocate memory or use global
variables for test-specific state.

Signed-off-by: Simon Glass <simon.glass at canonical.com>
Signed-off-by: Simon Glass <sjg at chromium.org>
---

 include/test/test.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/test/test.h b/include/test/test.h
index 0f2b68a5dee..f8a80a88959 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -9,6 +9,8 @@
 #include <malloc.h>
 #include <linux/bitops.h>
 
+#define UT_PRIV_SIZE	256
+
 /**
  * struct ut_stats - Statistics about tests run
  *
@@ -53,6 +55,7 @@ struct ut_stats {
  * @old_bloblist: stores the old gd->bloblist pointer
  * @expect_str: Temporary string used to hold expected string value
  * @actual_str: Temporary string used to hold actual string value
+ * @priv: Private data for tests to use as needed
  */
 struct unit_test_state {
 	struct ut_stats cur;
@@ -78,6 +81,7 @@ struct unit_test_state {
 	void *old_bloblist;
 	char expect_str[512];
 	char actual_str[512];
+	char priv[UT_PRIV_SIZE];
 };
 
 /* Test flags for each test */
-- 
2.43.0



More information about the U-Boot mailing list