diff mbox

validation: crypto: split crypto and random tests

Message ID 1424957142-9121-1-git-send-email-taras.kondratiuk@linaro.org
State Accepted
Commit 4b37b9353426d63242c7860a514901e39c21f5e7
Headers show

Commit Message

Taras Kondratiuk Feb. 26, 2015, 1:25 p.m. UTC
Crypto and Random are separate API modules now, so split tests
accordingly.

Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
 test/validation/Makefile.am                  |  3 ++-
 test/validation/crypto/odp_crypto_test_rng.c | 28 --------------------------
 test/validation/crypto/odp_crypto_test_rng.h | 17 ----------------
 test/validation/odp_crypto.c                 |  2 --
 test/validation/odp_random.c                 | 30 ++++++++++++++++++++++++++++
 5 files changed, 32 insertions(+), 48 deletions(-)
 delete mode 100644 test/validation/crypto/odp_crypto_test_rng.c
 delete mode 100644 test/validation/crypto/odp_crypto_test_rng.h
 create mode 100644 test/validation/odp_random.c

Comments

Mike Holmes Feb. 26, 2015, 3:45 p.m. UTC | #1
We need to throttle change in 1.0 to only ODP API only now.
This should go in 1.0.1

On 26 February 2015 at 08:25, Taras Kondratiuk <taras.kondratiuk@linaro.org>
wrote:

