All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v4 20/42] test: Handle driver model reinit in test_pre_run()
Date: Thu,  4 Mar 2021 06:50:56 -0700	[thread overview]
Message-ID: <20210304135118.643277-20-sjg@chromium.org> (raw)
In-Reply-To: <20210304135118.643277-1-sjg@chromium.org>

For driver model tests we want to reinit the data structures so that
everything is in a known state before the test runs. This avoids one test
changing something that breaks a subsequent tests.

Move the call for this into test_pre_run().

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 include/test/test.h |  2 ++
 include/test/ut.h   | 10 ++++++++++
 test/dm/test-dm.c   |  6 +++---
 test/test-main.c    |  3 +++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/test/test.h b/include/test/test.h
index d282cb2362d..6997568cc07 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -15,6 +15,7 @@
  * @fail_count: Number of tests that failed
  * @start: Store the starting mallinfo when doing leak test
  * @priv: A pointer to some other info some suites want to track
+ * @of_live: true to use livetree if available, false to use flattree
  * @of_root: Record of the livetree root node (used for setting up tests)
  * @expect_str: Temporary string used to hold expected string value
  * @actual_str: Temporary string used to hold actual string value
@@ -24,6 +25,7 @@ struct unit_test_state {
 	struct mallinfo start;
 	void *priv;
 	struct device_node *of_root;
+	bool of_live;
 	char expect_str[256];
 	char actual_str[256];
 };
diff --git a/include/test/ut.h b/include/test/ut.h
index e5ec18e60b0..6e56ca99c31 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -387,6 +387,16 @@ 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 569ffbbad93..ceeac3fd361 100644
--- a/test/dm/test-dm.c
+++ b/test/dm/test-dm.c
@@ -24,10 +24,10 @@ DECLARE_GLOBAL_DATA_PTR;
 struct unit_test_state global_dm_test_state;
 static struct dm_test_state _global_priv_dm_test_state;
 
