test: Add a private buffer for tests
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. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -486,6 +486,20 @@ ut_check_delta(last)
|
||||
Return the change in free memory since ``last`` was obtained from
|
||||
``ut_check_free()``. A positive value means more memory has been allocated.
|
||||
|
||||
Private buffer
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Each test has access to a private buffer ``uts->priv`` (256 bytes) for temporary
|
||||
data. This avoids the need to allocate memory or use global variables::
|
||||
|
||||
static int my_test(struct unit_test_state *uts)
|
||||
{
|
||||
snprintf(uts->priv, sizeof(uts->priv), "/%s", filename);
|
||||
/* use uts->priv as a path string */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Writing Python tests
|
||||
--------------------
|
||||
|
||||
Reference in New Issue
Block a user