> Crypto and Random are separate API modules now, so split tests
> accordingly.
>
> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> ---
>  test/validation/Makefile.am                  |  3 ++-
>  test/validation/crypto/odp_crypto_test_rng.c | 28
> --------------------------
>  test/validation/crypto/odp_crypto_test_rng.h | 17 ----------------
>  test/validation/odp_crypto.c                 |  2 --
>  test/validation/odp_random.c                 | 30
> ++++++++++++++++++++++++++++
>  5 files changed, 32 insertions(+), 48 deletions(-)
>  delete mode 100644 test/validation/crypto/odp_crypto_test_rng.c
>  delete mode 100644 test/validation/crypto/odp_crypto_test_rng.h
>  create mode 100644 test/validation/odp_random.c
>
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index f5bb9ac..0639205 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -14,6 +14,7 @@ EXECUTABLES = odp_buffer \
>               odp_packet \
>               odp_pool \
>               odp_queue \
> +             odp_random \
>               odp_schedule \
>               odp_shm \
>               odp_system \
> @@ -42,12 +43,12 @@ dist_odp_classification_SOURCES =
> classification/odp_classification_tests.c \
>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>  dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
>                           crypto/odp_crypto_test_sync_inp.c \
> -                         crypto/odp_crypto_test_rng.c \
>                           odp_crypto.c $(ODP_CU_COMMON)
>  dist_odp_init_SOURCES  = odp_init.c
>  dist_odp_init_abort_SOURCES = odp_init_abort.c
>  dist_odp_init_log_SOURCES = odp_init_log.c
>  dist_odp_queue_SOURCES = odp_queue.c $(ODP_CU_COMMON)
> +dist_odp_random_SOURCES = odp_random.c $(ODP_CU_COMMON)
>  dist_odp_schedule_SOURCES = odp_schedule.c $(ODP_CU_COMMON)
>  dist_odp_shm_SOURCES   = odp_shm.c $(ODP_CU_COMMON)
>  dist_odp_system_SOURCES = odp_system.c $(ODP_CU_COMMON)
> diff --git a/test/validation/crypto/odp_crypto_test_rng.c
> b/test/validation/crypto/odp_crypto_test_rng.c
> deleted file mode 100644
> index 6a4ad17..0000000
> --- a/test/validation/crypto/odp_crypto_test_rng.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (c) 2014, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:     BSD-3-Clause
> - */
> -#include <odp.h>
> -#include <CUnit/Basic.h>
> -#include <CUnit/TestDB.h>
> -#include "test_vectors_len.h"
> -
> -/*
> - * This test verifies that HW random number generator is able
> - * to produce an IV for TDES_CBC cipher algorithm.
> - * */
> -#define RNG_GET_SIZE   "RNG_GET_SIZE"
> -static void rng_get_size(void)
> -{
> -       int32_t ret;
> -       uint8_t buf[TDES_CBC_IV_LEN];
> -
> -       ret = odp_random_data(buf, sizeof(buf), false);
> -       CU_ASSERT(ret == TDES_CBC_IV_LEN);
> -}
> -
> -CU_TestInfo test_rng[] = {
> -       { RNG_GET_SIZE, rng_get_size },
> -       CU_TEST_INFO_NULL,
> -};
> diff --git a/test/validation/crypto/odp_crypto_test_rng.h
> b/test/validation/crypto/odp_crypto_test_rng.h
> deleted file mode 100644
> index 16909b3..0000000
> --- a/test/validation/crypto/odp_crypto_test_rng.h
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -/* Copyright (c) 2014, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:     BSD-3-Clause
> - */
> -#ifndef ODP_CRYPTO_TEST_RNG_
> -#define ODP_CRYPTO_TEST_RNG_
> -
> -#include "CUnit/TestDB.h"
> -
> -/* Suite name */
> -#define ODP_CRYPTO_RNG    "ODP_CRYPTO_RNG"
> -
> -/* Suite test array */
> -extern CU_TestInfo test_rng[];
> -
> -#endif
> diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
> index fbe5dbb..6cb5695 100644
> --- a/test/validation/odp_crypto.c
> +++ b/test/validation/odp_crypto.c
> @@ -8,7 +8,6 @@
>  #include "odp_cunit_common.h"
>  #include "odp_crypto_test_async_inp.h"
>  #include "odp_crypto_test_sync_inp.h"
> -#include "odp_crypto_test_rng.h"
>
>  #define SHM_PKT_POOL_SIZE      (512*2048*2)
>  #define SHM_PKT_POOL_BUF_SIZE  (1024 * 32)
> @@ -19,7 +18,6 @@
>  CU_SuiteInfo odp_testsuites[] = {
>         {ODP_CRYPTO_SYNC_INP, NULL, NULL, NULL, NULL, test_array_sync },
>         {ODP_CRYPTO_ASYNC_INP, NULL, NULL, NULL, NULL, test_array_async },
> -       {ODP_CRYPTO_RNG, NULL, NULL, NULL, NULL, test_rng },
>         CU_SUITE_INFO_NULL,
>  };
>
> diff --git a/test/validation/odp_random.c b/test/validation/odp_random.c
> new file mode 100644
> index 0000000..ebc9705
> --- /dev/null
> +++ b/test/validation/odp_random.c
> @@ -0,0 +1,30 @@
> +/* Copyright (c) 2015, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#include <odp.h>
> +#include <odp_cunit_common.h>
> +
> +/* Helper macro for CU_TestInfo initialization */
> +#define _CU_TEST_INFO(test_func) {#test_func, test_func}
> +
> +static void random_get_size(void)
> +{
> +       int32_t ret;
> +       uint8_t buf[32];
> +
> +       ret = odp_random_data(buf, sizeof(buf), false);
> +       CU_ASSERT(ret == sizeof(buf));
> +}
> +
> +CU_TestInfo test_odp_random[] = {
> +       _CU_TEST_INFO(random_get_size),
> +       CU_TEST_INFO_NULL,
> +};
> +
> +CU_SuiteInfo odp_testsuites[] = {
> +       {"Random", NULL, NULL, NULL, NULL, test_odp_random},
> +       CU_SUITE_INFO_NULL,
> +};
> --
> 1.9.1
>
>
Taras Kondratiuk Feb. 26, 2015, 4:11 p.m. UTC | #2
On 02/26/2015 05:45 PM, Mike Holmes wrote:
> We need to throttle change in 1.0 to only ODP API only now.
> This should go in 1.0.1 

That's fine.
But it can be reviewed anyway :)
Mike Holmes Feb. 26, 2015, 9:10 p.m. UTC | #3
need to add odp_random to gitignore

On 26 February 2015 at 13:31, Robbie King (robking) <robking@cisco.com>
wrote:

