[PATCH 08/11] ci: pytest: Generate test data for dm-verity
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Sep 22 08:41:25 PDT 2025
On 18.09.25 09:43, Tobias Waldekranz wrote:
> Create a small FAT fs with a couple of files, and the corresponding
> hash tree. Then create a modified copy that we can use to make sure
> that errors are detected.
>
> Signed-off-by: Tobias Waldekranz <tobias at waldekranz.com>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
> scripts/generate_testfs.sh | 44 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/scripts/generate_testfs.sh b/scripts/generate_testfs.sh
> index 3c200bd401..1c358ff846 100755
> --- a/scripts/generate_testfs.sh
> +++ b/scripts/generate_testfs.sh
> @@ -28,3 +28,47 @@ generate_fit()
> ${KBUILD_OUTPUT}/testfs/barebox-gzipped.fit
> }
> [ -f .github/testfs/${KBUILD_DEFCONFIG}-gzipped.its ] && generate_fit
> +
> +alias pad128k="dd if=/dev/zero bs=128k count=1 status=none"
> +
> +generate_dm_verity()
> +{
> + work=$(mktemp -d)
> + cd ${work}
> +
> + # Create two dummy files; use lots of padding to make sure that
> + # when we alter the contents of 'english' in root-bad, 'latin' is
> + # still be readable, as their contents wont (a) share the same
> + # hash block and (b) the block cache layer won't accedentally read
> + # the invalid block.
> +
> + pad128k >latin
> + echo -n "veritas vos liberabit" >>latin
> + pad128k >>latin
> +
> + pad128k >english
> + echo -n "truth will set you free" >>english
> + pad128k >>english
> +
> + truncate -s 1M good.fat
> + mkfs.vfat good.fat
> + mcopy -i good.fat latin english ::
> +
> + veritysetup format \
> + --root-hash-file=good.hash \
> + good.fat good.verity
> +
> + sed 's/truth will set you free/LIAR LIAR PANTS ON FIRE/' \
> + <good.fat >bad.fat
> +
> + cd -
> + cp \
> + ${work}/good.fat \
> + ${work}/good.verity \
> + ${work}/good.hash \
> + ${work}/bad.fat \
> + ${KBUILD_OUTPUT}/testfs
> +
> + rm -rf ${work}
> +}
> +generate_dm_verity
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list