diff --git a/include/test/test.h b/include/test/test.h index 0b124edd60..bf7d785d8e 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -124,4 +124,13 @@ enum { */ struct udevice *testbus_get_clear_removed(void); +static inline void arch_reset_for_test(void) +{ +#ifdef CONFIG_SANDBOX +#include + + state_reset_for_test(state_get_current()); +#endif +} + #endif /* __TEST_TEST_H */ diff --git a/test/test-main.c b/test/test-main.c index 46a0c2ee2f..8c852d72f4 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -46,9 +45,9 @@ static int dm_test_pre_run(struct unit_test_state *uts) uts->force_fail_alloc = false; uts->skip_post_probe = false; gd->dm_root = NULL; - if (!CONFIG_IS_ENABLED(OF_PLATDATA)) + if (IS_ENABLED(CONFIG_UT_DM) && !CONFIG_IS_ENABLED(OF_PLATDATA)) memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); - state_reset_for_test(state_get_current()); + arch_reset_for_test(); /* Determine whether to make the live tree available */ gd_set_of_root(of_live ? uts->of_root : NULL);