> The only nit that I have, and not sure we have any way around it
> today, is the size of the test buffer being hard coded to "32".
> Seems eventually that should be a #define for a given implementation's
> capabilities, or perhaps a minimum guaranteed on all ODP platforms.
>
> But I think this is OK for now.
>
> Reviewed-and-tested-by: Robbie King <robking@cisco.com>
>
> -----Original Message-----
> From: Taras Kondratiuk [mailto:taras.kondratiuk@linaro.org]
> Sent: Thursday, February 26, 2015 8:26 AM
> To: lng-odp@lists.linaro.org
> Cc: mike.holmes@linaro.org; Robbie King (robking); Taras Kondratiuk
> Subject: [PATCH] validation: crypto: split crypto and random tests
>
> Crypto and Random are separate API modules now, so split tests
> accordingly.
>
> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> ---
>  test/validation/Makefile.am                  |  3 ++-
>  test/validation/crypto/odp_crypto_test_rng.c | 28
> --------------------------
>  test/validation/crypto/odp_crypto_test_rng.h | 17 ----------------
>  test/validation/odp_crypto.c                 |  2 --
>  test/validation/odp_random.c                 | 30
> ++++++++++++++++++++++++++++
>  5 files changed, 32 insertions(+), 48 deletions(-)
>  delete mode 100644 test/validation/crypto/odp_crypto_test_rng.c
>  delete mode 100644 test/validation/crypto/odp_crypto_test_rng.h
>  create mode 100644 test/validation/odp_random.c
>
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index f5bb9ac..0639205 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -14,6 +14,7 @@ EXECUTABLES = odp_buffer \
>               odp_packet \
>               odp_pool \
>               odp_queue \
> +             odp_random \
>               odp_schedule \
>               odp_shm \
>               odp_system \
> @@ -42,12 +43,12 @@ dist_odp_classification_SOURCES =
> classification/odp_classification_tests.c \
>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>  dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
>                           crypto/odp_crypto_test_sync_inp.c \
> -                         crypto/odp_crypto_test_rng.c \
>                           odp_crypto.c $(ODP_CU_COMMON)
>  dist_odp_init_SOURCES  = odp_init.c
>  dist_odp_init_abort_SOURCES = odp_init_abort.c
>  dist_odp_init_log_SOURCES = odp_init_log.c
>  dist_odp_queue_SOURCES = odp_queue.c $(ODP_CU_COMMON)
> +dist_odp_random_SOURCES = odp_random.c $(ODP_CU_COMMON)
>  dist_odp_schedule_SOURCES = odp_schedule.c $(ODP_CU_COMMON)
>  dist_odp_shm_SOURCES   = odp_shm.c $(ODP_CU_COMMON)
>  dist_odp_system_SOURCES = odp_system.c $(ODP_CU_COMMON)
> diff --git a/test/validation/crypto/odp_crypto_test_rng.c
> b/test/validation/crypto/odp_crypto_test_rng.c
> deleted file mode 100644
> index 6a4ad17..0000000
> --- a/test/validation/crypto/odp_crypto_test_rng.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (c) 2014, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:     BSD-3-Clause
> - */
> -#include <odp.h>
> -#include <CUnit/Basic.h>
> -#include <CUnit/TestDB.h>
> -#include "test_vectors_len.h"
> -
> -/*
> - * This test verifies that HW random number generator is able
> - * to produce an IV for TDES_CBC cipher algorithm.
> - * */
> -#define RNG_GET_SIZE   "RNG_GET_SIZE"
> -static void rng_get_size(void)
> -{
> -       int32_t ret;
> -       uint8_t buf[TDES_CBC_IV_LEN];
> -
> -       ret = odp_random_data(buf, sizeof(buf), false);
> -       CU_ASSERT(ret == TDES_CBC_IV_LEN);
> -}
> -
> -CU_TestInfo test_rng[] = {
> -       { RNG_GET_SIZE, rng_get_size },
> -       CU_TEST_INFO_NULL,
> -};
> diff --git a/test/validation/crypto/odp_crypto_test_rng.h
> b/test/validation/crypto/odp_crypto_test_rng.h
> deleted file mode 100644
> index 16909b3..0000000
> --- a/test/validation/crypto/odp_crypto_test_rng.h
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -/* Copyright (c) 2014, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:     BSD-3-Clause
> - */
> -#ifndef ODP_CRYPTO_TEST_RNG_
> -#define ODP_CRYPTO_TEST_RNG_
> -
> -#include "CUnit/TestDB.h"
> -
> -/* Suite name */
> -#define ODP_CRYPTO_RNG    "ODP_CRYPTO_RNG"
> -
> -/* Suite test array */
> -extern CU_TestInfo test_rng[];
> -
> -#endif
> diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
> index fbe5dbb..6cb5695 100644
> --- a/test/validation/odp_crypto.c
> +++ b/test/validation/odp_crypto.c
> @@ -8,7 +8,6 @@
>  #include "odp_cunit_common.h"
>  #include "odp_crypto_test_async_inp.h"
>  #include "odp_crypto_test_sync_inp.h"
> -#include "odp_crypto_test_rng.h"
>
>  #define SHM_PKT_POOL_SIZE      (512*2048*2)
>  #define SHM_PKT_POOL_BUF_SIZE  (1024 * 32)
> @@ -19,7 +18,6 @@
>  CU_SuiteInfo odp_testsuites[] = {
>         {ODP_CRYPTO_SYNC_INP, NULL, NULL, NULL, NULL, test_array_sync },
>         {ODP_CRYPTO_ASYNC_INP, NULL, NULL, NULL, NULL, test_array_async },
> -       {ODP_CRYPTO_RNG, NULL, NULL, NULL, NULL, test_rng },
>         CU_SUITE_INFO_NULL,
>  };
>
> diff --git a/test/validation/odp_random.c b/test/validation/odp_random.c
> new file mode 100644
> index 0000000..ebc9705
> --- /dev/null
> +++ b/test/validation/odp_random.c
> @@ -0,0 +1,30 @@
> +/* Copyright (c) 2015, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#include <odp.h>
> +#include <odp_cunit_common.h>
> +
> +/* Helper macro for CU_TestInfo initialization */
> +#define _CU_TEST_INFO(test_func) {#test_func, test_func}
> +
> +static void random_get_size(void)
> +{
> +       int32_t ret;
> +       uint8_t buf[32];
> +
> +       ret = odp_random_data(buf, sizeof(buf), false);
> +       CU_ASSERT(ret == sizeof(buf));
> +}
> +
> +CU_TestInfo test_odp_random[] = {
> +       _CU_TEST_INFO(random_get_size),
> +       CU_TEST_INFO_NULL,
> +};
> +
> +CU_SuiteInfo odp_testsuites[] = {
> +       {"Random", NULL, NULL, NULL, NULL, test_odp_random},
> +       CU_SUITE_INFO_NULL,
> +};
> --
> 1.9.1
>
>
Taras Kondratiuk Feb. 27, 2015, 12:32 p.m. UTC | #4
On 02/26/2015 08:31 PM, Robbie King (robking) wrote:
> The only nit that I have, and not sure we have any way around it 
> today, is the size of the test buffer being hard coded to "32".
> Seems eventually that should be a #define for a given implementation's
> capabilities, or perhaps a minimum guaranteed on all ODP platforms.

