From patchwork Thu Mar 4 13:50:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447342 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BweruMsa; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DrsqF0gB0z9sRf for ; Fri, 5 Mar 2021 00:56:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A12D1828AB; Thu, 4 Mar 2021 14:53:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BweruMsa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 722118280D; Thu, 4 Mar 2021 14:52:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7EBBF82765 for ; Thu, 4 Mar 2021 14:52:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x22f.google.com with SMTP id i21so27872947oii.2 for ; Thu, 04 Mar 2021 05:52:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l6e7TboSQnQr82M71fihSVASMToChUEpJBIrzlaVRFU=; b=BweruMsa5rzv920B4GC1KvKD34dNlvqwiHTiyi0L13oQ1r4Jj+CSzJXN5xTZAaSmx0 Xy1H+A24H2D6ZmaiqByjxvwdytK/SKQJyrFxryIGlsSgXrOMYXVye9UE+UI3NrQcRbpS VUJW/KyBEWKugoGaTc+aO6XDR6i+9N8HF4Hck= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l6e7TboSQnQr82M71fihSVASMToChUEpJBIrzlaVRFU=; b=eB0wE1HsUcGhplvzh8koNfCxy4u0aw8sM8K4kMZo9nP7mAomlSgtIRxnlQQjRFdbXT KxCkubeZnqAhmPqzez7Y7Lu2DmcxT/RZ9VwsDAVeDEJ+8NV4zp3TjsZLCPb0Gkvm8SEI O55Ry8oZAjNE8TN29bpVMT7OqcBFb3z2Lz/wpP7EEFJtXo6BoELu/uEylLY8oxu6V/UP vZK8ynuhEh6rQdbH2KI3K7A+g2DFJL3H2ijV7/cuDfM28ICzj+7dQZ/ImFYepsKe0oVZ gdEW9vR288Z6kqVn+Mf7e51SQBfnLEkkjrqEwTGnGIPm7+JD3LNgrbS+DJpExcLv9F/j diBg== X-Gm-Message-State: AOAM5317rKiclZDMaZhzIdDc7Ny81YD0YBCfYOli6OBda3czEuQdZ3bA 9a1RPdOayafgBu+pTXXAlTqTqsVyRSFhT7lj X-Google-Smtp-Source: ABdhPJx9eEPpmZAAOVQiZXIYwmQB2evUMjG9S8+VTeOguN7chuv59uOvn3cYBER3XOlW1rmbrfQwtw== X-Received: by 2002:a05:6808:10ca:: with SMTP id s10mr3051271ois.33.1614865923878; Thu, 04 Mar 2021 05:52:03 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:03 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 22/42] test: Move dm_test_init() into test-main.c Date: Thu, 4 Mar 2021 06:50:58 -0700 Message-Id: <20210304135118.643277-22-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean 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 #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);