diff mbox

[2/5] validation: common: add tests_global_init() function

Message ID 1417453530-18743-3-git-send-email-taras.kondratiuk@linaro.org
State Superseded
Headers show

Commit Message

Taras Kondratiuk Dec. 1, 2014, 5:05 p.m. UTC
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
 test/validation/common/odp_cunit_common.c |    9 +++++++++
 test/validation/common/odp_cunit_common.h |   14 ++++++++++++++
 2 files changed, 23 insertions(+)

Comments

Mike Holmes Dec. 2, 2014, 6:53 p.m. UTC | #1
On 1 December 2014 at 12:05, Taras Kondratiuk <taras.kondratiuk@linaro.org>
wrote:

> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
>

Reviewed-by: Mike Holmes <mike.holmes@linaro.org>


> ---
>  test/validation/common/odp_cunit_common.c |    9 +++++++++
>  test/validation/common/odp_cunit_common.h |   14 ++++++++++++++
>  2 files changed, 23 insertions(+)
>
> diff --git a/test/validation/common/odp_cunit_common.c
> b/test/validation/common/odp_cunit_common.c
> index c87e103..14ba840 100644
> --- a/test/validation/common/odp_cunit_common.c
> +++ b/test/validation/common/odp_cunit_common.c
> @@ -36,6 +36,11 @@ int odp_cunit_thread_exit(pthrd_arg *arg)
>         return 0;
>  }
>
> +__attribute__((__weak__)) int tests_global_init(void)
> +{
> +       return 0;
> +}
> +
>  int main(void)
>  {
>         int ret;
> @@ -52,6 +57,10 @@ int main(void)
>                 return -1;
>         }
>
> +       ret = tests_global_init();
> +       if (ret)
> +               return ret;
> +
>         CU_set_error_action(CUEA_ABORT);
>
>         CU_initialize_registry();
> diff --git a/test/validation/common/odp_cunit_common.h
> b/test/validation/common/odp_cunit_common.h
> index 1f30788..f967ca2 100644
> --- a/test/validation/common/odp_cunit_common.h
> +++ b/test/validation/common/odp_cunit_common.h
> @@ -40,5 +40,19 @@ typedef struct {
>  /** create thread fro start_routine function */
>  extern int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg
> *arg);
>  extern int odp_cunit_thread_exit(pthrd_arg *);
> +/**
> + * Global tests initialization.
> + *
> + * Initialize global resources needed by all testsuites. Default weak
> definition
> + * do nothing. Test application can override it by defining a strong
> version.
> + * The function is called by the common main() just after ODP global/local
> + * initialization.
> + *
> + * @note: This function is a workaround for Crypto test and other
> applications
> + *        should try not to use it, because it will complicate migration
> to a
> + *        single test application in future. Normally each testsuite have
> to
> + *        prepare its environment in its own init function.
> + */
> +extern int tests_global_init(void);
>
>
Is this not a case where cryptos odp_testsuite would be altered to
provide this function cryptos CUnit test suite init ?

Crypto should also provide a suite terminate that is symmetrical

CU_SuiteInfo odp_testsuites[] = {
        {ODP_CRYPTO_SYNC_INP, cryptotests_global_init,
cryptotests_global_term, NULL, NULL, test_array_sync },
        {ODP_CRYPTO_ASYNC_INP, cryptotests_global_init,
cryptotests_global_term , NULL, NULL, test_array_async },
        CU_SUITE_INFO_NULL,
};

Since this does not call global terminate I believe there is no SDK issues
for 1.0

I agree that the change can be a later patch



>  #endif /* ODP_CUNICT_COMMON_H */
> --
> 1.7.9.5
>
>
Taras Kondratiuk Dec. 3, 2014, 9:20 a.m. UTC | #2
On 12/02/2014 08:53 PM, Mike Holmes wrote:
> On 1 December 2014 at 12:05, Taras Kondratiuk
> <taras.kondratiuk@linaro.org <mailto:taras.kondratiuk@linaro.org>> wrote:
>     diff --git a/test/validation/common/odp_cunit_common.h
>     b/test/validation/common/odp_cunit_common.h
>     index 1f30788..f967ca2 100644
>     --- a/test/validation/common/odp_cunit_common.h
>     +++ b/test/validation/common/odp_cunit_common.h
>     @@ -40,5 +40,19 @@ typedef struct {
>       /** create thread fro start_routine function */
>       extern int odp_cunit_thread_create(void *func_ptr(void *),
>     pthrd_arg *arg);
>       extern int odp_cunit_thread_exit(pthrd_arg *);
>     +/**
>     + * Global tests initialization.
>     + *
>     + * Initialize global resources needed by all testsuites. Default
>     weak definition
>     + * do nothing. Test application can override it by defining a
>     strong version.
>     + * The function is called by the common main() just after ODP
>     global/local
>     + * initialization.
>     + *
>     + * @note: This function is a workaround for Crypto test and other
>     applications
>     + *        should try not to use it, because it will complicate
>     migration to a
>     + *        single test application in future. Normally each
>     testsuite have to
>     + *        prepare its environment in its own init function.
>     + */
>     +extern int tests_global_init(void);
>
>
> Is this not a case where cryptos odp_testsuite would be altered to
> provide this function cryptos CUnit test suite init ?
>
> Crypto should also provide a suite terminate that is symmetrical
>
> CU_SuiteInfo odp_testsuites[] = {
>          {ODP_CRYPTO_SYNC_INP, cryptotests_global_init,
> cryptotests_global_term, NULL, NULL, test_array_sync },
>          {ODP_CRYPTO_ASYNC_INP, cryptotests_global_init,
> cryptotests_global_term , NULL, NULL, test_array_async },
>          CU_SUITE_INFO_NULL,
> };

Exactly, but we don't have necessary API in place to correctly cleanup
resources initialized in testsuite init function. We need at least
buffer and queue destroy API. Patches for them are in ML.
diff mbox

Patch

diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
index c87e103..14ba840 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -36,6 +36,11 @@  int odp_cunit_thread_exit(pthrd_arg *arg)
 	return 0;
 }
 
+__attribute__((__weak__)) int tests_global_init(void)
+{
+	return 0;
+}
+
 int main(void)
 {
 	int ret;
@@ -52,6 +57,10 @@  int main(void)
 		return -1;
 	}
 
+	ret = tests_global_init();
+	if (ret)
+		return ret;
+
 	CU_set_error_action(CUEA_ABORT);
 
 	CU_initialize_registry();
diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h
index 1f30788..f967ca2 100644
--- a/test/validation/common/odp_cunit_common.h
+++ b/test/validation/common/odp_cunit_common.h
@@ -40,5 +40,19 @@  typedef struct {
 /** create thread fro start_routine function */
 extern int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg);
 extern int odp_cunit_thread_exit(pthrd_arg *);
+/**
+ * Global tests initialization.
+ *
+ * Initialize global resources needed by all testsuites. Default weak definition
+ * do nothing. Test application can override it by defining a strong version.
+ * The function is called by the common main() just after ODP global/local
+ * initialization.
+ *
+ * @note: This function is a workaround for Crypto test and other applications
+ *        should try not to use it, because it will complicate migration to a
+ *        single test application in future. Normally each testsuite have to
+ *        prepare its environment in its own init function.
+ */
+extern int tests_global_init(void);
 
 #endif /* ODP_CUNICT_COMMON_H */