I can't find it in ML, but I've raised this issue some time ago.
If platform's RNG don't have enough random bytes to fill
odp_random_data() request, then we have at least two options:
1. odp_random_data() returns whatever number of bytes are available.
   It can be even 0 bytes until new random bytes are generated.
   Application have to repeat odp_random_data() in a loop to fill a
   whole buffer.
2. odp_random_data() can block for some time, while implementation
   polls RNG to fill a whole requested buffer.

At that time we agreed that #2 is better.
Ola Liljedahl Feb. 27, 2015, 1:25 p.m. UTC | #5
On 27 February 2015 at 14:22, Savolainen, Petri (Nokia - FI/Espoo)
<petri.savolainen@nokia.com> wrote:
>
>
>> -----Original Message-----
>> From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp-
>> bounces@lists.linaro.org] On Behalf Of ext Taras Kondratiuk
>> Sent: Friday, February 27, 2015 2:32 PM
>> To: Robbie King (robking); lng-odp@lists.linaro.org
>> Subject: Re: [lng-odp] [PATCH] validation: crypto: split crypto and random
>> tests
>>
>> On 02/26/2015 08:31 PM, Robbie King (robking) wrote:
>> > The only nit that I have, and not sure we have any way around it
>> > today, is the size of the test buffer being hard coded to "32".
>> > Seems eventually that should be a #define for a given implementation's
>> > capabilities, or perhaps a minimum guaranteed on all ODP platforms.
>>
>> I can't find it in ML, but I've raised this issue some time ago.
>> If platform's RNG don't have enough random bytes to fill
>> odp_random_data() request, then we have at least two options:
>> 1. odp_random_data() returns whatever number of bytes are available.
>>    It can be even 0 bytes until new random bytes are generated.
>>    Application have to repeat odp_random_data() in a loop to fill a
>>    whole buffer.
>> 2. odp_random_data() can block for some time, while implementation
>>    polls RNG to fill a whole requested buffer.
>>
>> At that time we agreed that #2 is better.
>
> Current API definition is #1 (changed during Ola's return value harmonization). I think it makes sense if/when (new) random data generation may take some time. Function can return all data that is available immediately and return. Application can decide what to do if there was not enough random data available: poll in tight/loose loop, record the state and try again later, fail and report an error, ...
Yes I think this approach is better. No hidden blocking.

