From nobody Sun Feb 8 16:50:29 2026 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 ADC2236C587; Mon, 12 Jan 2026 14:22:13 +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=1768227735; cv=none; b=EzHtfB6J0Cylodn185W650h/8OB3Q9dtN5DfZCRYH/xD1A7MUawjlUAgTxlTaZ4h0NzENhOhkO1JnIIqodGKjpZ1wsuUpu2H9H82hlXtCg88OPOzQF2nPXyfp9bT9+XAcfPTSS+1uWmhlaBlxafL+dffA148Wer/jBzjCVzKR+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768227735; c=relaxed/simple; bh=CaV6+LlKGRYvRL9UsbxBUGMeZd6ptcNGilWz6iyk29w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O/olmULVy85nQsnavjNMGEC+H2jEe5aMOzINCcmqemcwn9q0jr2LuIaYo5/OmVBgoQ3Oj9AmRngmY6QX+lx0UjavZqKuwpcMoLBIX8JNcysssqy47pKVjduuvpAsddabGB78SwzsPb7SCvyMCvSLxCDWmgVSC06WOsxeR9vwv5U= 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=Rs0m+J5r; 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="Rs0m+J5r" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 8E87C1A2810; Mon, 12 Jan 2026 14:22:12 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 63D1E606FA; Mon, 12 Jan 2026 14:22:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7B6B6103C9262; Mon, 12 Jan 2026 15:22:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1768227731; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Fec2nLC5UB9GciN3RWgleKKuS++nqoMq0WJOh/SpVL4=; b=Rs0m+J5rld3HdosKGDqL1UPFWlTCNJQNjU5HQImLt0SRwcr7GhR3KDEYoKUWNbfxdjXY/S TJm1my84s8ou3pRyw3dFdtYd1dZ0UcADhm+ltEBBHFXruSgBVx+v/TMz45uO3lbZJ31WFE cn3YrJVjlCvionZFCF2B/1GtndKvq62JCsnwa8fuoNnihdZ3poLHN9K6jrlg9JjU2EF3RN +9K2cWzTKdrZ/hUtYJGIDm54BtHsyXhxYvtkXzSa0d2CtIJN178W15wbUh4O52MM5iAN4V 9atYSAmR0iYFe/M5WINnd+mHy9frkchboRMzvCegvMkHPnWWVdzZUFPyLGk4AA== From: Herve Codina To: David Gibson , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: 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 72/77] tests: Add a first basic test for fdtaddon Date: Mon, 12 Jan 2026 15:20:02 +0100 Message-ID: <20260112142009.1006236-73-herve.codina@bootlin.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260112142009.1006236-1-herve.codina@bootlin.com> References: <20260112142009.1006236-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" 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 | 3 +- tests/run_tests.sh | 46 ++++++++++++++++++- tests/testutils.sh | 1 + 11 files changed, 244 insertions(+), 2 deletions(-) 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 0000000..eb8cd40 --- /dev/null +++ b/tests/fdtaddon_base.dtb.expect @@ -0,0 +1,24 @@ +/dts-v1/; + +/ { + base-node { + sub-node { + prop =3D <0x00000000>; + phandle =3D <0x00000002>; + }; + }; + somewhere { + node-a1 { + compatible =3D "abc,aaa"; + phandle =3D <0x00000001>; + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000001 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + }; + node-a2 { + compatible =3D "abc,aaa"; + phandle =3D <0x00000003>; + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000003 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + }; + }; +}; diff --git a/tests/fdtaddon_base.dts b/tests/fdtaddon_base.dts new file mode 100644 index 0000000..3b00146 --- /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 =3D <0>; + }; + }; + + somewhere { + node_a1: node-a1 { + compatible =3D "abc,aaa"; + /export/ node_a: &node_a1; + /export/ other: &other_a; + }; + node_a2: node-a2 { + compatible =3D "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 0000000..927733c --- /dev/null +++ b/tests/fdtaddon_basics1-merged1.dtb.dts.expect @@ -0,0 +1,35 @@ +/dts-v1/; + +/ { + + base-node { + + sub-node { + prop =3D <0x00>; + phandle =3D <0x02>; + }; + }; + + somewhere { + + node-a1 { + compatible =3D "abc,aaa"; + phandle =3D <0x01>; + + /export/ node_a: &{/somewhere/node-a1}; + /export/ other: &{/base-node/sub-node}; + + addon-node { + prop =3D <0x00>; + }; + }; + + node-a2 { + compatible =3D "abc,aaa"; + phandle =3D <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_bas= ics1-merged1.dtb.expect new file mode 100644 index 0000000..bee1397 --- /dev/null +++ b/tests/fdtaddon_basics1-merged1.dtb.expect @@ -0,0 +1,27 @@ +/dts-v1/; + +/ { + base-node { + sub-node { + prop =3D <0x00000000>; + phandle =3D <0x00000002>; + }; + }; + somewhere { + node-a1 { + compatible =3D "abc,aaa"; + phandle =3D <0x00000001>; + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000001 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + addon-node { + prop =3D <0x00000000>; + }; + }; + node-a2 { + compatible =3D "abc,aaa"; + phandle =3D <0x00000003>; + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000003 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + }; + }; +}; diff --git a/tests/fdtaddon_basics1-merged2.dtb.dts.expect b/tests/fdtaddon= _basics1-merged2.dtb.dts.expect new file mode 100644 index 0000000..d85567b --- /dev/null +++ b/tests/fdtaddon_basics1-merged2.dtb.dts.expect @@ -0,0 +1,35 @@ +/dts-v1/; + +/ { + + base-node { + + sub-node { + prop =3D <0x00>; + phandle =3D <0x02>; + }; + }; + + somewhere { + + node-a1 { + compatible =3D "abc,aaa"; + phandle =3D <0x01>; + + /export/ node_a: &{/somewhere/node-a1}; + /export/ other: &{/base-node/sub-node}; + }; + + node-a2 { + compatible =3D "abc,aaa"; + phandle =3D <0x03>; + + /export/ node_a: &{/somewhere/node-a2}; + /export/ other: &{/base-node/sub-node}; + + addon-node { + prop =3D <0x00>; + }; + }; + }; +}; diff --git a/tests/fdtaddon_basics1-merged2.dtb.expect b/tests/fdtaddon_bas= ics1-merged2.dtb.expect new file mode 100644 index 0000000..34a4b36 --- /dev/null +++ b/tests/fdtaddon_basics1-merged2.dtb.expect @@ -0,0 +1,27 @@ +/dts-v1/; + +/ { + base-node { + sub-node { + prop =3D <0x00000000>; + phandle =3D <0x00000002>; + }; + }; + somewhere { + node-a1 { + compatible =3D "abc,aaa"; + phandle =3D <0x00000001>; + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000001 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + }; + node-a2 { + compatible =3D "abc,aaa"; + phandle =3D <0x00000003>; + // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000003 + // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002 + addon-node { + prop =3D <0x00000000>; + }; + }; + }; +}; diff --git a/tests/fdtaddon_basics1.dtba.expect b/tests/fdtaddon_basics1.dt= ba.expect new file mode 100644 index 0000000..1102923 --- /dev/null +++ b/tests/fdtaddon_basics1.dtba.expect @@ -0,0 +1,8 @@ +/dts-v1/; +/addon/; + +/ { + addon-node { + prop =3D <0x00000000>; + }; +}; diff --git a/tests/fdtaddon_basics1.dtsa b/tests/fdtaddon_basics1.dtsa new file mode 100644 index 0000000..84621c9 --- /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 =3D <0>; + }; +}; diff --git a/tests/meson.build b/tests/meson.build index e81a2e1..f0ae98a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -141,7 +141,8 @@ run_test_types =3D [ 'fdtput', 'fdtdump', 'fdtoverlay', - 'metadata' + 'metadata', + 'fdtaddon' ] run_test_deps =3D [ dtc_tools, dumptrees_dtb, tests_exe diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 4392752..32c40cf 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -1168,6 +1168,47 @@ metadata_tests() { base_run_test check_diff metadata_sort.dtb.dts "$SRCDIR/metadata_sort.dtb= .dts.expect" } =20 +run_fdtaddon_test () { + printf "fdtaddon $*: " + base_run_test wrap_test $VALGRIND $FDTADDON "$@" +} + +check_dtb () { + local dtb=3D"$1" + base_run_test wrap_fdtdump "$dtb" "$dtb.out" + sed -i '/^\/\/ [^\[]/d' "$dtb.out" + base_run_test check_diff "$dtb.out" "$SRCDIR/$dtb.expect" +} + +check_dts () { + local dts=3D"$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.dt= s" + 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=3D/tmp/tests.stderr.$$ @@ -1207,7 +1248,7 @@ while getopts "vt:me" ARG ; do done =20 if [ -z "$TESTSETS" ]; then - TESTSETS=3D"libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump fdtove= rlay metadata" + TESTSETS=3D"libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump fdtove= rlay metadata fdtaddon" =20 # Test pylibfdt if the libfdt Python module is available. if ! $no_python; then @@ -1250,6 +1291,9 @@ for set in $TESTSETS; do "metadata") metadata_tests ;; + "fdtaddon") + fdtaddon_tests + ;; esac done =20 diff --git a/tests/testutils.sh b/tests/testutils.sh index 6b2f0d1..b5e121e 100644 --- a/tests/testutils.sh +++ b/tests/testutils.sh @@ -27,6 +27,7 @@ DTGET=3D${TEST_BINDIR}/fdtget DTPUT=3D${TEST_BINDIR}/fdtput FDTDUMP=3D${TEST_BINDIR}/fdtdump FDTOVERLAY=3D${TEST_BINDIR}/fdtoverlay +FDTADDON=3D${TEST_BINDIR}/fdtaddon =20 verbose_run () { if [ -z "$QUIET_TEST" ]; then --=20 2.52.0