diff mbox

[2/4] validation: add odp_cunit_update() to modify registered tests

Message ID 1442396523-18466-3-git-send-email-stuart.haslam@linaro.org
State New
Headers show

Commit Message

Stuart Haslam Sept. 16, 2015, 9:42 a.m. UTC
Add an odp_cunit_update() function to allow some attributes of previously
registered tests to be modified, such as whether it's active or not.

Previously, registering and running tests was done in a single step;

odp_cunit_run(testsuites);

But this is now split;

odp_cunit_register(testsuites);
odp_cunit_update(testsuites_updates);
odp_cunit_run();

The odp_cunit_update() is optional and none of the currently defined
tests use it, so there's no functional change in this patch.

Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
---
 test/validation/buffer/buffer.c                 |   7 +-
 test/validation/classification/classification.c |   7 +-
 test/validation/common/odp_cunit_common.c       | 107 ++++++++++++++++++++++--
 test/validation/common/odp_cunit_common.h       |  11 ++-
 test/validation/cpumask/cpumask.c               |   7 +-
 test/validation/crypto/crypto.c                 |  10 ++-
 test/validation/errno/errno.c                   |   7 +-
 test/validation/init/init.c                     |  29 ++++++-
 test/validation/packet/packet.c                 |   7 +-
 test/validation/pktio/pktio.c                   |   7 +-
 test/validation/pool/pool.c                     |   7 +-
 test/validation/queue/queue.c                   |   7 +-
 test/validation/random/random.c                 |   7 +-
 test/validation/scheduler/scheduler.c           |   7 +-
 test/validation/shmem/shmem.c                   |   7 +-
 test/validation/synchronizers/synchronizers.c   |  10 ++-
 test/validation/system/system.c                 |   7 +-
 test/validation/thread/thread.c                 |   7 +-
 test/validation/time/time.c                     |   7 +-
 test/validation/timer/timer.c                   |   7 +-
 20 files changed, 245 insertions(+), 27 deletions(-)

Comments