-- Ola

>
> -Petri
>
>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Taras Kondratiuk March 2, 2015, 3:55 p.m. UTC | #6
On 02/26/2015 05:45 PM, Mike Holmes wrote:
> We need to throttle change in 1.0 to only ODP API only now.
> This should go in 1.0.1

Can this be merged now?
Mike Holmes March 2, 2015, 4:02 p.m. UTC | #7
Open season on 1.0.1 :)

On 2 March 2015 at 10:55, Taras Kondratiuk <taras.kondratiuk@linaro.org>
wrote:

> On 02/26/2015 05:45 PM, Mike Holmes wrote:
>
>> We need to throttle change in 1.0 to only ODP API only now.
>> This should go in 1.0.1
>>
>
> Can this be merged now?
>
Maxim Uvarov March 3, 2015, 12:25 p.m. UTC | #8
Merged,
Maxim.

On 02/26/15 16:25, Taras Kondratiuk wrote:
> Crypto and Random are separate API modules now, so split tests
> accordingly.
>
> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> ---
>   test/validation/Makefile.am                  |  3 ++-
>   test/validation/crypto/odp_crypto_test_rng.c | 28 --------------------------
>   test/validation/crypto/odp_crypto_test_rng.h | 17 ----------------
>   test/validation/odp_crypto.c                 |  2 --
>   test/validation/odp_random.c                 | 30 ++++++++++++++++++++++++++++
>   5 files changed, 32 insertions(+), 48 deletions(-)
>   delete mode 100644 test/validation/crypto/odp_crypto_test_rng.c
>   delete mode 100644 test/validation/crypto/odp_crypto_test_rng.h
>   create mode 100644 test/validation/odp_random.c
>
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index f5bb9ac..0639205 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -14,6 +14,7 @@ EXECUTABLES = odp_buffer \
>   	      odp_packet \
>   	      odp_pool \
>   	      odp_queue \
> +	      odp_random \
>   	      odp_schedule \
>   	      odp_shm \
>   	      odp_system \
> @@ -42,12 +43,12 @@ dist_odp_classification_SOURCES = classification/odp_classification_tests.c \
>   odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>   dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
>   			  crypto/odp_crypto_test_sync_inp.c \
> -			  crypto/odp_crypto_test_rng.c \
>   			  odp_crypto.c $(ODP_CU_COMMON)
>   dist_odp_init_SOURCES	= odp_init.c
>   dist_odp_init_abort_SOURCES = odp_init_abort.c
>   dist_odp_init_log_SOURCES = odp_init_log.c
>   dist_odp_queue_SOURCES	= odp_queue.c $(ODP_CU_COMMON)
> +dist_odp_random_SOURCES = odp_random.c $(ODP_CU_COMMON)
>   dist_odp_schedule_SOURCES = odp_schedule.c $(ODP_CU_COMMON)
>   dist_odp_shm_SOURCES	= odp_shm.c $(ODP_CU_COMMON)
>   dist_odp_system_SOURCES = odp_system.c $(ODP_CU_COMMON)
> diff --git a/test/validation/crypto/odp_crypto_test_rng.c b/test/validation/crypto/odp_crypto_test_rng.c
> deleted file mode 100644
> index 6a4ad17..0000000
> --- a/test/validation/crypto/odp_crypto_test_rng.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (c) 2014, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:     BSD-3-Clause
> - */
> -#include <odp.h>
> -#include <CUnit/Basic.h>
> -#include <CUnit/TestDB.h>
> -#include "test_vectors_len.h"
> -
> -/*
> - * This test verifies that HW random number generator is able
> - * to produce an IV for TDES_CBC cipher algorithm.
> - * */
> -#define RNG_GET_SIZE	"RNG_GET_SIZE"
> -static void rng_get_size(void)
> -{
> -	int32_t ret;
> -	uint8_t buf[TDES_CBC_IV_LEN];
> -
> -	ret = odp_random_data(buf, sizeof(buf), false);
> -	CU_ASSERT(ret == TDES_CBC_IV_LEN);
> -}
> -
> -CU_TestInfo test_rng[] = {
> -	{ RNG_GET_SIZE, rng_get_size },
> -	CU_TEST_INFO_NULL,
> -};
> diff --git a/test/validation/crypto/odp_crypto_test_rng.h b/test/validation/crypto/odp_crypto_test_rng.h
> deleted file mode 100644
> index 16909b3..0000000
> --- a/test/validation/crypto/odp_crypto_test_rng.h
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -/* Copyright (c) 2014, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:     BSD-3-Clause
> - */
> -#ifndef ODP_CRYPTO_TEST_RNG_
> -#define ODP_CRYPTO_TEST_RNG_
> -
> -#include "CUnit/TestDB.h"
> -
> -/* Suite name */
> -#define ODP_CRYPTO_RNG    "ODP_CRYPTO_RNG"
> -
> -/* Suite test array */
> -extern CU_TestInfo test_rng[];
> -
> -#endif
> diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
> index fbe5dbb..6cb5695 100644
> --- a/test/validation/odp_crypto.c
> +++ b/test/validation/odp_crypto.c
> @@ -8,7 +8,6 @@
>   #include "odp_cunit_common.h"
>   #include "odp_crypto_test_async_inp.h"
>   #include "odp_crypto_test_sync_inp.h"
> -#include "odp_crypto_test_rng.h"
>   
>   #define SHM_PKT_POOL_SIZE	(512*2048*2)
>   #define SHM_PKT_POOL_BUF_SIZE	(1024 * 32)
> @@ -19,7 +18,6 @@
>   CU_SuiteInfo odp_testsuites[] = {
>   	{ODP_CRYPTO_SYNC_INP, NULL, NULL, NULL, NULL, test_array_sync },
>   	{ODP_CRYPTO_ASYNC_INP, NULL, NULL, NULL, NULL, test_array_async },
> -	{ODP_CRYPTO_RNG, NULL, NULL, NULL, NULL, test_rng },
>   	CU_SUITE_INFO_NULL,
>   };
>   
> diff --git a/test/validation/odp_random.c b/test/validation/odp_random.c
> new file mode 100644
> index 0000000..ebc9705
> --- /dev/null
> +++ b/test/validation/odp_random.c
> @@ -0,0 +1,30 @@
> +/* Copyright (c) 2015, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#include <odp.h>
> +#include <odp_cunit_common.h>
> +
> +/* Helper macro for CU_TestInfo initialization */
> +#define _CU_TEST_INFO(test_func) {#test_func, test_func}
> +
> +static void random_get_size(void)
> +{
> +	int32_t ret;
> +	uint8_t buf[32];
> +
> +	ret = odp_random_data(buf, sizeof(buf), false);
> +	CU_ASSERT(ret == sizeof(buf));
> +}
> +
> +CU_TestInfo test_odp_random[] = {
> +	_CU_TEST_INFO(random_get_size),
> +	CU_TEST_INFO_NULL,
> +};
> +
> +CU_SuiteInfo odp_testsuites[] = {
> +	{"Random", NULL, NULL, NULL, NULL, test_odp_random},
> +	CU_SUITE_INFO_NULL,
> +};
diff mbox