-/* Get ready for testing */
-static int dm_test_init(struct unit_test_state *uts, bool of_live)
+int dm_test_init(struct unit_test_state *uts)
 {
 	struct dm_test_state *dms = uts->priv;
+	bool of_live = uts->of_live;
 
 	memset(dms, '\0', sizeof(*dms));
 	gd->dm_root = NULL;
@@ -70,7 +70,7 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
 
 	printf("Test: %s: %s%s\n", test->name, fname,
 	       !of_live ? " (flat tree)" : "");
-	ut_assertok(dm_test_init(uts, of_live));
+	uts->of_live = of_live;
 
 	ut_assertok(test_pre_run(uts, test));
 
diff --git a/test/test-main.c b/test/test-main.c
index 6f0d32f7e27..f14b7b09f79 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -30,6 +30,9 @@ 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_set_skip_delays(uts, false);
 
 	uts->start = mallinfo();
-- 
2.30.1.766.gb4fecdf3b7-goog

  parent reply	other threads:[~2021-03-04 13:50 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 13:50 [PATCH v4 00/42] test: Refactor tests to have a single test runner Simon Glass
2021-03-04 13:50 ` [PATCH v4 01/42] dm: core: Fix allocation of empty of-platdata Simon Glass
2021-03-04 13:50 ` [PATCH v4 02/42] doc: Tidy up testing section Simon Glass
2021-03-04 15:32   ` Heinrich Schuchardt
2021-03-04 13:50 ` [PATCH v4 03/42] doc: Document make tcheck Simon Glass
2021-03-04 13:50 ` [PATCH v4 04/42] sandbox: Drop the 'starting...' message unless testing Simon Glass
2021-03-04 15:38   ` Heinrich Schuchardt
2021-03-04 13:50 ` [PATCH v4 05/42] test: Re-enable test_ofplatdata Simon Glass
2021-03-04 13:50 ` [PATCH v4 06/42] doc: Explain how to run tests without pytest Simon Glass
2021-03-04 16:13   ` Heinrich Schuchardt
2021-03-07 22:49     ` Simon Glass
2021-03-04 13:50 ` [PATCH v4 07/42] doc: Document how sandbox_spl_tests are run Simon Glass
2021-03-04 13:50 ` [PATCH v4 08/42] test: Correct setexpr test prefix Simon Glass
2021-03-04 13:50 ` [PATCH v4 09/42] test: Mark all driver model tests with a flag Simon Glass
2021-03-04 13:50 ` [PATCH v4 10/42] test: Rename test-main.c to test-dm.c Simon Glass
2021-03-04 13:50 ` [PATCH v4 11/42] test: Add an overall test runner Simon Glass
2021-03-04 13:50 ` [PATCH v4 12/42] test: Create pre/post-run functions Simon Glass
2021-03-04 13:50 ` [PATCH v4 13/42] test: Call test_pre/post_run() from driver model tests Simon Glass
2021-03-04 13:50 ` [PATCH v4 14/42] test: Move dm_extended_scan() to test_pre_run() Simon Glass
2021-03-04 13:50 ` [PATCH v4 15/42] test: Move do_autoprobe() " Simon Glass
2021-03-04 13:50 ` [PATCH v4 16/42] test: Move dm_scan_plat() " Simon Glass
2021-03-04 13:50 ` [PATCH v4 17/42] test: Drop mallinfo() work-around Simon Glass
2021-03-04 13:50 ` [PATCH v4 18/42] test: Move console silencing to test_pre_run() Simon Glass
2021-03-04 13:50 ` [PATCH v4 19/42] test: Move delay skipping " Simon Glass
2021-03-04 13:50 ` Simon Glass [this message]
2021-03-04 13:50 ` [PATCH v4 21/42] test: Drop struct dm_test_state Simon Glass
2021-03-04 13:50 ` [PATCH v4 22/42] test: Move dm_test_init() into test-main.c Simon Glass
2021-03-04 13:50 ` [PATCH v4 23/42] test: Move dm_test_destroy() " Simon Glass
2021-03-04 13:51 ` [PATCH v4 24/42] test: Move test running into a separate function Simon Glass
2021-03-04 13:51 ` [PATCH v4 25/42] test: Use ut_run_test() to run driver model tests Simon Glass
2021-03-04 13:51 ` [PATCH v4 26/42] test: Drop dm_do_test() Simon Glass
2021-03-04 13:51 ` [PATCH v4 27/42] test: Add ut_run_test_live_flat() to run tests twice Simon Glass
2021-03-04 13:51 ` [PATCH v4 28/42] test: Use a local variable for test state Simon Glass
2021-03-04 13:51 ` [PATCH v4 29/42] test: Run driver-model tests using ut_run_list() Simon Glass
2021-03-04 13:51 ` [PATCH v4 30/42] test: Use return values in dm_test_run() Simon Glass
2021-03-04 13:51 ` [PATCH v4 31/42] test: Move the devicetree check into ut_run_list() Simon Glass
2021-03-04 13:51 ` [PATCH v4 32/42] test: Move restoring of driver model state to ut_run_list() Simon Glass
2021-03-04 13:51 ` [PATCH v4 33/42] test: log: Rename log main test file to log_ut.c Simon Glass
2021-03-04 17:18   ` Heinrich Schuchardt
2021-03-04 13:51 ` [PATCH v4 34/42] test: Add a macros for finding tests in linker_lists Simon Glass
2021-03-04 13:51 ` [PATCH v4 35/42] test: Rename all linker lists to have a ut_ prefix Simon Glass
2021-03-04 15:28   ` Heinrich Schuchardt
2021-03-05  4:09     ` Simon Glass
2021-03-04 13:51 ` [PATCH v4 36/42] test: Allow SPL to run any available test Simon Glass
2021-03-04 13:51 ` [PATCH v4 37/42] sandbox: Update os_find_u_boot() to find the .img file Simon Glass
2021-03-04 13:51 ` [PATCH v4 38/42] spl: Convert spl_fit to work with sandbox Simon Glass
2021-03-04 13:51 ` [PATCH v4 39/42] doc: Move coccinelle into its own section Simon Glass
2021-03-04 17:23   ` Heinrich Schuchardt
2021-03-07 22:18     ` Simon Glass
2021-03-04 13:51 ` [PATCH v4 40/42] spl: test: Add a test for spl_load_simple_fit() Simon Glass
2021-03-04 13:51 ` [PATCH v4 41/42] test: sandbox: Move sandbox test docs into doc/develop Simon Glass
2021-03-04 13:51 ` [PATCH v4 42/42] doc: Explain briefly how to write new tests Simon Glass
2021-03-04 18:14   ` Heinrich Schuchardt
2021-03-07 23:21     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210304135118.643277-20-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.