mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 07:31:15 +00:00
test: Move dm_test_init() into test-main.c
Move this function into test-main so that all the init is in one place. Rename it so that its purpose is clearer. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
4a467c6de6
commit
c79705ea93
3 changed files with 32 additions and 32 deletions
|
@ -387,15 +387,6 @@ int test_pre_run(struct unit_test_state *uts, struct unit_test *test);
|
|||
*/
|
||||
int test_post_run(struct unit_test_state *uts, struct unit_test *test);
|
||||
|
||||
/**
|
||||
* dm_test_init() - Get ready to run a driver model test
|
||||
*
|
||||
* This clears out the driver model data structures. For sandbox it resets the
|
||||
* state structure.
|
||||
*
|
||||
* @uts: Test state
|
||||
*/
|
||||
int dm_test_init(struct unit_test_state *uts);
|
||||
|
||||
/**
|
||||
* ut_run_tests() - Run a set of tests
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <malloc.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <asm/state.h>
|
||||
#include <dm/test.h>
|
||||
#include <dm/root.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <test/test.h>
|
||||
|
@ -23,27 +22,6 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
|
||||
struct unit_test_state global_dm_test_state;
|
||||
|
||||
int dm_test_init(struct unit_test_state *uts)
|
||||
{
|
||||
bool of_live = uts->of_live;
|
||||
|
||||
uts->root = NULL;
|
||||
uts->testdev = NULL;
|
||||
uts->force_fail_alloc = false;
|
||||
uts->skip_post_probe = false;
|
||||
gd->dm_root = NULL;
|
||||
if (!CONFIG_IS_ENABLED(OF_PLATDATA))
|
||||
memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));
|
||||
state_reset_for_test(state_get_current());
|
||||
|
||||
/* Determine whether to make the live tree available */
|
||||
gd_set_of_root(of_live ? uts->of_root : NULL);
|
||||
ut_assertok(dm_init(of_live));
|
||||
uts->root = dm_root();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dm_test_destroy(struct unit_test_state *uts)
|
||||
{
|
||||
int id;
|
||||
|
|
|
@ -7,12 +7,43 @@
|
|||
#include <common.h>
|
||||
#include <console.h>
|
||||
#include <dm.h>
|
||||
#include <asm/state.h>
|
||||
#include <dm/root.h>
|
||||
#include <dm/test.h>
|
||||
#include <test/test.h>
|
||||
#include <test/ut.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
/**
|
||||
* dm_test_pre_run() - Get ready to run a driver model test
|
||||
*
|
||||
* This clears out the driver model data structures. For sandbox it resets the
|
||||
* state structure
|
||||
*
|
||||
* @uts: Test state
|
||||
*/
|
||||
static int dm_test_pre_run(struct unit_test_state *uts)
|
||||
{
|
||||
bool of_live = uts->of_live;
|
||||
|
||||
uts->root = NULL;
|
||||
uts->testdev = NULL;
|
||||
uts->force_fail_alloc = false;
|
||||
uts->skip_post_probe = false;
|
||||
gd->dm_root = NULL;
|
||||
if (!CONFIG_IS_ENABLED(OF_PLATDATA))
|
||||
memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));
|
||||
state_reset_for_test(state_get_current());
|
||||
|
||||
/* Determine whether to make the live tree available */
|
||||
gd_set_of_root(of_live ? uts->of_root : NULL);
|
||||
ut_assertok(dm_init(of_live));
|
||||
uts->root = dm_root();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ensure all the test devices are probed */
|
||||
static int do_autoprobe(struct unit_test_state *uts)
|
||||
{
|
||||
|
@ -31,7 +62,7 @@ static int do_autoprobe(struct unit_test_state *uts)
|
|||
int test_pre_run(struct unit_test_state *uts, struct unit_test *test)
|
||||
{
|
||||
if (test->flags & UT_TESTF_DM)
|
||||
ut_assertok(dm_test_init(uts));
|
||||
ut_assertok(dm_test_pre_run(uts));
|
||||
|
||||
ut_set_skip_delays(uts, false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue