tests: crypto: Add a unnormal testing condition

For z_early_boot_rand_get(), give a length less than uint32 to be input
value, ensure the API can work normally with error condition to improve
code coverage.

Signed-off-by: Jian Kang <jianx.kang@intel.com>
This commit is contained in:
Jian Kang 2021-03-01 13:54:08 +08:00 committed by Anas Nashif
commit e169015c6e

View file

@ -30,15 +30,17 @@
void test_rand32(void)
{
uint32_t gen, last_gen;
uint32_t gen, last_gen, tmp;
int rnd_cnt;
int equal_count = 0;
uint32_t buf[N_VALUES];
/* Test early boot random number generation function */
/* Cover the case, where argument "length" is < size of "size_t" */
z_early_boot_rand_get((uint8_t *)&tmp, (size_t)1);
z_early_boot_rand_get((uint8_t *)&last_gen, sizeof(last_gen));
z_early_boot_rand_get((uint8_t *)&gen, sizeof(gen));
zassert_true(last_gen != gen,
zassert_true(last_gen != gen && last_gen != tmp && tmp != gen,
"z_early_boot_rand_get failed");
/*