Add a test demonstrating how one can embed various scripts in the
control DTB and verifying that the source command can be used with
${fdtcontroladdr}.Signed-off-by: Rasmus Villemoes <[email protected]> --- arch/sandbox/dts/sandbox-test1.sh | 4 ++++ arch/sandbox/dts/sandbox-test2.sh | 4 ++++ arch/sandbox/dts/sandbox_scripts.dtsi | 18 ++++++++++++++++++ configs/sandbox_defconfig | 1 + test/py/tests/test_source.py | 12 ++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 arch/sandbox/dts/sandbox-test1.sh create mode 100644 arch/sandbox/dts/sandbox-test2.sh create mode 100644 arch/sandbox/dts/sandbox_scripts.dtsi diff --git a/arch/sandbox/dts/sandbox-test1.sh b/arch/sandbox/dts/sandbox-test1.sh new file mode 100644 index 00000000000..9d65a71bd7b --- /dev/null +++ b/arch/sandbox/dts/sandbox-test1.sh @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +echo "aaa" +source ${fdtcontroladdr}:test2 +echo "ccc" diff --git a/arch/sandbox/dts/sandbox-test2.sh b/arch/sandbox/dts/sandbox-test2.sh new file mode 100644 index 00000000000..c84a0a3b97d --- /dev/null +++ b/arch/sandbox/dts/sandbox-test2.sh @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +# Some comment. +echo "bbb" diff --git a/arch/sandbox/dts/sandbox_scripts.dtsi b/arch/sandbox/dts/sandbox_scripts.dtsi new file mode 100644 index 00000000000..f54c95b72b3 --- /dev/null +++ b/arch/sandbox/dts/sandbox_scripts.dtsi @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/ { + images { + default = "test"; + test1 { + description = "Testscript"; + data = /incbin/("sandbox-test1.sh"); + type = "script"; + compression = "none"; + }; + test2 { + description = "Another testscript"; + data = /incbin/("sandbox-test2.sh"); + type = "script"; + compression = "none"; + }; + }; +}; diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 55dc7845544..083383eea2b 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -154,6 +154,7 @@ CONFIG_CMD_SPAWN=y CONFIG_MAC_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_OF_LIVE=y +CONFIG_DEVICE_TREE_INCLUDES="sandbox_scripts.dtsi" CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_FAT=y CONFIG_ENV_IS_IN_EXT4=y diff --git a/test/py/tests/test_source.py b/test/py/tests/test_source.py index 970d8c79869..315aaee3fd6 100644 --- a/test/py/tests/test_source.py +++ b/test/py/tests/test_source.py @@ -34,3 +34,15 @@ def test_source(ubman): ubman.run_command('fdt rm /images default') assert 'Fail' in ubman.run_command('source || echo Fail') assert 'Fail' in ubman.run_command('source \\# || echo Fail') + + output = ubman.run_command('source ${fdtcontroladdr}:test1') + assert 'aaa' in output + assert 'bbb' in output + assert 'ccc' in output + + output = ubman.run_command('source ${fdtcontroladdr}:test2') + assert 'aaa' not in output + assert 'bbb' in output + assert 'ccc' not in output + + assert 'Fail' in ubman.run_command('source ${fdtcontroladdr}:no-such-script || echo Fail') -- 2.54.0

