From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Anderson Date: Mon, 22 Mar 2021 09:26:57 -0400 Subject: [PATCH v5 22/41] test: Move dm_test_init() into test-main.c In-Reply-To: <20210308003517.1574569-22-sjg@chromium.org> References: <20210308003517.1574569-1-sjg@chromium.org> <20210308003517.1574569-22-sjg@chromium.org> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 3/7/21 7:34 PM, Simon Glass wrote: > 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 > --- > > (no changes since v1) > > include/test/ut.h | 9 --------- > test/dm/test-dm.c | 22 ---------------------- > test/test-main.c | 33 ++++++++++++++++++++++++++++++++- > 3 files changed, 32 insertions(+), 32 deletions(-) > > diff --git a/include/test/ut.h b/include/test/ut.h > index 6e56ca99c31..4e0aba9f700 100644 > --- a/include/test/ut.h > +++ b/include/test/ut.h > @@ -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 > diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c > index 15adc53f533..d601e497522 100644 > --- a/test/dm/test-dm.c > +++ b/test/dm/test-dm.c > @@ -12,7 +12,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -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; > diff --git a/test/test-main.c b/test/test-main.c > index f14b7b09f79..8b0121bdcec 100644 > --- a/test/test-main.c > +++ b/test/test-main.c > @@ -7,12 +7,43 @@ > #include > #include > #include > +#include This breaks non-sandbox unit testing, since they do not have a state.h. --Sean > #include > +#include > #include > #include > > 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); > >