Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95EB5ECAAD8 for ; Wed, 31 Aug 2022 03:11:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 58EF584A0D; Wed, 31 Aug 2022 05:10:06 +0200 (CEST) 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="BUkdhYOA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2327182A33; Wed, 31 Aug 2022 05:09:43 +0200 (CEST) Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (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 186A9849AC for ; Wed, 31 Aug 2022 05:09:39 +0200 (CEST) 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-ot1-x32a.google.com with SMTP id l5-20020a05683004a500b0063707ff8244so9429656otd.12 for ; Tue, 30 Aug 2022 20:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=rX9V97ipwyFn3KZIjX32K5fn5/QTrgMv8ckcFGnU8zo=; b=BUkdhYOAUBkqib69ANzc+RUdkkVr7FqGpvrPv1bUFYhJU72/EjbRch8MX/XDovO9zd 46SfsUJSeFqRrXjA3EgLpt3VS/vBnhEEiE3dA/nN2UfuwFlfciHX1NFmSsKEW6RhCRHm RWNYi12bHD93cxKz7uETeHvuDS7NzBWbHmVwM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=rX9V97ipwyFn3KZIjX32K5fn5/QTrgMv8ckcFGnU8zo=; b=WNjCJF9X3zyHnQaYFwQr5tYaYc7qH9lIn0L0Vc2xkxyDod8lBaUg2Uc2eTr80LpANS 7o/tom/b/7LeIzhIqugX2Nr40ohRqI3EJdChXcbXj8L0yxpUUiljwGecOoXlgZ5KP9/T yJuB7/JcXYybEOgrZJpobk9d028Fk1jot/9iYZgvWOSzLYTx+q179FJ77UwquywX9QnC /C4/HfI9VnmOXx4IYOz32ClQr8Lngw34i3Y0ubgJ+S4MlyL1wK4Q3ZfSmqbs5C/LgBgR lErh1MgMe+JCXvsPQbokCmPsMqY8UelzL9eQDKAtEhIKCyMlornKRUxI+fi44O6EV6iP lf9A== X-Gm-Message-State: ACgBeo2cGm7RziIwCdN11voDqBf51rL3LSTrU0QxbBEsJok1/0VXB2MW OZ4X5VrOQDC6ZYh9PRH+6ce11WRMMZlPtQ== X-Google-Smtp-Source: AA6agR6P+2r6z1wXxxBUCc/xLyczBzDork0mOjAee9NLboOPANUsuAR7kBRA5WZNr0D1jtSEG4nGNA== X-Received: by 2002:a9d:7dd6:0:b0:637:3819:baf6 with SMTP id k22-20020a9d7dd6000000b006373819baf6mr9951191otn.365.1661915351412; Tue, 30 Aug 2022 20:09:11 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id fp39-20020a05687065a700b00116d5103487sm9282605oab.31.2022.08.30.20.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 20:09:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Michal Simek , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Kishon Vijay Abraham I , Tom Rini , Simon Glass , AKASHI Takahiro , Heinrich Schuchardt , Jason Liu , Rasmus Villemoes , Stefan Roese Subject: [PATCH 12/21] test: Detect a change in the device tree Date: Tue, 30 Aug 2022 21:08:08 -0600 Message-Id: <20220831030817.27804-13-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220831030817.27804-1-sjg@chromium.org> References: <20220831030817.27804-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean If the device tree changes during a test and we cannot restore it, mark it as such so that future tests which need the live tree are skipped. Signed-off-by: Simon Glass --- include/asm-generic/global_data.h | 4 ++++ test/test-main.c | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 805a6fd6797..717cde129a9 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -635,6 +635,10 @@ enum gd_flags { * @GD_FLG_SMP_READY: SMP initialization is complete */ GD_FLG_SMP_READY = 0x80000, + /* + * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests + */ + GD_FLG_FDT_CHANGED = 0x100000, }; #endif /* __ASSEMBLY__ */ diff --git a/test/test-main.c b/test/test-main.c index 9dfa205faed..d285872d111 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -77,6 +77,10 @@ static int dm_test_pre_run(struct unit_test_state *uts) { bool of_live = uts->of_live; + if (of_live && (gd->flags & GD_FLG_FDT_CHANGED)) { + printf("Cannot run live tree test as device tree changed\n"); + return -EFAULT; + } uts->root = NULL; uts->testdev = NULL; uts->force_fail_alloc = false; @@ -110,9 +114,17 @@ static int dm_test_post_run(struct unit_test_state *uts) uint chksum; chksum = crc8(0, gd->fdt_blob, fdt_totalsize(gd->fdt_blob)); - - if (chksum != uts->fdt_chksum) + if (chksum != uts->fdt_chksum) { + /* + * We cannot run any more tests that need the + * live tree, since its strings point into the + * flat tree, which has changed. This likely + * means that at least some of the pointers from + * the live tree point to different things + */ printf("Device tree changed: cannot run live tree tests\n"); + gd->flags |= GD_FLG_FDT_CHANGED; + } break; } case FDTCHK_NONE: @@ -411,7 +423,8 @@ static int ut_run_test_live_flat(struct unit_test_state *uts, * or it is a core test. */ if (!(test->flags & UT_TESTF_LIVE_TREE) && - (!runs || ut_test_run_on_flattree(test))) { + (!runs || ut_test_run_on_flattree(test)) && + !(gd->flags & GD_FLG_FDT_CHANGED)) { uts->of_live = false; ut_assertok(ut_run_test(uts, test, test->name)); runs++; -- 2.37.2.672.g94769d06f0-goog