From patchwork Wed Feb 3 12:44:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1435294 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=gbcZ62kl; 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 4DW1lx3Khhz9vDk for ; Wed, 3 Feb 2021 23:51:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9652E828B4; Wed, 3 Feb 2021 13:48:03 +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="gbcZ62kl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C791827E4; Wed, 3 Feb 2021 13:46:48 +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.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (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 1031482828 for ; Wed, 3 Feb 2021 13:46:35 +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-qt1-x836.google.com with SMTP id r20so13822443qtm.3 for ; Wed, 03 Feb 2021 04:46:35 -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=bx89cqob4YS135brN779g7KwBZtVL2bxGmNvE7pM8iI=; b=gbcZ62klhDJDqOSlbcbSFOPx4EHvo6V1rvuvjmK1Qy85cTfegYeYFUBwQaTyg3Zyp/ +Afstk9SW4A+eiIniHEpptDVNvwaH+XM7B/IOUZmRKblI8ub686Dzg1i02/e654dxNrw EiJH9luElwCFIbea2UQvmcDKITm7C7tEXWTGo= 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=bx89cqob4YS135brN779g7KwBZtVL2bxGmNvE7pM8iI=; b=XmvkFOSnNfDAkWON1PFJKBPknxc+B3Zbdhdf4uvI7Bi+vjqvcRzwa8Rn9YR1yQZtuM +pT5Bdb8Q+B+Iy2DLMQI2E8ZKybAEsGYEXTE8jMTamvA9FL23RawXBKfz3LlyzNBUN9N CMdRyPTT23IZ7MZJB0zXQSqjbo8DYF9ua3tGLUzTIO7nKVjKR1nm1Q+4mK1gJzj8JQ1f 0AXgTISvvLnzEHTQCD7lf2MQLZ4w26A4xNPcBQf6A71T4hlp4xwxevaHgyeqzPKVYnFG Nj8Bg5pAsT4bHNG7inJniM9bOkvg49Qnh+NcBMDbNUGUuZ7CeeiPGs2m0XwYJAWyVhhL HwLA== X-Gm-Message-State: AOAM532sSSia+VQDOAL0Z28luJv8kpofDRn98dL/uptn96LkPIF8ns5r MTjHBrf3x8xqj0B+JKA8A6WTsN5JXDz+OKkO X-Google-Smtp-Source: ABdhPJz1dAN6725dJKlr93RFbZQIqATlrpsTZ14uGjfKswM3keEHNM6ZiY7Cv75yE/yVC0FzcYaYmw== X-Received: by 2002:ac8:4e55:: with SMTP id e21mr2197708qtw.159.1612356393731; Wed, 03 Feb 2021 04:46:33 -0800 (PST) Received: from sjg1.roam.corp.google.com ([50.225.158.38]) by smtp.gmail.com with ESMTPSA id p26sm1560903qkk.6.2021.02.03.04.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 04:46:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Stephen Warren , Stephen Warren , Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH v3 31/41] test: Move restoring of driver model state to ut_run_list() Date: Wed, 3 Feb 2021 05:44:37 -0700 Message-Id: <20210203124447.2458527-31-sjg@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210203124447.2458527-1-sjg@chromium.org> References: <20210203124447.2458527-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.3 at phobos.denx.de X-Virus-Status: Clean Add this functionality to ut_run_list() so it can be removed from dm_test_run(). At this point all tests are run through ut_run_list(). Signed-off-by: Simon Glass --- (no changes since v1) test/dm/test-dm.c | 11 ----------- test/test-main.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 30046c71509..4f7d5736a53 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -23,21 +23,10 @@ int dm_test_run(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); - struct device_node *of_root; int ret; - of_root = gd_of_root(); ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name); - /* Put everything back to normal so that sandbox works as expected */ - gd_set_of_root(of_root); - gd->dm_root = NULL; - if (dm_init(CONFIG_IS_ENABLED(OF_LIVE))) - return CMD_RET_FAILURE; - dm_scan_plat(false); - if (!CONFIG_IS_ENABLED(OF_PLATDATA)) - dm_scan_fdt(false); - return ret ? CMD_RET_FAILURE : 0; } diff --git a/test/test-main.c b/test/test-main.c index 8138fb43875..6edd49f0b61 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -143,7 +143,7 @@ static bool test_matches(const char *prefix, const char *test_name, return false; } -/* +/** * ut_list_has_dm_tests() - Check if a list of tests has driver model ones * * @tests: List of tests to run @@ -162,6 +162,28 @@ static bool ut_list_has_dm_tests(struct unit_test *tests, int count) return false; } +/** + * dm_test_restore() Put things back to normal so sandbox works as expected + * + * @of_root: Value to set for of_root + * @return 0 if OK, -ve on error + */ +static int dm_test_restore(struct device_node *of_root) +{ + int ret; + + gd_set_of_root(of_root); + gd->dm_root = NULL; + ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE)); + if (ret) + return ret; + dm_scan_plat(false); + if (!CONFIG_IS_ENABLED(OF_PLATDATA)) + dm_scan_fdt(false); + + return 0; +} + /** * test_pre_run() - Handle any preparation needed to run a test * @@ -359,10 +381,12 @@ int ut_run_list(const char *category, const char *prefix, struct unit_test *tests, int count, const char *select_name) { struct unit_test_state uts = { .fail_count = 0 }; + bool has_dm_tests = false; int ret; if (!CONFIG_IS_ENABLED(OF_PLATDATA) && ut_list_has_dm_tests(tests, count)) { + has_dm_tests = true; /* * If we have no device tree, or it only has a root node, then * these * tests clearly aren't going to work... @@ -385,5 +409,9 @@ int ut_run_list(const char *category, const char *prefix, else printf("Failures: %d\n", uts.fail_count); + /* Best efforts only...ignore errors */ + if (has_dm_tests) + dm_test_restore(uts.of_root); + return ret; }