Christophe Milard Sept. 16, 2015, 3:03 p.m. UTC | #1
On 2015-09-16 10:42, Stuart Haslam wrote:
> Add an odp_cunit_update() function to allow some attributes of previously
> registered tests to be modified, such as whether it's active or not.
> 
> Previously, registering and running tests was done in a single step;
> 
> odp_cunit_run(testsuites);
> 
> But this is now split;
> 
> odp_cunit_register(testsuites);
> odp_cunit_update(testsuites_updates);
> odp_cunit_run();
> 
> The odp_cunit_update() is optional and none of the currently defined
> tests use it, so there's no functional change in this patch.
> 
> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> ---
>  test/validation/buffer/buffer.c                 |   7 +-
>  test/validation/classification/classification.c |   7 +-
>  test/validation/common/odp_cunit_common.c       | 107 ++++++++++++++++++++++--
>  test/validation/common/odp_cunit_common.h       |  11 ++-
>  test/validation/cpumask/cpumask.c               |   7 +-
>  test/validation/crypto/crypto.c                 |  10 ++-
>  test/validation/errno/errno.c                   |   7 +-
>  test/validation/init/init.c                     |  29 ++++++-
>  test/validation/packet/packet.c                 |   7 +-
>  test/validation/pktio/pktio.c                   |   7 +-
>  test/validation/pool/pool.c                     |   7 +-
>  test/validation/queue/queue.c                   |   7 +-
>  test/validation/random/random.c                 |   7 +-
>  test/validation/scheduler/scheduler.c           |   7 +-
>  test/validation/shmem/shmem.c                   |   7 +-
>  test/validation/synchronizers/synchronizers.c   |  10 ++-
>  test/validation/system/system.c                 |   7 +-
>  test/validation/thread/thread.c                 |   7 +-
>  test/validation/time/time.c                     |   7 +-
>  test/validation/timer/timer.c                   |   7 +-
>  20 files changed, 245 insertions(+), 27 deletions(-)
> 
> diff --git a/test/validation/buffer/buffer.c b/test/validation/buffer/buffer.c
> index 4600e59..257e95c 100644
> --- a/test/validation/buffer/buffer.c
> +++ b/test/validation/buffer/buffer.c
> @@ -153,5 +153,10 @@ odp_suiteinfo_t buffer_suites[] = {
>  
>  int buffer_main(void)
>  {
> -	return odp_cunit_run(buffer_suites);
> +	int ret = odp_cunit_register(buffer_suites);
> +
> +	if (ret == 0)
> +		odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/classification/classification.c b/test/validation/classification/classification.c
> index b868c61..fe9a827 100644
> --- a/test/validation/classification/classification.c
> +++ b/test/validation/classification/classification.c
> @@ -23,5 +23,10 @@ odp_suiteinfo_t classification_suites[] = {
>  
>  int classification_main(void)
>  {
> -	return odp_cunit_run(classification_suites);
> +	int ret = odp_cunit_register(classification_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
> index d63e87e..8b62370 100644
> --- a/test/validation/common/odp_cunit_common.c
> +++ b/test/validation/common/odp_cunit_common.c
> @@ -164,16 +164,99 @@ static int cunit_register_suites(odp_suiteinfo_t testsuites[])
>  	return 0;
>  }
>  
> +static int cunit_update_test(odp_suiteinfo_t *sinfo,
> +			     odp_testinfo_t *updated_tinfo)
> +{
> +	odp_testinfo_t *tinfo;
> +
> +	for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++)
> +		if (strcmp(tinfo->testinfo.pName,
> +			   updated_tinfo->testinfo.pName) == 0)
> +			break;
> +
> +	if (!tinfo || !tinfo->testinfo.pName)
> +		return -1;
> +
> +	tinfo->check_active = updated_tinfo->check_active;
> +
> +	return 0;
> +}

Is the above function meant to update the tests or the test activity?
It looks like it only update the test activity...

> +
> +static int cunit_update_suite(odp_suiteinfo_t *updated_sinfo)
> +{
> +	CU_pSuite suite;
> +	CU_pTest test;
> +	odp_suiteinfo_t *sinfo;
> +	odp_testinfo_t *tinfo;
> +
> +	/* find previously registered suite with matching name */
> +	for (sinfo = global_testsuites; sinfo->pName; sinfo++)
> +		if (strcmp(sinfo->pName, updated_sinfo->pName) == 0)
> +			break;
> +
> +	if (!sinfo || !sinfo->pName) {
> +		fprintf(stderr, "%s: unable to add new suite: %s\n",

shouldn't it say "unable to find existing suite with matching name"?

> +			__func__, updated_sinfo->pName);
> +		return -1;
> +	}
> +
> +	/* lookup the associated CUnit suite */
> +	suite = CU_get_suite_by_name(sinfo->pName, CU_get_registry());
> +	if (!suite) {
> +		fprintf(stderr, "%s: can't find registered suite %s\n",

shouldn't it say "unable to find existing suite with matching name in registery"?

> +			__func__, sinfo->pName);
> +		return CU_get_error();
> +	}
> +
> +	sinfo->pInitFunc = updated_sinfo->pInitFunc;
> +	sinfo->pCleanupFunc = updated_sinfo->pCleanupFunc;
> +
> +	CU_set_suite_cleanupfunc(suite, updated_sinfo->pCleanupFunc);
> +
> +	for (tinfo = updated_sinfo->pTests; tinfo->testinfo.pName; tinfo++) {
> +		test = CU_get_test(suite, tinfo->testinfo.pName);
> +
> +		if (test) {
> +			CU_ErrorCode err = CU_set_test_func(test,
> +						tinfo->testinfo.pTestFunc);
> +			if (err != CUE_SUCCESS)
> +				return -1;
> +
> +			if (cunit_update_test(sinfo, tinfo) != 0)
> +				return -1;
> +		} else {
> +			fprintf(stderr, "%s: unable to add new test: %s\n",
> +				__func__, tinfo->testinfo.pName);
> +			return -1;
> +		}
> +	}
> +
> +	return 0;
> +}
> +

I am not sure about the meaning of the two above fuctions...
From their names I understand that they should update the data associated
with the tests, but the test function pointers contained in odp_suiteinfo_t
don't seem to be taken into account...
It looks like cunit_update_test() only updates the activity flag in the test,
whereas cunit_update_suite() upddates init + cleanup + activity flag
It would make sense to me to update the test function pointers as well in cunit_update_test().
If not their name should indidate what they are intended to do.

/Christophe
>  /*
> - * Register test suites to be run via odp_cunit_run()
> + * Update suites/tests previously registered via odp_cunit_register().
> + *
> + * Note that this is intended for modifying the properties of already
> + * registered suites/tests. New suites/tests can only be registered via
> + * odp_cunit_register().
>   */
> -int odp_cunit_run(odp_suiteinfo_t testsuites[])
> +int odp_cunit_update(odp_suiteinfo_t testsuites[])
>  {
> -	int ret;
> +	int ret = 0;
> +	odp_suiteinfo_t *sinfo;
>  
> -	printf("\tODP API version: %s\n", odp_version_api_str());
> -	printf("\tODP implementation version: %s\n", odp_version_impl_str());
> +	for (sinfo = testsuites; sinfo->pName && ret == 0; sinfo++)
> +		ret = cunit_update_suite(sinfo);
>  
> +	return ret;
> +}
> +
> +/*
> + * Register test suites to be run via odp_cunit_run()
> + */
> +int odp_cunit_register(odp_suiteinfo_t testsuites[])
> +{
>  	/* call test executable init hook, if any */
>  	if (global_init_term.global_init_ptr &&
>  	    ((*global_init_term.global_init_ptr)() != 0))
> @@ -185,6 +268,20 @@ int odp_cunit_run(odp_suiteinfo_t testsuites[])
>  	global_testsuites = testsuites;
>  	cunit_register_suites(testsuites);
>  	CU_set_fail_on_inactive(CU_FALSE);
> +
> +	return 0;
> +}
> +
> +/*
> + * Run tests previously registered via odp_cunit_register()
> + */
> +int odp_cunit_run(void)
> +{
> +	int ret;
> +
> +	printf("\tODP API version: %s\n", odp_version_api_str());
> +	printf("\tODP implementation version: %s\n", odp_version_impl_str());
> +
>  	CU_basic_set_mode(CU_BRM_VERBOSE);
>  	CU_basic_run_tests();
>  
> diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h
> index 218146c..c689054 100644
> --- a/test/validation/common/odp_cunit_common.h
> +++ b/test/validation/common/odp_cunit_common.h
> @@ -68,9 +68,16 @@ typedef struct {
>  	int numthrds; /**< no of pthreads to create */
>  } pthrd_arg;
>  
> +/* register suites to be run via odp_cunit_run() */
> +int odp_cunit_register(odp_suiteinfo_t testsuites[]);
> +/* update tests previously registered via odp_cunit_register() */
> +int odp_cunit_update(odp_suiteinfo_t testsuites[]);
> +/* the function, called by module main(), to run the testsuites: */
> +int odp_cunit_run(void);
> +
>  /** 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 *);
> +int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg);
> +int odp_cunit_thread_exit(pthrd_arg *);
>  
>  /**
>   * Global tests initialization/termination.
> diff --git a/test/validation/cpumask/cpumask.c b/test/validation/cpumask/cpumask.c
> index 37dee6a..bf5421e 100644
> --- a/test/validation/cpumask/cpumask.c
> +++ b/test/validation/cpumask/cpumask.c
> @@ -101,5 +101,10 @@ odp_suiteinfo_t cpumask_suites[] = {
>  
>  int cpumask_main(void)
>  {
> -	return odp_cunit_run(cpumask_suites);
> +	int ret = odp_cunit_register(cpumask_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/crypto/crypto.c b/test/validation/crypto/crypto.c
> index b2f9d96..9229cab 100644
> --- a/test/validation/crypto/crypto.c
> +++ b/test/validation/crypto/crypto.c
> @@ -94,7 +94,15 @@ int crypto_term(void)
>  
>  int crypto_main(void)
>  {
> +	int ret;
> +
>  	odp_cunit_register_global_init(crypto_init);
>  	odp_cunit_register_global_term(crypto_term);
> -	return odp_cunit_run(crypto_suites);
> +
> +	ret = odp_cunit_register(crypto_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/errno/errno.c b/test/validation/errno/errno.c
> index 6196164..d0e2128 100644
> --- a/test/validation/errno/errno.c
> +++ b/test/validation/errno/errno.c
> @@ -31,5 +31,10 @@ odp_suiteinfo_t errno_suites[] = {
>  
>  int errno_main(void)
>  {
> -	return odp_cunit_run(errno_suites);
> +	int ret = odp_cunit_register(errno_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/init/init.c b/test/validation/init/init.c
> index d5ec333..a8a5640 100644
> --- a/test/validation/init/init.c
> +++ b/test/validation/init/init.c
> @@ -53,12 +53,19 @@ static void odp_init_abort(void)
>  
>  int init_main_abort(void)
>  {
> +	int ret;
> +
>  	/* prevent default ODP init: */
>  	odp_cunit_register_global_init(NULL);
>  	odp_cunit_register_global_term(NULL);
>  
>  	/* run the tests: */
> -	return odp_cunit_run(init_suites_abort);
> +	ret = odp_cunit_register(init_suites_abort);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
>  
>  /* test ODP global init, with alternate log function */
> @@ -109,12 +116,20 @@ static int odp_init_log(odp_log_level_e level __attribute__((unused)),
>  
>  int init_main_log(void)
>  {
> +	int ret;
> +
>  	/* prevent default ODP init: */
>  	odp_cunit_register_global_init(NULL);
>  	odp_cunit_register_global_term(NULL);
>  
> +	/* register the tests: */
> +	ret = odp_cunit_register(init_suites_log);
> +
>  	/* run the tests: */
> -	return odp_cunit_run(init_suites_log);
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
>  
>  /* test normal ODP global init */
> @@ -141,10 +156,18 @@ odp_suiteinfo_t init_suites_ok[] = {
>  
>  int init_main_ok(void)
>  {
> +	int ret;
> +
>  	/* prevent default ODP init: */
>  	odp_cunit_register_global_init(NULL);
>  	odp_cunit_register_global_term(NULL);
>  
> +	/* register the tests: */
> +	ret = odp_cunit_register(init_suites_ok);
> +
>  	/* run the tests: */
> -	return odp_cunit_run(init_suites_ok);
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c
> index 8a4f0a6..d9a543f 100644
> --- a/test/validation/packet/packet.c
> +++ b/test/validation/packet/packet.c
> @@ -805,5 +805,10 @@ odp_suiteinfo_t packet_suites[] = {
>  
>  int packet_main(void)
>  {
> -	return odp_cunit_run(packet_suites);
> +	int ret = odp_cunit_register(packet_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
> index bfcaace..118fe89 100644
> --- a/test/validation/pktio/pktio.c
> +++ b/test/validation/pktio/pktio.c
> @@ -908,5 +908,10 @@ odp_suiteinfo_t pktio_suites[] = {
>  
>  int pktio_main(void)
>  {
> -	return odp_cunit_run(pktio_suites);
> +	int ret = odp_cunit_register(pktio_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/pool/pool.c b/test/validation/pool/pool.c
> index 3de2714..bca210a 100644
> --- a/test/validation/pool/pool.c
> +++ b/test/validation/pool/pool.c
> @@ -116,5 +116,10 @@ odp_suiteinfo_t pool_suites[] = {
>  
>  int pool_main(void)
>  {
> -	return odp_cunit_run(pool_suites);
> +	int ret = odp_cunit_register(pool_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c
> index 7d6de54..98da2ec 100644
> --- a/test/validation/queue/queue.c
> +++ b/test/validation/queue/queue.c
> @@ -137,5 +137,10 @@ odp_suiteinfo_t queue_suites[] = {
>  
>  int queue_main(void)
>  {
> -	return odp_cunit_run(queue_suites);
> +	int ret = odp_cunit_register(queue_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/random/random.c b/test/validation/random/random.c
> index a9a5a01..8ed5944 100644
> --- a/test/validation/random/random.c
> +++ b/test/validation/random/random.c
> @@ -29,5 +29,10 @@ odp_suiteinfo_t random_suites[] = {
>  
>  int random_main(void)
>  {
> -	return odp_cunit_run(random_suites);
> +	int ret = odp_cunit_register(random_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c
> index 81653c4..684dba5 100644
> --- a/test/validation/scheduler/scheduler.c
> +++ b/test/validation/scheduler/scheduler.c
> @@ -1149,5 +1149,10 @@ odp_suiteinfo_t scheduler_suites[] = {
>  
>  int scheduler_main(void)
>  {
> -	return odp_cunit_run(scheduler_suites);
> +	int ret = odp_cunit_register(scheduler_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c
> index 41ec725..5524b5c 100644
> --- a/test/validation/shmem/shmem.c
> +++ b/test/validation/shmem/shmem.c
> @@ -88,5 +88,10 @@ odp_suiteinfo_t shmem_suites[] = {
>  
>  int shmem_main(void)
>  {
> -	return odp_cunit_run(shmem_suites);
> +	int ret = odp_cunit_register(shmem_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
> index 595be74..96783fa 100644
> --- a/test/validation/synchronizers/synchronizers.c
> +++ b/test/validation/synchronizers/synchronizers.c
> @@ -1212,6 +1212,14 @@ odp_suiteinfo_t synchronizers_suites[] = {
>  
>  int synchronizers_main(void)
>  {
> +	int ret;
> +
>  	odp_cunit_register_global_init(synchronizers_init);
> -	return odp_cunit_run(synchronizers_suites);
> +
> +	ret = odp_cunit_register(synchronizers_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/system/system.c b/test/validation/system/system.c
> index cf0ab0a..7dc2cc0 100644
> --- a/test/validation/system/system.c
> +++ b/test/validation/system/system.c
> @@ -101,5 +101,10 @@ odp_suiteinfo_t system_suites[] = {
>  
>  int system_main(void)
>  {
> -	return odp_cunit_run(system_suites);
> +	int ret = odp_cunit_register(system_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/thread/thread.c b/test/validation/thread/thread.c
> index b86ebd3..9ba8322 100644
> --- a/test/validation/thread/thread.c
> +++ b/test/validation/thread/thread.c
> @@ -125,5 +125,10 @@ odp_suiteinfo_t thread_suites[] = {
>  
>  int thread_main(void)
>  {
> -	return odp_cunit_run(thread_suites);
> +	int ret = odp_cunit_register(thread_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/time/time.c b/test/validation/time/time.c
> index f2c196c..41db0e9 100644
> --- a/test/validation/time/time.c
> +++ b/test/validation/time/time.c
> @@ -75,5 +75,10 @@ odp_suiteinfo_t time_suites[] = {
>  
>  int time_main(void)
>  {
> -	return odp_cunit_run(time_suites);
> +	int ret = odp_cunit_register(time_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
> index 02398f7..645dc58 100644
> --- a/test/validation/timer/timer.c
> +++ b/test/validation/timer/timer.c
> @@ -544,5 +544,10 @@ odp_suiteinfo_t timer_suites[] = {
>  
>  int timer_main(void)
>  {
> -	return odp_cunit_run(timer_suites);
> +	int ret = odp_cunit_register(timer_suites);
> +
> +	if (ret == 0)
> +		ret = odp_cunit_run();
> +
> +	return ret;
>  }
> -- 
> 2.1.1
> 
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
Stuart Haslam Sept. 16, 2015, 4:07 p.m. UTC | #2
On Wed, Sep 16, 2015 at 05:03:38PM +0200, Christophe Milard wrote:
> On 2015-09-16 10:42, Stuart Haslam wrote:
> > Add an odp_cunit_update() function to allow some attributes of previously
> > registered tests to be modified, such as whether it's active or not.
> > 
> > Previously, registering and running tests was done in a single step;
> > 
> > odp_cunit_run(testsuites);
> > 
> > But this is now split;
> > 
> > odp_cunit_register(testsuites);
> > odp_cunit_update(testsuites_updates);
> > odp_cunit_run();
> > 
> > The odp_cunit_update() is optional and none of the currently defined
> > tests use it, so there's no functional change in this patch.
> > 
> > Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> > ---
> >  test/validation/buffer/buffer.c                 |   7 +-
> >  test/validation/classification/classification.c |   7 +-
> >  test/validation/common/odp_cunit_common.c       | 107 ++++++++++++++++++++++--
> >  test/validation/common/odp_cunit_common.h       |  11 ++-
> >  test/validation/cpumask/cpumask.c               |   7 +-
> >  test/validation/crypto/crypto.c                 |  10 ++-
> >  test/validation/errno/errno.c                   |   7 +-
> >  test/validation/init/init.c                     |  29 ++++++-
> >  test/validation/packet/packet.c                 |   7 +-
> >  test/validation/pktio/pktio.c                   |   7 +-
> >  test/validation/pool/pool.c                     |   7 +-
> >  test/validation/queue/queue.c                   |   7 +-
> >  test/validation/random/random.c                 |   7 +-
> >  test/validation/scheduler/scheduler.c           |   7 +-
> >  test/validation/shmem/shmem.c                   |   7 +-
> >  test/validation/synchronizers/synchronizers.c   |  10 ++-
> >  test/validation/system/system.c                 |   7 +-
> >  test/validation/thread/thread.c                 |   7 +-
> >  test/validation/time/time.c                     |   7 +-
> >  test/validation/timer/timer.c                   |   7 +-
> >  20 files changed, 245 insertions(+), 27 deletions(-)
> > 
> > diff --git a/test/validation/buffer/buffer.c b/test/validation/buffer/buffer.c
> > index 4600e59..257e95c 100644
> > --- a/test/validation/buffer/buffer.c
> > +++ b/test/validation/buffer/buffer.c
> > @@ -153,5 +153,10 @@ odp_suiteinfo_t buffer_suites[] = {
> >  
> >  int buffer_main(void)
> >  {
> > -	return odp_cunit_run(buffer_suites);
> > +	int ret = odp_cunit_register(buffer_suites);
> > +
> > +	if (ret == 0)
> > +		odp_cunit_run();
> > +
> > +	return ret;
> >  }
> > diff --git a/test/validation/classification/classification.c b/test/validation/classification/classification.c
> > index b868c61..fe9a827 100644
> > --- a/test/validation/classification/classification.c
> > +++ b/test/validation/classification/classification.c
> > @@ -23,5 +23,10 @@ odp_suiteinfo_t classification_suites[] = {
> >  
> >  int classification_main(void)
> >  {
> > -	return odp_cunit_run(classification_suites);
> > +	int ret = odp_cunit_register(classification_suites);
> > +
> > +	if (ret == 0)
> > +		ret = odp_cunit_run();
> > +
> > +	return ret;
> >  }
> > diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
> > index d63e87e..8b62370 100644
> > --- a/test/validation/common/odp_cunit_common.c
> > +++ b/test/validation/common/odp_cunit_common.c
> > @@ -164,16 +164,99 @@ static int cunit_register_suites(odp_suiteinfo_t testsuites[])
> >  	return 0;
> >  }
> >  
> > +static int cunit_update_test(odp_suiteinfo_t *sinfo,
> > +			     odp_testinfo_t *updated_tinfo)
> > +{
> > +	odp_testinfo_t *tinfo;
> > +
> > +	for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++)
> > +		if (strcmp(tinfo->testinfo.pName,
> > +			   updated_tinfo->testinfo.pName) == 0)
> > +			break;
> > +
> > +	if (!tinfo || !tinfo->testinfo.pName)
> > +		return -1;
> > +
> > +	tinfo->check_active = updated_tinfo->check_active;
> > +
> > +	return 0;
> > +}
> 
> Is the above function meant to update the tests or the test activity?
> It looks like it only update the test activity...
> 

This is just updating the local properties of the test (i.e. stuff
that's in odp_testinfo_t but not in CU_TestInfo). The test function
itself is modified by the call to CU_set_test_func() before this
function is called. I'll rework it a little to make that clearer
though.

> > +
> > +static int cunit_update_suite(odp_suiteinfo_t *updated_sinfo)
> > +{
> > +	CU_pSuite suite;
> > +	CU_pTest test;
> > +	odp_suiteinfo_t *sinfo;
> > +	odp_testinfo_t *tinfo;
> > +
> > +	/* find previously registered suite with matching name */
> > +	for (sinfo = global_testsuites; sinfo->pName; sinfo++)
> > +		if (strcmp(sinfo->pName, updated_sinfo->pName) == 0)
> > +			break;
> > +
> > +	if (!sinfo || !sinfo->pName) {
> > +		fprintf(stderr, "%s: unable to add new suite: %s\n",
> 
> shouldn't it say "unable to find existing suite with matching name"?
> 

OK. I was supposing that this would only occur if someone was
incorrectly attempting to register a new suite via update.

> > +			__func__, updated_sinfo->pName);
> > +		return -1;
> > +	}
> > +
> > +	/* lookup the associated CUnit suite */
> > +	suite = CU_get_suite_by_name(sinfo->pName, CU_get_registry());
> > +	if (!suite) {
> > +		fprintf(stderr, "%s: can't find registered suite %s\n",
> 
> shouldn't it say "unable to find existing suite with matching name in registery"?

OK. This means I'll have to figure out what our policy is on long vs
wrapped lines as I've lost track :)

> > +			__func__, sinfo->pName);
> > +		return CU_get_error();
> > +	}
> > +
> > +	sinfo->pInitFunc = updated_sinfo->pInitFunc;
> > +	sinfo->pCleanupFunc = updated_sinfo->pCleanupFunc;
> > +
> > +	CU_set_suite_cleanupfunc(suite, updated_sinfo->pCleanupFunc);
> > +
> > +	for (tinfo = updated_sinfo->pTests; tinfo->testinfo.pName; tinfo++) {
> > +		test = CU_get_test(suite, tinfo->testinfo.pName);
> > +
> > +		if (test) {
> > +			CU_ErrorCode err = CU_set_test_func(test,
> > +						tinfo->testinfo.pTestFunc);
> > +			if (err != CUE_SUCCESS)
> > +				return -1;
> > +
> > +			if (cunit_update_test(sinfo, tinfo) != 0)
> > +				return -1;
> > +		} else {
> > +			fprintf(stderr, "%s: unable to add new test: %s\n",
> > +				__func__, tinfo->testinfo.pName);
> > +			return -1;
> > +		}
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> 
> I am not sure about the meaning of the two above fuctions...
> From their names I understand that they should update the data associated
> with the tests, but the test function pointers contained in odp_suiteinfo_t
> don't seem to be taken into account...
> It looks like cunit_update_test() only updates the activity flag in the test,
> whereas cunit_update_suite() upddates init + cleanup + activity flag
> It would make sense to me to update the test function pointers as well in cunit_update_test().
> If not their name should indidate what they are intended to do.
> 

As above, it does update the test function. To replace the test function
with a locally defined one you'd need the test name to match the
previously registered one (as this is the "official" name of the test
case being replaced) but the symbol name to be different (to avoid
potential collisions). The ODP_TEST_INFO* macros don't support this
but you could currently do it manually;

static odp_testinfo_t foo_tests_updates[] = {
	{{"foo_test_b", my_local_foo_test_b}, NULL},
	ODP_TEST_INFO_NULL
};

I think that's fine, given that I expect this is an uncommon use case.
Christophe Milard Sept. 16, 2015, 4:46 p.m. UTC | #3
On 16 September 2015 at 18:07, Stuart Haslam <stuart.haslam@linaro.org>
wrote:

> On Wed, Sep 16, 2015 at 05:03:38PM +0200, Christophe Milard wrote:
> > On 2015-09-16 10:42, Stuart Haslam wrote:
> > > Add an odp_cunit_update() function to allow some attributes of
> previously
> > > registered tests to be modified, such as whether it's active or not.
> > >
> > > Previously, registering and running tests was done in a single step;
> > >
> > > odp_cunit_run(testsuites);
> > >
> > > But this is now split;
> > >
> > > odp_cunit_register(testsuites);
> > > odp_cunit_update(testsuites_updates);
> > > odp_cunit_run();
> > >
> > > The odp_cunit_update() is optional and none of the currently defined
> > > tests use it, so there's no functional change in this patch.
> > >
> > > Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> > > ---
> > >  test/validation/buffer/buffer.c                 |   7 +-
> > >  test/validation/classification/classification.c |   7 +-
> > >  test/validation/common/odp_cunit_common.c       | 107
> ++++++++++++++++++++++--
> > >  test/validation/common/odp_cunit_common.h       |  11 ++-
> > >  test/validation/cpumask/cpumask.c               |   7 +-
> > >  test/validation/crypto/crypto.c                 |  10 ++-
> > >  test/validation/errno/errno.c                   |   7 +-
> > >  test/validation/init/init.c                     |  29 ++++++-
> > >  test/validation/packet/packet.c                 |   7 +-
> > >  test/validation/pktio/pktio.c                   |   7 +-
> > >  test/validation/pool/pool.c                     |   7 +-
> > >  test/validation/queue/queue.c                   |   7 +-
> > >  test/validation/random/random.c                 |   7 +-
> > >  test/validation/scheduler/scheduler.c           |   7 +-
> > >  test/validation/shmem/shmem.c                   |   7 +-
> > >  test/validation/synchronizers/synchronizers.c   |  10 ++-
> > >  test/validation/system/system.c                 |   7 +-
> > >  test/validation/thread/thread.c                 |   7 +-
> > >  test/validation/time/time.c                     |   7 +-
> > >  test/validation/timer/timer.c                   |   7 +-
> > >  20 files changed, 245 insertions(+), 27 deletions(-)
> > >
> > > diff --git a/test/validation/buffer/buffer.c
> b/test/validation/buffer/buffer.c
> > > index 4600e59..257e95c 100644
> > > --- a/test/validation/buffer/buffer.c
> > > +++ b/test/validation/buffer/buffer.c
> > > @@ -153,5 +153,10 @@ odp_suiteinfo_t buffer_suites[] = {
> > >
> > >  int buffer_main(void)
> > >  {
> > > -   return odp_cunit_run(buffer_suites);
> > > +   int ret = odp_cunit_register(buffer_suites);
> > > +
> > > +   if (ret == 0)
> > > +           odp_cunit_run();
> > > +
> > > +   return ret;
> > >  }
> > > diff --git a/test/validation/classification/classification.c
> b/test/validation/classification/classification.c
> > > index b868c61..fe9a827 100644
> > > --- a/test/validation/classification/classification.c
> > > +++ b/test/validation/classification/classification.c
> > > @@ -23,5 +23,10 @@ odp_suiteinfo_t classification_suites[] = {
> > >
> > >  int classification_main(void)
> > >  {
> > > -   return odp_cunit_run(classification_suites);
> > > +   int ret = odp_cunit_register(classification_suites);
> > > +
> > > +   if (ret == 0)
> > > +           ret = odp_cunit_run();
> > > +
> > > +   return ret;
> > >  }
> > > diff --git a/test/validation/common/odp_cunit_common.c
> b/test/validation/common/odp_cunit_common.c
> > > index d63e87e..8b62370 100644
> > > --- a/test/validation/common/odp_cunit_common.c
> > > +++ b/test/validation/common/odp_cunit_common.c
> > > @@ -164,16 +164,99 @@ static int cunit_register_suites(odp_suiteinfo_t
> testsuites[])
> > >     return 0;
> > >  }
> > >
> > > +static int cunit_update_test(odp_suiteinfo_t *sinfo,
> > > +                        odp_testinfo_t *updated_tinfo)
> > > +{
> > > +   odp_testinfo_t *tinfo;
> > > +
> > > +   for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++)
> > > +           if (strcmp(tinfo->testinfo.pName,
> > > +                      updated_tinfo->testinfo.pName) == 0)
> > > +                   break;
> > > +
> > > +   if (!tinfo || !tinfo->testinfo.pName)
> > > +           return -1;
> > > +
> > > +   tinfo->check_active = updated_tinfo->check_active;
> > > +
> > > +   return 0;
> > > +}
> >
> > Is the above function meant to update the tests or the test activity?
> > It looks like it only update the test activity...
> >
>
> This is just updating the local properties of the test (i.e. stuff
> that's in odp_testinfo_t but not in CU_TestInfo). The test function
> itself is modified by the call to CU_set_test_func() before this
> function is called. I'll rework it a little to make that clearer
> though.
>

Yes please... I understood from the code, but I felt the code did not match
the function name.
Why not calling it ...update_properties?

>
> > > +
> > > +static int cunit_update_suite(odp_suiteinfo_t *updated_sinfo)
> > > +{
> > > +   CU_pSuite suite;
> > > +   CU_pTest test;
> > > +   odp_suiteinfo_t *sinfo;
> > > +   odp_testinfo_t *tinfo;
> > > +
> > > +   /* find previously registered suite with matching name */
> > > +   for (sinfo = global_testsuites; sinfo->pName; sinfo++)
> > > +           if (strcmp(sinfo->pName, updated_sinfo->pName) == 0)
> > > +                   break;
> > > +
> > > +   if (!sinfo || !sinfo->pName) {
> > > +           fprintf(stderr, "%s: unable to add new suite: %s\n",
> >
> > shouldn't it say "unable to find existing suite with matching name"?
> >
>
> OK. I was supposing that this would only occur if someone was
> incorrectly attempting to register a new suite via update.
>

Then maybe it should say "text XXX not found: use YYY to add new tests"...


>
> > > +                   __func__, updated_sinfo->pName);
> > > +           return -1;
> > > +   }
> > > +
> > > +   /* lookup the associated CUnit suite */
> > > +   suite = CU_get_suite_by_name(sinfo->pName, CU_get_registry());
> > > +   if (!suite) {
> > > +           fprintf(stderr, "%s: can't find registered suite %s\n",
> >
> > shouldn't it say "unable to find existing suite with matching name in
> registery"?
>
> OK. This means I'll have to figure out what our policy is on long vs
> wrapped lines as I've lost track :)
>

I won't fight you with the wording...


>
> > > +                   __func__, sinfo->pName);
> > > +           return CU_get_error();
> > > +   }
> > > +
> > > +   sinfo->pInitFunc = updated_sinfo->pInitFunc;
> > > +   sinfo->pCleanupFunc = updated_sinfo->pCleanupFunc;
> > > +
> > > +   CU_set_suite_cleanupfunc(suite, updated_sinfo->pCleanupFunc);
> > > +
> > > +   for (tinfo = updated_sinfo->pTests; tinfo->testinfo.pName;
> tinfo++) {
> > > +           test = CU_get_test(suite, tinfo->testinfo.pName);
> > > +
> > > +           if (test) {
> > > +                   CU_ErrorCode err = CU_set_test_func(test,
> > > +                                           tinfo->testinfo.pTestFunc);
> > > +                   if (err != CUE_SUCCESS)
> > > +                           return -1;
> > > +
> > > +                   if (cunit_update_test(sinfo, tinfo) != 0)
> > > +                           return -1;
> > > +           } else {
> > > +                   fprintf(stderr, "%s: unable to add new test: %s\n",
> > > +                           __func__, tinfo->testinfo.pName);
> > > +                   return -1;
> > > +           }
> > > +   }
> > > +
> > > +   return 0;
> > > +}
> > > +
> >
> > I am not sure about the meaning of the two above fuctions...
> > From their names I understand that they should update the data associated
> > with the tests, but the test function pointers contained in
> odp_suiteinfo_t
> > don't seem to be taken into account...
> > It looks like cunit_update_test() only updates the activity flag in the
> test,
> > whereas cunit_update_suite() upddates init + cleanup + activity flag
> > It would make sense to me to update the test function pointers as well
> in cunit_update_test().
> > If not their name should indidate what they are intended to do.
> >
>
> As above, it does update the test function. To replace the test function
> with a locally defined one you'd need the test name to match the
> previously registered one (as this is the "official" name of the test
> case being replaced) but the symbol name to be different (to avoid
> potential collisions). The ODP_TEST_INFO* macros don't support this
> but you could currently do it manually;
>
> static odp_testinfo_t foo_tests_updates[] = {
>         {{"foo_test_b", my_local_foo_test_b}, NULL},
>         ODP_TEST_INFO_NULL
> };
>
> I think that's fine, given that I expect this is an uncommon use case.
>

I think it is good enough too. As long as it is clear

Christophe


>
> --
> Stuart.
>
diff mbox

Patch

diff --git a/test/validation/buffer/buffer.c b/test/validation/buffer/buffer.c
index 4600e59..257e95c 100644
--- a/test/validation/buffer/buffer.c
+++ b/test/validation/buffer/buffer.c
@@ -153,5 +153,10 @@  odp_suiteinfo_t buffer_suites[] = {
 
 int buffer_main(void)
 {
-	return odp_cunit_run(buffer_suites);
+	int ret = odp_cunit_register(buffer_suites);
+
+	if (ret == 0)
+		odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/classification/classification.c b/test/validation/classification/classification.c
index b868c61..fe9a827 100644
--- a/test/validation/classification/classification.c
+++ b/test/validation/classification/classification.c
@@ -23,5 +23,10 @@  odp_suiteinfo_t classification_suites[] = {
 
 int classification_main(void)
 {
-	return odp_cunit_run(classification_suites);
+	int ret = odp_cunit_register(classification_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
index d63e87e..8b62370 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -164,16 +164,99 @@  static int cunit_register_suites(odp_suiteinfo_t testsuites[])
 	return 0;
 }
 
+static int cunit_update_test(odp_suiteinfo_t *sinfo,
+			     odp_testinfo_t *updated_tinfo)
+{
+	odp_testinfo_t *tinfo;
+
+	for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++)
+		if (strcmp(tinfo->testinfo.pName,
+			   updated_tinfo->testinfo.pName) == 0)
+			break;
+
+	if (!tinfo || !tinfo->testinfo.pName)
+		return -1;
+
+	tinfo->check_active = updated_tinfo->check_active;
+
+	return 0;
+}
+
+static int cunit_update_suite(odp_suiteinfo_t *updated_sinfo)
+{
+	CU_pSuite suite;
+	CU_pTest test;
+	odp_suiteinfo_t *sinfo;
+	odp_testinfo_t *tinfo;
+
+	/* find previously registered suite with matching name */
+	for (sinfo = global_testsuites; sinfo->pName; sinfo++)
+		if (strcmp(sinfo->pName, updated_sinfo->pName) == 0)
+			break;
+
+	if (!sinfo || !sinfo->pName) {
+		fprintf(stderr, "%s: unable to add new suite: %s\n",
+			__func__, updated_sinfo->pName);
+		return -1;
+	}
+
+	/* lookup the associated CUnit suite */
+	suite = CU_get_suite_by_name(sinfo->pName, CU_get_registry());
+	if (!suite) {
+		fprintf(stderr, "%s: can't find registered suite %s\n",
+			__func__, sinfo->pName);
+		return CU_get_error();
+	}
+
+	sinfo->pInitFunc = updated_sinfo->pInitFunc;
+	sinfo->pCleanupFunc = updated_sinfo->pCleanupFunc;
+
+	CU_set_suite_cleanupfunc(suite, updated_sinfo->pCleanupFunc);
+
+	for (tinfo = updated_sinfo->pTests; tinfo->testinfo.pName; tinfo++) {
+		test = CU_get_test(suite, tinfo->testinfo.pName);
+
+		if (test) {
+			CU_ErrorCode err = CU_set_test_func(test,
+						tinfo->testinfo.pTestFunc);
+			if (err != CUE_SUCCESS)
+				return -1;
+
+			if (cunit_update_test(sinfo, tinfo) != 0)
+				return -1;
+		} else {
+			fprintf(stderr, "%s: unable to add new test: %s\n",
+				__func__, tinfo->testinfo.pName);
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
 /*
- * Register test suites to be run via odp_cunit_run()
+ * Update suites/tests previously registered via odp_cunit_register().
+ *
+ * Note that this is intended for modifying the properties of already
+ * registered suites/tests. New suites/tests can only be registered via
+ * odp_cunit_register().
  */
-int odp_cunit_run(odp_suiteinfo_t testsuites[])
+int odp_cunit_update(odp_suiteinfo_t testsuites[])
 {
-	int ret;
+	int ret = 0;
+	odp_suiteinfo_t *sinfo;
 
-	printf("\tODP API version: %s\n", odp_version_api_str());
-	printf("\tODP implementation version: %s\n", odp_version_impl_str());
+	for (sinfo = testsuites; sinfo->pName && ret == 0; sinfo++)
+		ret = cunit_update_suite(sinfo);
 
+	return ret;
+}
+
+/*
+ * Register test suites to be run via odp_cunit_run()
+ */
+int odp_cunit_register(odp_suiteinfo_t testsuites[])
+{
 	/* call test executable init hook, if any */
 	if (global_init_term.global_init_ptr &&
 	    ((*global_init_term.global_init_ptr)() != 0))
@@ -185,6 +268,20 @@  int odp_cunit_run(odp_suiteinfo_t testsuites[])
 	global_testsuites = testsuites;
 	cunit_register_suites(testsuites);
 	CU_set_fail_on_inactive(CU_FALSE);
+
+	return 0;
+}
+
+/*
+ * Run tests previously registered via odp_cunit_register()
+ */
+int odp_cunit_run(void)
+{
+	int ret;
+
+	printf("\tODP API version: %s\n", odp_version_api_str());
+	printf("\tODP implementation version: %s\n", odp_version_impl_str());
+
 	CU_basic_set_mode(CU_BRM_VERBOSE);
 	CU_basic_run_tests();
 
diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h
index 218146c..c689054 100644
--- a/test/validation/common/odp_cunit_common.h
+++ b/test/validation/common/odp_cunit_common.h
@@ -68,9 +68,16 @@  typedef struct {
 	int numthrds; /**< no of pthreads to create */
 } pthrd_arg;
 
+/* register suites to be run via odp_cunit_run() */
+int odp_cunit_register(odp_suiteinfo_t testsuites[]);
+/* update tests previously registered via odp_cunit_register() */
+int odp_cunit_update(odp_suiteinfo_t testsuites[]);
+/* the function, called by module main(), to run the testsuites: */
+int odp_cunit_run(void);
+
 /** 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 *);
+int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg);
+int odp_cunit_thread_exit(pthrd_arg *);
 
 /**
  * Global tests initialization/termination.
diff --git a/test/validation/cpumask/cpumask.c b/test/validation/cpumask/cpumask.c
index 37dee6a..bf5421e 100644
--- a/test/validation/cpumask/cpumask.c
+++ b/test/validation/cpumask/cpumask.c
@@ -101,5 +101,10 @@  odp_suiteinfo_t cpumask_suites[] = {
 
 int cpumask_main(void)
 {
-	return odp_cunit_run(cpumask_suites);
+	int ret = odp_cunit_register(cpumask_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/crypto/crypto.c b/test/validation/crypto/crypto.c
index b2f9d96..9229cab 100644
--- a/test/validation/crypto/crypto.c
+++ b/test/validation/crypto/crypto.c
@@ -94,7 +94,15 @@  int crypto_term(void)
 
 int crypto_main(void)
 {
+	int ret;
+
 	odp_cunit_register_global_init(crypto_init);
 	odp_cunit_register_global_term(crypto_term);
-	return odp_cunit_run(crypto_suites);
+
+	ret = odp_cunit_register(crypto_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/errno/errno.c b/test/validation/errno/errno.c
index 6196164..d0e2128 100644
--- a/test/validation/errno/errno.c
+++ b/test/validation/errno/errno.c
@@ -31,5 +31,10 @@  odp_suiteinfo_t errno_suites[] = {
 
 int errno_main(void)
 {
-	return odp_cunit_run(errno_suites);
+	int ret = odp_cunit_register(errno_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/init/init.c b/test/validation/init/init.c
index d5ec333..a8a5640 100644
--- a/test/validation/init/init.c
+++ b/test/validation/init/init.c
@@ -53,12 +53,19 @@  static void odp_init_abort(void)
 
 int init_main_abort(void)
 {
+	int ret;
+
 	/* prevent default ODP init: */
 	odp_cunit_register_global_init(NULL);
 	odp_cunit_register_global_term(NULL);
 
 	/* run the tests: */
-	return odp_cunit_run(init_suites_abort);
+	ret = odp_cunit_register(init_suites_abort);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
 
 /* test ODP global init, with alternate log function */
@@ -109,12 +116,20 @@  static int odp_init_log(odp_log_level_e level __attribute__((unused)),
 
 int init_main_log(void)
 {
+	int ret;
+
 	/* prevent default ODP init: */
 	odp_cunit_register_global_init(NULL);
 	odp_cunit_register_global_term(NULL);
 
+	/* register the tests: */
+	ret = odp_cunit_register(init_suites_log);
+
 	/* run the tests: */
-	return odp_cunit_run(init_suites_log);
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
 
 /* test normal ODP global init */
@@ -141,10 +156,18 @@  odp_suiteinfo_t init_suites_ok[] = {
 
 int init_main_ok(void)
 {
+	int ret;
+
 	/* prevent default ODP init: */
 	odp_cunit_register_global_init(NULL);
 	odp_cunit_register_global_term(NULL);
 
+	/* register the tests: */
+	ret = odp_cunit_register(init_suites_ok);
+
 	/* run the tests: */
-	return odp_cunit_run(init_suites_ok);
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c
index 8a4f0a6..d9a543f 100644
--- a/test/validation/packet/packet.c
+++ b/test/validation/packet/packet.c
@@ -805,5 +805,10 @@  odp_suiteinfo_t packet_suites[] = {
 
 int packet_main(void)
 {
-	return odp_cunit_run(packet_suites);
+	int ret = odp_cunit_register(packet_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index bfcaace..118fe89 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -908,5 +908,10 @@  odp_suiteinfo_t pktio_suites[] = {
 
 int pktio_main(void)
 {
-	return odp_cunit_run(pktio_suites);
+	int ret = odp_cunit_register(pktio_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/pool/pool.c b/test/validation/pool/pool.c
index 3de2714..bca210a 100644
--- a/test/validation/pool/pool.c
+++ b/test/validation/pool/pool.c
@@ -116,5 +116,10 @@  odp_suiteinfo_t pool_suites[] = {
 
 int pool_main(void)
 {
-	return odp_cunit_run(pool_suites);
+	int ret = odp_cunit_register(pool_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c
index 7d6de54..98da2ec 100644
--- a/test/validation/queue/queue.c
+++ b/test/validation/queue/queue.c
@@ -137,5 +137,10 @@  odp_suiteinfo_t queue_suites[] = {
 
 int queue_main(void)
 {
-	return odp_cunit_run(queue_suites);
+	int ret = odp_cunit_register(queue_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/random/random.c b/test/validation/random/random.c
index a9a5a01..8ed5944 100644
--- a/test/validation/random/random.c
+++ b/test/validation/random/random.c
@@ -29,5 +29,10 @@  odp_suiteinfo_t random_suites[] = {
 
 int random_main(void)
 {
-	return odp_cunit_run(random_suites);
+	int ret = odp_cunit_register(random_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c
index 81653c4..684dba5 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -1149,5 +1149,10 @@  odp_suiteinfo_t scheduler_suites[] = {
 
 int scheduler_main(void)
 {
-	return odp_cunit_run(scheduler_suites);
+	int ret = odp_cunit_register(scheduler_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c
index 41ec725..5524b5c 100644
--- a/test/validation/shmem/shmem.c
+++ b/test/validation/shmem/shmem.c
@@ -88,5 +88,10 @@  odp_suiteinfo_t shmem_suites[] = {
 
 int shmem_main(void)
 {
-	return odp_cunit_run(shmem_suites);
+	int ret = odp_cunit_register(shmem_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
index 595be74..96783fa 100644
--- a/test/validation/synchronizers/synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -1212,6 +1212,14 @@  odp_suiteinfo_t synchronizers_suites[] = {
 
 int synchronizers_main(void)
 {
+	int ret;
+
 	odp_cunit_register_global_init(synchronizers_init);
-	return odp_cunit_run(synchronizers_suites);
+
+	ret = odp_cunit_register(synchronizers_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/system/system.c b/test/validation/system/system.c
index cf0ab0a..7dc2cc0 100644
--- a/test/validation/system/system.c
+++ b/test/validation/system/system.c
@@ -101,5 +101,10 @@  odp_suiteinfo_t system_suites[] = {
 
 int system_main(void)
 {
-	return odp_cunit_run(system_suites);
+	int ret = odp_cunit_register(system_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/thread/thread.c b/test/validation/thread/thread.c
index b86ebd3..9ba8322 100644
--- a/test/validation/thread/thread.c
+++ b/test/validation/thread/thread.c
@@ -125,5 +125,10 @@  odp_suiteinfo_t thread_suites[] = {
 
 int thread_main(void)
 {
-	return odp_cunit_run(thread_suites);
+	int ret = odp_cunit_register(thread_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/time/time.c b/test/validation/time/time.c
index f2c196c..41db0e9 100644
--- a/test/validation/time/time.c
+++ b/test/validation/time/time.c
@@ -75,5 +75,10 @@  odp_suiteinfo_t time_suites[] = {
 
 int time_main(void)
 {
-	return odp_cunit_run(time_suites);
+	int ret = odp_cunit_register(time_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
index 02398f7..645dc58 100644
--- a/test/validation/timer/timer.c
+++ b/test/validation/timer/timer.c
@@ -544,5 +544,10 @@  odp_suiteinfo_t timer_suites[] = {
 
 int timer_main(void)
 {
-	return odp_cunit_run(timer_suites);
+	int ret = odp_cunit_register(timer_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }