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 51D12C636D4 for ; Mon, 13 Feb 2023 16:07:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1AF485698; Mon, 13 Feb 2023 17:07:44 +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="mxAy6F88"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD86385679; Mon, 13 Feb 2023 17:07:36 +0100 (CET) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 45EA98582E for ; Mon, 13 Feb 2023 16:58:09 +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-il1-x130.google.com with SMTP id h29so3541580ila.8 for ; Mon, 13 Feb 2023 07:58:09 -0800 (PST) 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 :message-id:reply-to; bh=zbIpuUWpD5U5AMTc3UcUkGCyS/eF3RPiSDOpNjkjsuM=; b=mxAy6F88FGJAozISCFmJZXIxpWbpOGZiJP2iaVZ6vc+BrZYeYJmAnScXkVfQqSkCdW KhJMq+ULecicRDAZ/I5OHG9cb9LBal2sCNE2yQ/zOK2fUi13RmLlaq4lADwRMt2g2fTp PPrEg/t7oMEfINh6puMqb9LPhxPC7QObBC8PE= 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:message-id:reply-to; bh=zbIpuUWpD5U5AMTc3UcUkGCyS/eF3RPiSDOpNjkjsuM=; b=MYpIjb4iAiK06Kt/DfG4ieOfaYLozddQEC/lQ1gXNSOozdXvUdM7p7l/QlFcNG+16N TtNdA2Z7rY9jBLt/jEXDj6PK4LQ32seM0f0Aj6cLlcVHUGlaIgXIdANrsFytihOj+lWn vxUBoZGW/WiYWPOEzA8HhEiGZ+hDjs5gOo+PHcWz2AXWWq1/dPRt8pZD+YvMZg3NlcUW cPb6UIocH/VjqZD5X49aEmiVXPZa6b1618UBKm/HJ4sViKOQyFAHmNvAVQPsR04SVUmd 6PCM48V26T0fp4+DfU1Sw6TFr4+6HOzJN200gtJ3Ee+L8T+gnNt+DNTzi64X6F1VA1TO rwPg== X-Gm-Message-State: AO0yUKW3HjkzeiU8Fm2M3Ot6bYIvhvbzQF3MqXi5iRyPqz1AkWiIJhrJ H+vWvcliNKPtu8yE9SKL8G10kSt2MfjY73Wu X-Google-Smtp-Source: AK7set+E1lfshsBl9CiNsogFKzd+ihh8iy01BjreiA12s/jkk7KAqXH6sCgqo+nC21wzdKkMwLEpew== X-Received: by 2002:a05:6e02:b41:b0:315:2e7d:42f with SMTP id f1-20020a056e020b4100b003152e7d042fmr9303408ilu.11.1676303826268; Mon, 13 Feb 2023 07:57:06 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id b2-20020a923402000000b003154a4a039esm647463ila.5.2023.02.13.07.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 07:57:06 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , U-Boot Custodians , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH v5 11/11] dm: test: Add a test for the various migration combinations Date: Mon, 13 Feb 2023 08:56:41 -0700 Message-Id: <20230213155641.1208774-12-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog In-Reply-To: <20230213155641.1208774-1-sjg@chromium.org> References: <20230213155641.1208774-1-sjg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 Test that: - sandbox shows a warning when an unmigrated DT is used - sandbox fails to run when migration is turned off - sandbox_spl fails to build when migration is turned off Signed-off-by: Simon Glass --- Changes in v5: - Ensure that the old tags are supported in each commit of this series Changes in v4: - Add new patch with a test for the various migration combinations test/py/tests/test_of_migrate.py | 108 +++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 test/py/tests/test_of_migrate.py diff --git a/test/py/tests/test_of_migrate.py b/test/py/tests/test_of_migrate.py new file mode 100644 index 00000000000..910f7c05510 --- /dev/null +++ b/test/py/tests/test_of_migrate.py @@ -0,0 +1,108 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright 2023 Google LLC +# Written by Simon Glass + +"""Test handling of unmigrated u-boot,dm- tags""" + +import os +import pytest + +import u_boot_utils as util + +# This is needed for Azure, since the default '..' directory is not writeable +TMPDIR1 = '/tmp/test_no_migrate' +TMPDIR2 = '/tmp/test_no_migrate_spl' +TMPDIR3 = '/tmp/test_migrate' + +def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): + """Build an updated U-Boot with a slightly modified device tree + + Args: + cons (ConsoleBase): U-Boot console + replace_pair (tuple): + String to find + String to replace it with + board (str): Board to build + tmpdir (str): Temporary directory to use + disable_migrate (bool): True to disable CONFIG_OF_TAG_MIGRATE in build + """ + srcdir = cons.config.source_dir + build_dir = cons.config.build_dir + + # Get the source for the existing dts + dt_dir = os.path.join(build_dir, 'arch', 'sandbox', 'dts') + orig_fname = os.path.join(dt_dir, 'sandbox.dtb') + out_dts = os.path.join(dt_dir, 'sandbox_out.dts') + util.run_and_log(cons, ['dtc', orig_fname, '-I', 'dtb', '-O', 'dts', + '-o', out_dts]) + + # Update it to use an old tag + with open(out_dts) as inf: + data = inf.read() + data = data.replace(*replace_pair) + + dts_fname = os.path.join(dt_dir, 'sandbox_oldtag.dts') + with open(dts_fname, 'w') as outf: + print(data, file=outf) + dtb_fname = os.path.join(dt_dir, 'sandbox_oldtag.dtb') + util.run_and_log(cons, ['dtc', dts_fname, '-o', dtb_fname]) + + migrate = ['-a', '~CONFIG_OF_TAG_MIGRATE'] if disable_migrate else [] + + # Build sandbox with this new dtb, turning off OF_TAG_MIGRATE + env = dict(os.environ) + env['EXT_DTB'] = dtb_fname + env['DEVICE_TREE'] = 'sandbox_new' + env['NO_LTO'] = '1' # Speed up build + out = util.run_and_log( + cons, ['./tools/buildman/buildman', '-m', '--board', board, + *migrate, '-w', '-o', tmpdir], ignore_errors=True, env=env) + return out + +@pytest.mark.slow +@pytest.mark.boardspec('sandbox') +def test_of_no_migrate(u_boot_console): + """Test sandbox with old boot phase tags like u-boot,dm-pre-proper""" + cons = u_boot_console + + build_for_migrate(cons, ['bootph-some-ram', 'u-boot,dm-pre-proper'], + 'sandbox', TMPDIR1) + + # It should fail to run, since the lcd device will not be bound before + # relocation. so won't get its frame-buffer memory + out = util.run_and_log( + cons, [os.path.join(TMPDIR1, 'u-boot'), '-D', '-c', 'help'], + ignore_errors=True) + assert "Video device 'lcd' cannot allocate frame buffer memory" in out + + +@pytest.mark.slow +@pytest.mark.boardspec('sandbox_spl') +@pytest.mark.boardspec('spl_of_platdata_inst') +@pytest.mark.boardspec('!sandbox_tpl') +def test_of_no_migrate_spl(u_boot_console): + """Test sandbox with old boot phase tags like u-boot,dm-spl""" + cons = u_boot_console + + out = build_for_migrate(cons, ['bootph-pre-ram', 'u-boot,dm-spl'], + 'sandbox_spl', TMPDIR2) + + # It should fail to build, since the SPL DT will not include 'spl-test' + # node, among others + assert "undefined type ‘struct dtd_sandbox_spl_test’" in out + + +@pytest.mark.slow +@pytest.mark.boardspec('sandbox') +def test_of_migrate(u_boot_console): + """Test sandbox shows a message when tags were migrated""" + cons = u_boot_console + + build_for_migrate(cons, ['bootph-some-ram', 'u-boot,dm-pre-proper'], + 'sandbox', TMPDIR3, disable_migrate=False) + + # It should show a migration message + out = util.run_and_log( + cons, [os.path.join(TMPDIR3, 'u-boot'), '-D', '-c', 'help'], + ignore_errors=True) + assert "Warning: Device tree includes old 'u-boot,dm-' tags" in out -- 2.39.1.581.gbfd45094c4-goog