Test that the compile-time and run-time entropy source counts match

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2026-03-15 19:43:44 +01:00
parent 909055d760
commit 900b7dc5ac
2 changed files with 26 additions and 0 deletions

View File

@@ -4,6 +4,9 @@ entropy_init_free:0
Entropy init-free-init-free
entropy_init_free:1
Entropy: count default sources
entropy_count_sources:
Create NV seed_file
nv_seed_file_create:

View File

@@ -171,6 +171,29 @@ void entropy_init_free(int reinit)
}
/* END_CASE */
/* BEGIN_CASE */
void entropy_count_sources()
{
mbedtls_entropy_context ctx;
mbedtls_entropy_init(&ctx);
#if defined(MBEDTLS_ENTROPY_HAVE_SOURCES)
TEST_EQUAL(MBEDTLS_ENTROPY_HAVE_SOURCES, ctx.source_count);
#else
TEST_EQUAL(0, ctx.source_count);
#endif
#if defined(MBEDTLS_ENTROPY_NV_SEED)
TEST_EQUAL(MBEDTLS_ENTROPY_TRUE_SOURCES + 1, ctx.source_count);
#else
TEST_EQUAL(MBEDTLS_ENTROPY_TRUE_SOURCES, ctx.source_count);
#endif
exit:
mbedtls_entropy_free(&ctx);
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */
void entropy_seed_file(char *path, int ret)
{