summaryrefslogtreecommitdiff
path: root/test/dm/test-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-07 17:35:04 -0700
committerTom Rini <trini@konsulko.com>2021-03-12 09:57:30 -0500
commitfe806861a98b4ad524d070c6d7b9d20fd475ec6f (patch)
tree59df6d3172d2ec6758deb6ee14fa872be5837b6a /test/dm/test-uclass.c
parentd2281bb09b0ebf580f8efe23c84c240a2f3ea9bb (diff)
test: Use a local variable for test state
At present we use a global test state for all driver-model tests. Make use of a local struct like we do with the other tests. To make this work, add functions to get and set this state. When a test starts, the state is set (so it can be used in the test). When a test finishes, the state is unset, so it cannot be used by mistake. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/test-uclass.c')
-rw-r--r--test/dm/test-uclass.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c
index f4b540c9278..067701734a0 100644
--- a/test/dm/test-uclass.c
+++ b/test/dm/test-uclass.c
@@ -17,8 +17,6 @@
#include <test/test.h>
#include <test/ut.h>
-static struct unit_test_state *uts = &global_dm_test_state;
-
int test_ping(struct udevice *dev, int pingval, int *pingret)
{
const struct test_ops *ops = device_get_ops(dev);
@@ -31,6 +29,7 @@ int test_ping(struct udevice *dev, int pingval, int *pingret)
static int test_post_bind(struct udevice *dev)
{
+ struct unit_test_state *uts = test_get_state();
struct dm_test_perdev_uc_pdata *uc_pdata;
dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++;
@@ -56,6 +55,7 @@ static int test_pre_unbind(struct udevice *dev)
static int test_pre_probe(struct udevice *dev)
{
struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev);
+ struct unit_test_state *uts = test_get_state();
dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]++;
ut_assert(priv);
@@ -66,6 +66,7 @@ static int test_pre_probe(struct udevice *dev)
static int test_post_probe(struct udevice *dev)
{
+ struct unit_test_state *uts = test_get_state();
struct udevice *prev = list_entry(dev->uclass_node.prev,
struct udevice, uclass_node);
@@ -100,6 +101,8 @@ static int test_pre_remove(struct udevice *dev)
static int test_init(struct uclass *uc)
{
+ struct unit_test_state *uts = test_get_state();
+
dm_testdrv_op_count[DM_TEST_OP_INIT]++;
ut_assert(uclass_get_priv(uc));