On 10/12/23 03:23, Heinrich Schuchardt wrote:
On 10/12/23 03:56, Sean Anderson wrote:
Several SPL functions try to avoid performing initialization twice by
caching devices. This is fine for regular boot, but does not work with
UNIT_TEST, since all devices are torn down after each test. Disable caching
so we don't use stale devices.

Signed-off-by: Sean Anderson <[email protected]>
---

  common/spl/spl_fat.c | 2 +-
  common/spl/spl_mmc.c | 3 ++-
  2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index c6e2526ade1..8bec9cce5ca 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -24,7 +24,7 @@ static int spl_register_fat_device(struct blk_desc 
*block_dev, int partition)
  {
      int err = 0;

-    if (fat_registered)
+    if (!CONFIG_IS_ENABLED(UNIT_TEST) && fat_registered)

Please, avoid separate code paths depending on CONFIG_UNIT_TESTS.

We shouldn't change normal behavior if unit tests are not running. It is
preferable to let the unit test framework call a new function resetting
fat_registered when needed. This will allow future tests to test all
code paths separately.

OK, that sounds reasonable to me.

--Sean

Reply via email to