Patch

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index f5bb9ac..0639205 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -14,6 +14,7 @@  EXECUTABLES = odp_buffer \
 	      odp_packet \
 	      odp_pool \
 	      odp_queue \
+	      odp_random \
 	      odp_schedule \
 	      odp_shm \
 	      odp_system \
@@ -42,12 +43,12 @@  dist_odp_classification_SOURCES = classification/odp_classification_tests.c \
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
 			  crypto/odp_crypto_test_sync_inp.c \
-			  crypto/odp_crypto_test_rng.c \
 			  odp_crypto.c $(ODP_CU_COMMON)
 dist_odp_init_SOURCES	= odp_init.c
 dist_odp_init_abort_SOURCES = odp_init_abort.c
 dist_odp_init_log_SOURCES = odp_init_log.c
 dist_odp_queue_SOURCES	= odp_queue.c $(ODP_CU_COMMON)
+dist_odp_random_SOURCES = odp_random.c $(ODP_CU_COMMON)
 dist_odp_schedule_SOURCES = odp_schedule.c $(ODP_CU_COMMON)
 dist_odp_shm_SOURCES	= odp_shm.c $(ODP_CU_COMMON)
 dist_odp_system_SOURCES = odp_system.c $(ODP_CU_COMMON)
diff --git a/test/validation/crypto/odp_crypto_test_rng.c b/test/validation/crypto/odp_crypto_test_rng.c
deleted file mode 100644
index 6a4ad17..0000000
--- a/test/validation/crypto/odp_crypto_test_rng.c
+++ /dev/null
@@ -1,28 +0,0 @@ 
-/* Copyright (c) 2014, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-#include <odp.h>
-#include <CUnit/Basic.h>
-#include <CUnit/TestDB.h>
-#include "test_vectors_len.h"
-
-/*
- * This test verifies that HW random number generator is able
- * to produce an IV for TDES_CBC cipher algorithm.
- * */
-#define RNG_GET_SIZE	"RNG_GET_SIZE"
-static void rng_get_size(void)
-{
-	int32_t ret;
-	uint8_t buf[TDES_CBC_IV_LEN];
-
-	ret = odp_random_data(buf, sizeof(buf), false);
-	CU_ASSERT(ret == TDES_CBC_IV_LEN);
-}
-
-CU_TestInfo test_rng[] = {
-	{ RNG_GET_SIZE, rng_get_size },
-	CU_TEST_INFO_NULL,
-};
diff --git a/test/validation/crypto/odp_crypto_test_rng.h b/test/validation/crypto/odp_crypto_test_rng.h
deleted file mode 100644
index 16909b3..0000000
--- a/test/validation/crypto/odp_crypto_test_rng.h
+++ /dev/null
@@ -1,17 +0,0 @@ 
-/* Copyright (c) 2014, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-#ifndef ODP_CRYPTO_TEST_RNG_
-#define ODP_CRYPTO_TEST_RNG_
-
-#include "CUnit/TestDB.h"
-
-/* Suite name */
-#define ODP_CRYPTO_RNG    "ODP_CRYPTO_RNG"
-
-/* Suite test array */
-extern CU_TestInfo test_rng[];
-
-#endif
diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
index fbe5dbb..6cb5695 100644
--- a/test/validation/odp_crypto.c
+++ b/test/validation/odp_crypto.c
@@ -8,7 +8,6 @@ 
 #include "odp_cunit_common.h"
 #include "odp_crypto_test_async_inp.h"
 #include "odp_crypto_test_sync_inp.h"
