From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A02E33C8737 for ; Wed, 26 Aug 2026 09:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787738037; cv=none; b=ao1doGxFeR8DrK771c/jYMSPKFlPwif0m4DCLjrG9VFoXMS0h0FdjuAPUWseOwLMV/3I3y/xXCwXQBHHCmtywk4jNdXoVk/bz7ThrOdJNphm/DE+Dn4LiqQXi0mPljwzwer5/eu7ETlii3lifEvVJSFqaNpPCpd8qFAl3ouTVjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787738037; c=relaxed/simple; bh=zW+C00oPGGlznz+vbQZbK4mmD8KDpuIYgjGZ+r6+9P8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ny2kJVYW/u4rxnFemV0XI6U3uMVcI7uPu4Iy5TAciMYb+A/Q6SpZmz/8DCDsV6H3J41k95TKhEiqNpUihisMdwcZiAhnWXNnmE1vqzTEP6WG3VD7mOJ/j++eVcsGiBVhPJ42zEYkRV3XYJ6Yh3UcBxcEwsnvpAt6sDDO7UOWmiU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=EcZk3DGJ; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="EcZk3DGJ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 50ABD1A183A; Wed, 26 Aug 2026 09:53:54 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 24672604EC; Wed, 26 Aug 2026 09:53:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 89E7C11C7AD6D; Wed, 26 Aug 2026 11:53:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1787738033; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=8cMhEqVQh2DycY88vB1DpGb7R/2IixVPGtElx+1YGBA=; b=EcZk3DGJT53ajfsSDrSXalR0EKKeFxCvSnq0VmvrsSdmOl5sgK0G4a0h08kSwJ+PKKuc2K MGg3W1i3ZLMr7LEBd3NRR8gxbHNZWHlSggjXYYUgFFIjlMOP+WqngXXQXEbb+mxtShQotr mjL+31vbTMpDSMIBrXe5iH4zzCZEeqdMhBQ6KOxx5ysc/LlEYUDga9mk32nVhPgcfZBCo6 eNTifKnM4/g1WNqoBLLG6QCn7SrOYsimJ4JQma/GaPBkIv2PqOfn7OFuK2czoPFNRQcoQ1 xAVuKhgwodiQV4NP1wwtLGnNs327Viyu3fZU1kdVUw2yNuAEYSD/CSQvqKwG3A== From: Herve Codina To: David Gibson , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Laurent Pinchart , David Lechner , Ayush Singh , Geert Uytterhoeven , devicetree-compiler@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree-spec@vger.kernel.org, Hui Pu , Ian Ray , Luca Ceresoli , Thomas Petazzoni , Herve Codina Subject: [RFC PATCH v2 65/74] tests: Add a first basic test for fdtaddon Date: Wed, 26 Aug 2026 11:49:34 +0200 Message-ID: <20260826094950.1088288-66-herve.codina@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260826094950.1088288-1-herve.codina@bootlin.com> References: <20260826094950.1088288-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: devicetree-spec@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 The fdtaddon tests family goal is to test features related the application of an addon to a base device tree. This first basic test added in fdtaddon tests is related to the application of a simple addon. The terminology used in the test is the following: - dts: A 'full' device tree source. This can be either a base device tree or a merged device tree (i.e. a base device tree where an addon has been applied to). - dtb: A 'full' device tree blob This can be either a dtb generated by dtc from a dts or the output of the fdtaddon command. - dtsa: An addon device tree source A dts with the '/addon/' keyword. - dtba: An addon device tree blob This a device tree blob generated from a dtsa. With this terminology in mind, the test pattern is the following: - Generate the base tree dtb (fdtaddon_base.dtb) - Check this generated dtb against expected contents - Generate a dtba (xxx.dtba) from an input dtsa - Check this generated dtba against expected contents - Apply the dtba to the base tree dtb at node-a1 (xxx-merged1.dtb) - Check this generated dtb against expected contents - Generate a dts (xxx-merged1.dtb.dts) from the generated xxx-merged1.dtb - Check this generated dts against expected contents - Apply the dtba to the base tree dtb at node-a2 (xxx-merged2.dtb) - Check this generated dtb against expected contents - Generate a dts (xxx-merged2.dtb.dts) from the generated xxx-merged2.dtb - Check this generated dts against expected contents Even if only one basic addon dsta is currently provided in this tests introduction, use a loop in order to ease future addition consisting in testing other features based on more complex addon dtsa. Signed-off-by: Herve Codina --- tests/fdtaddon_base.dtb.expect | 24 ++++++++++ tests/fdtaddon_base.dts | 27 +++++++++++ tests/fdtaddon_basics1-merged1.dtb.dts.expect | 35 ++++++++++++++ tests/fdtaddon_basics1-merged1.dtb.expect | 27 +++++++++++ tests/fdtaddon_basics1-merged2.dtb.dts.expect | 35 ++++++++++++++ tests/fdtaddon_basics1-merged2.dtb.expect | 27 +++++++++++ tests/fdtaddon_basics1.dtba.expect | 8 ++++ tests/fdtaddon_basics1.dtsa | 13 +++++ tests/meson.build | 1 + tests/run_tests.sh | 47 ++++++++++++++++++- tests/testutils.sh | 1 + 11 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 tests/fdtaddon_base.dtb.expect create mode 100644 tests/fdtaddon_base.dts create mode 100644 tests/fdtaddon_basics1-merged1.dtb.dts.expect create mode 100644 tests/fdtaddon_basics1-merged1.dtb.expect create mode 100644 tests/fdtaddon_basics1-merged2.dtb.dts.expect create mode 100644 tests/fdtaddon_basics1-merged2.dtb.expect create mode 100644 tests/fdtaddon_basics1.dtba.expect create mode 100644 tests/fdtaddon_basics1.dtsa diff --git a/tests/fdtaddon_base.dtb.expect b/tests/fdtaddon_base.dtb.expect new file mode 100644 index 00000000..2da5be4d --- /dev/null +++ b/tests/fdtaddon_base.dtb.expect @@ -0,0 +1,24 @@ +/dts-v1/; + +/ { + base-node { + sub-node { + prop = <0x00000000>; + phandle = <0x00000002>; + }; + }; + somewhere { + node-a1 { + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000001 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + compatible = "abc,aaa"; + phandle = <0x00000001>; + }; + node-a2 { + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000003 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + compatible = "abc,aaa"; + phandle = <0x00000003>; + }; + }; +}; diff --git a/tests/fdtaddon_base.dts b/tests/fdtaddon_base.dts new file mode 100644 index 00000000..3b001461 --- /dev/null +++ b/tests/fdtaddon_base.dts @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) +/* + * Copyright (C) 2026 Bootlin + */ + +/dts-v1/; + +/ { + base-node { + other_a: sub-node { + prop = <0>; + }; + }; + + somewhere { + node_a1: node-a1 { + compatible = "abc,aaa"; + /export/ node_a: &node_a1; + /export/ other: &other_a; + }; + node_a2: node-a2 { + compatible = "abc,aaa"; + /export/ node_a: &node_a2; + /export/ other: &other_a; + }; + }; +}; diff --git a/tests/fdtaddon_basics1-merged1.dtb.dts.expect b/tests/fdtaddon_basics1-merged1.dtb.dts.expect new file mode 100644 index 00000000..927733c1 --- /dev/null +++ b/tests/fdtaddon_basics1-merged1.dtb.dts.expect @@ -0,0 +1,35 @@ +/dts-v1/; + +/ { + + base-node { + + sub-node { + prop = <0x00>; + phandle = <0x02>; + }; + }; + + somewhere { + + node-a1 { + compatible = "abc,aaa"; + phandle = <0x01>; + + /export/ node_a: &{/somewhere/node-a1}; + /export/ other: &{/base-node/sub-node}; + + addon-node { + prop = <0x00>; + }; + }; + + node-a2 { + compatible = "abc,aaa"; + phandle = <0x03>; + + /export/ node_a: &{/somewhere/node-a2}; + /export/ other: &{/base-node/sub-node}; + }; + }; +}; diff --git a/tests/fdtaddon_basics1-merged1.dtb.expect b/tests/fdtaddon_basics1-merged1.dtb.expect new file mode 100644 index 00000000..966a43df --- /dev/null +++ b/tests/fdtaddon_basics1-merged1.dtb.expect @@ -0,0 +1,27 @@ +/dts-v1/; + +/ { + base-node { + sub-node { + prop = <0x00000000>; + phandle = <0x00000002>; + }; + }; + somewhere { + node-a1 { + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000001 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + compatible = "abc,aaa"; + phandle = <0x00000001>; + addon-node { + prop = <0x00000000>; + }; + }; + node-a2 { + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000003 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + compatible = "abc,aaa"; + phandle = <0x00000003>; + }; + }; +}; diff --git a/tests/fdtaddon_basics1-merged2.dtb.dts.expect b/tests/fdtaddon_basics1-merged2.dtb.dts.expect new file mode 100644 index 00000000..d85567b7 --- /dev/null +++ b/tests/fdtaddon_basics1-merged2.dtb.dts.expect @@ -0,0 +1,35 @@ +/dts-v1/; + +/ { + + base-node { + + sub-node { + prop = <0x00>; + phandle = <0x02>; + }; + }; + + somewhere { + + node-a1 { + compatible = "abc,aaa"; + phandle = <0x01>; + + /export/ node_a: &{/somewhere/node-a1}; + /export/ other: &{/base-node/sub-node}; + }; + + node-a2 { + compatible = "abc,aaa"; + phandle = <0x03>; + + /export/ node_a: &{/somewhere/node-a2}; + /export/ other: &{/base-node/sub-node}; + + addon-node { + prop = <0x00>; + }; + }; + }; +}; diff --git a/tests/fdtaddon_basics1-merged2.dtb.expect b/tests/fdtaddon_basics1-merged2.dtb.expect new file mode 100644 index 00000000..ca9c7ba0 --- /dev/null +++ b/tests/fdtaddon_basics1-merged2.dtb.expect @@ -0,0 +1,27 @@ +/dts-v1/; + +/ { + base-node { + sub-node { + prop = <0x00000000>; + phandle = <0x00000002>; + }; + }; + somewhere { + node-a1 { + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000001 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + compatible = "abc,aaa"; + phandle = <0x00000001>; + }; + node-a2 { + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000003 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + compatible = "abc,aaa"; + phandle = <0x00000003>; + addon-node { + prop = <0x00000000>; + }; + }; + }; +}; diff --git a/tests/fdtaddon_basics1.dtba.expect b/tests/fdtaddon_basics1.dtba.expect new file mode 100644 index 00000000..1102923a --- /dev/null +++ b/tests/fdtaddon_basics1.dtba.expect @@ -0,0 +1,8 @@ +/dts-v1/; +/addon/; + +/ { + addon-node { + prop = <0x00000000>; + }; +}; diff --git a/tests/fdtaddon_basics1.dtsa b/tests/fdtaddon_basics1.dtsa new file mode 100644 index 00000000..84621c97 --- /dev/null +++ b/tests/fdtaddon_basics1.dtsa @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) +/* + * Copyright (C) 2026 Bootlin + */ + +/dts-v1/; +/addon/; + +/ { + addon-node { + prop = <0>; + }; +}; diff --git a/tests/meson.build b/tests/meson.build index ec24f0af..e1a2454e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -144,6 +144,7 @@ run_test_types = [ 'fdtdump', 'fdtoverlay', 'metadata', + 'fdtaddon', ] run_test_deps = [ dtc_tools, treegen_dtb, tests_exe, diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 7f47b685..3f80b183 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -1281,6 +1281,48 @@ metadata_tests() { run_test check_full metadata_sort.dtb } +run_fdtaddon_test () { + printf "fdtaddon $*: " + base_run_test wrap_test $VALGRIND $FDTADDON "$@" +} + +check_dtb () { + local dtb="$1" + base_run_test wrap_fdtdump "$dtb" "$dtb.out" + sed -i '/^\/\/ [^\[]/d' "$dtb.out" + base_run_test check_diff "$dtb.out" "$SRCDIR/$dtb.expect" + run_test check_full "$dtb" +} + +check_dts () { + local dts="$1" + base_run_test check_diff "$dts" "$SRCDIR/$dts.expect" +} + +fdtaddon_tests() { + run_dtc_test -I dts -O dtb -o fdtaddon_base.dtb "$SRCDIR/fdtaddon_base.dts" + check_dtb fdtaddon_base.dtb + + for dt in fdtaddon_basics1; do + run_dtc_test -I dts -O dtb -o $dt.dtba "$SRCDIR/$dt.dtsa" + check_dtb $dt.dtba + + run_fdtaddon_test -i fdtaddon_base.dtb -o $dt-merged1.dtb \ + -t "/somewhere/node-a1" $dt.dtba + check_dtb $dt-merged1.dtb + + run_dtc_test -I dtb -O dts -o $dt-merged1.dtb.dts $dt-merged1.dtb + check_dts $dt-merged1.dtb.dts + + run_fdtaddon_test -i fdtaddon_base.dtb -o $dt-merged2.dtb \ + -t "/somewhere/node-a2" $dt.dtba + check_dtb $dt-merged2.dtb + + run_dtc_test -I dtb -O dts -o $dt-merged2.dtb.dts $dt-merged2.dtb + check_dts $dt-merged2.dtb.dts + done +} + pylibfdt_tests () { run_dtc_test -I dts -O dtb -o test_props.dtb "$SRCDIR/test_props.dts" TMP=/tmp/tests.stderr.$$ @@ -1320,7 +1362,7 @@ while getopts "vt:me" ARG ; do done if [ -z "$TESTSETS" ]; then - TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump fdtoverlay metadata" + TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump fdtoverlay metadata fdtaddon" # Test pylibfdt if the libfdt Python module is available. if ! $no_python; then @@ -1363,6 +1405,9 @@ for set in $TESTSETS; do "metadata") metadata_tests ;; + "fdtaddon") + fdtaddon_tests + ;; esac done diff --git a/tests/testutils.sh b/tests/testutils.sh index 6b2f0d14..b5e121e7 100644 --- a/tests/testutils.sh +++ b/tests/testutils.sh @@ -27,6 +27,7 @@ DTGET=${TEST_BINDIR}/fdtget DTPUT=${TEST_BINDIR}/fdtput FDTDUMP=${TEST_BINDIR}/fdtdump FDTOVERLAY=${TEST_BINDIR}/fdtoverlay +FDTADDON=${TEST_BINDIR}/fdtaddon verbose_run () { if [ -z "$QUIET_TEST" ]; then -- 2.55.0