[PATCH 2/7] test: self: add digest test

Sascha Hauer sha at pengutronix.de
Thu May 25 01:37:18 PDT 2023


On Mon, May 22, 2023 at 07:30:39AM +0200, Ahmad Fatoum wrote:
> Later commits will touch existing digest code, so this is a good
> opportunity to add a self test to ensure MD5/SHA continues to work.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  test/self/Kconfig  |   6 ++
>  test/self/Makefile |   1 +
>  test/self/digest.c | 190 +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 197 insertions(+)
>  create mode 100644 test/self/digest.c
> 
> +static void test_digests_sha12(const char *suffix)
> +{
> +	bool cond;
> +
> +	cond = !strcmp(suffix, "asm") ? IS_ENABLED(CONFIG_DIGEST_SHA1_ARM) :
> +	       IS_ENABLED(CONFIG_HAVE_DIGEST_SHA1);
> +
> +	test_digest(cond, digest_suffix("sha1", suffix),
> +		TEST_CASE(zeroes7, "77ce0377defbd11b77b1f4ad54ca40ea5ef28490"),
> +		TEST_CASE(one32,   "cbd9cbfc20182e4b71e593e7ad598fc383cc6058"),
> +		TEST_CASE(inc4097, "c627e736efd8bb0dff1778335c9c79cb1f27e396"));
> +
> +
> +	cond = !strcmp(suffix, "asm") ? IS_ENABLED(CONFIG_DIGEST_SHA256_ARM) :
> +	       IS_ENABLED(CONFIG_HAVE_DIGEST_SHA1);
> +
> +	test_digest(cond, digest_suffix("sha224", suffix),
> +		TEST_CASE(zeroes7, "fbf6df85218ac5632461a8a17c6f294e6f35264cbfc0a9774a4f665b"),
> +		TEST_CASE(one32,   "343cb3950305e6e6331e294b0a4925739d09ecbd2b43a2fc87c09941"),
> +		TEST_CASE(inc4097, "6596b5dcfbd857f4246d6b94508b8a1a5b715a4f644a0c1e7d54c4f7"));

This breaks on mips qemu-malta_defconfig:

https://github.com/barebox/barebox/actions/runs/5077359707/jobs/9120526730

This config has SHA256 enabled, but not SHA224. It seems we have to run
this test conditionally somehow.

Sascha

-- 
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