@@ -13,12 +13,45 @@ void random_test_get_size(void)
int32_t ret;
uint8_t buf[32];
- ret = odp_random_data(buf, sizeof(buf), false);
+ ret = odp_random_data(buf, sizeof(buf), ODP_RAND_NORMAL);
CU_ASSERT(ret == sizeof(buf));
}
+void random_test_kind(void)
+{
+ odp_crypto_capability_t capa;
+ int32_t rc;
+ uint8_t buf[4096];
+ uint32_t buf_size = sizeof(buf);
+
+ rc = odp_crypto_capability(&capa);
+ CU_ASSERT_FATAL(rc == 0);
+
+ if (capa.max_kind_size != 0 && capa.max_kind_size < buf_size)
+ buf_size = capa.max_kind_size;
+
+ rc = odp_random_data(buf, buf_size, capa.max_kind);
+ CU_ASSERT((uint32_t)rc == buf_size);
+
+ switch (capa.max_kind) {
+ case ODP_RAND_NORMAL:
+ rc = odp_random_data(buf, 4, ODP_RAND_CRYPTO);
+ CU_ASSERT(rc < 0);
+ /* Fall through */
+
+ case ODP_RAND_CRYPTO:
+ rc = odp_random_data(buf, 4, ODP_RAND_TRUE);
+ CU_ASSERT(rc < 0);
+ break;
+
+ default:
+ break;
+ }
+}
+
odp_testinfo_t random_suite[] = {
ODP_TEST_INFO(random_test_get_size),
+ ODP_TEST_INFO(random_test_kind),
ODP_TEST_INFO_NULL,
};
@@ -11,6 +11,7 @@
/* test functions: */
void random_test_get_size(void);
+void random_test_kind(void);
/* test arrays: */
extern odp_testinfo_t random_suite[];
Add additional test to verify that random kindness capabilities are present and behave as advertised. Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> --- test/common_plat/validation/api/random/random.c | 35 ++++++++++++++++++++++++- test/common_plat/validation/api/random/random.h | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) -- 2.7.4