-#include "odp_crypto_test_rng.h"
 
 #define SHM_PKT_POOL_SIZE	(512*2048*2)
 #define SHM_PKT_POOL_BUF_SIZE	(1024 * 32)
@@ -19,7 +18,6 @@ 
 CU_SuiteInfo odp_testsuites[] = {
 	{ODP_CRYPTO_SYNC_INP, NULL, NULL, NULL, NULL, test_array_sync },
 	{ODP_CRYPTO_ASYNC_INP, NULL, NULL, NULL, NULL, test_array_async },
-	{ODP_CRYPTO_RNG, NULL, NULL, NULL, NULL, test_rng },
 	CU_SUITE_INFO_NULL,
 };
 
diff --git a/test/validation/odp_random.c b/test/validation/odp_random.c
new file mode 100644
index 0000000..ebc9705
--- /dev/null
+++ b/test/validation/odp_random.c
@@ -0,0 +1,30 @@ 
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp.h>
+#include <odp_cunit_common.h>
+
+/* Helper macro for CU_TestInfo initialization */
+#define _CU_TEST_INFO(test_func) {#test_func, test_func}
+
+static void random_get_size(void)
+{
+	int32_t ret;
+	uint8_t buf[32];
+
+	ret = odp_random_data(buf, sizeof(buf), false);
+	CU_ASSERT(ret == sizeof(buf));
+}
+
+CU_TestInfo test_odp_random[] = {
+	_CU_TEST_INFO(random_get_size),
+	CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo odp_testsuites[] = {
+	{"Random", NULL, NULL, NULL, NULL, test_odp_random},
+	CU_SUITE_INFO_NULL,
+};