test: Move dm_test_destroy() into test-main.c
Move this function into the common test runner and rename it to dm_test_post_run() so that its purpose is clear. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -22,26 +22,6 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||||||
|
|
||||||
struct unit_test_state global_dm_test_state;
|
struct unit_test_state global_dm_test_state;
|
||||||
|
|
||||||
static int dm_test_destroy(struct unit_test_state *uts)
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
|
|
||||||
for (id = 0; id < UCLASS_COUNT; id++) {
|
|
||||||
struct uclass *uc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the uclass doesn't exist we don't want to create it. So
|
|
||||||
* check that here before we call uclass_find_device().
|
|
||||||
*/
|
|
||||||
uc = uclass_find(id);
|
|
||||||
if (!uc)
|
|
||||||
continue;
|
|
||||||
ut_assertok(uclass_destroy(uc));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
|
static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
|
||||||
bool of_live)
|
bool of_live)
|
||||||
{
|
{
|
||||||
@@ -57,8 +37,6 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
|
|||||||
|
|
||||||
ut_assertok(test_post_run(uts, test));
|
ut_assertok(test_post_run(uts, test));
|
||||||
|
|
||||||
ut_assertok(dm_test_destroy(uts));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include <asm/state.h>
|
#include <asm/state.h>
|
||||||
#include <dm/root.h>
|
#include <dm/root.h>
|
||||||
#include <dm/test.h>
|
#include <dm/test.h>
|
||||||
|
#include <dm/uclass-internal.h>
|
||||||
#include <test/test.h>
|
#include <test/test.h>
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
|
|
||||||
@@ -44,6 +45,26 @@ static int dm_test_pre_run(struct unit_test_state *uts)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dm_test_post_run(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
|
||||||
|
for (id = 0; id < UCLASS_COUNT; id++) {
|
||||||
|
struct uclass *uc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the uclass doesn't exist we don't want to create it. So
|
||||||
|
* check that here before we call uclass_find_device().
|
||||||
|
*/
|
||||||
|
uc = uclass_find(id);
|
||||||
|
if (!uc)
|
||||||
|
continue;
|
||||||
|
ut_assertok(uclass_destroy(uc));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ensure all the test devices are probed */
|
/* Ensure all the test devices are probed */
|
||||||
static int do_autoprobe(struct unit_test_state *uts)
|
static int do_autoprobe(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
@@ -94,6 +115,8 @@ 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)
|
int test_post_run(struct unit_test_state *uts, struct unit_test *test)
|
||||||
{
|
{
|
||||||
ut_unsilence_console(uts);
|
ut_unsilence_console(uts);
|
||||||
|
if (test->flags & UT_TESTF_DM)
|
||||||
|
ut_assertok(dm_test_post_run(uts));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user