Message ID | 1419906241-25267-1-git-send-email-mike.holmes@linaro.org |
---|---|
State | Superseded |
Headers | show |
On 12/30/2014 05:24 AM, Mike Holmes wrote: > + odp_cunit_thread_create(run_thread_id_core, &thrdarg); > + odp_cunit_thread_exit(&thrdarg); That looks like you test some cuinit functions. Might be test for real API is more appropriate here. Maxim.
On 30 December 2014 at 04:55, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > On 12/30/2014 05:24 AM, Mike Holmes wrote: > >> + odp_cunit_thread_create(run_thread_id_core, &thrdarg); >> + odp_cunit_thread_exit(&thrdarg); >> > That looks like you test some cuinit functions. Might be test for real API > is more appropriate here. > These ones were my focus because the core API has 0 coverage at this time. I was trying to keep it simple to just add the get id and get core apis but I could cut and paste the complete threads here. > > Maxim. > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
The docs only list those two APIs but I checked and I would end up cutting and pasting the odph code etc to not really test any more of the ODP API see http://docs.opendataplane.org/odp/html/group__odp__thread.html On 30 December 2014 at 07:07, Mike Holmes <mike.holmes@linaro.org> wrote: > > > On 30 December 2014 at 04:55, Maxim Uvarov <maxim.uvarov@linaro.org> > wrote: > >> On 12/30/2014 05:24 AM, Mike Holmes wrote: >> >>> + odp_cunit_thread_create(run_thread_id_core, &thrdarg); >>> + odp_cunit_thread_exit(&thrdarg); >>> >> That looks like you test some cuinit functions. Might be test for real >> API is more appropriate here. >> > > These ones were my focus because the core API has 0 coverage at this time. > I was trying to keep it simple to just add the get id and get core apis > but I could cut and paste the complete threads here. > > >> >> Maxim. >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> http://lists.linaro.org/mailman/listinfo/lng-odp >> > > > > -- > *Mike Holmes* > Linaro Sr Technical Manager > LNG - ODP >
On 12/30/2014 05:45 PM, Mike Holmes wrote: > The docs only list those two APIs but I checked and I would end up > cutting and pasting the odph code etc to not really test any more of > the ODP API > > see http://docs.opendataplane.org/odp/html/group__odp__thread.html > Ok, there are only 2 functions. I think it's ok to use helpers to test them. Maxim. > On 30 December 2014 at 07:07, Mike Holmes <mike.holmes@linaro.org > <mailto:mike.holmes@linaro.org>> wrote: > > > > On 30 December 2014 at 04:55, Maxim Uvarov > <maxim.uvarov@linaro.org <mailto:maxim.uvarov@linaro.org>> wrote: > > On 12/30/2014 05:24 AM, Mike Holmes wrote: > > + odp_cunit_thread_create(run_thread_id_core, &thrdarg); > + odp_cunit_thread_exit(&thrdarg); > > That looks like you test some cuinit functions. Might be test > for real API is more appropriate here. > > > These ones were my focus because the core API has 0 coverage at > this time. > I was trying to keep it simple to just add the get id and get > core apis but I could cut and paste the complete threads here. > > > Maxim. > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> > http://lists.linaro.org/mailman/listinfo/lng-odp > > > > > -- > *Mike Holmes* > Linaro Sr Technical Manager > LNG - ODP > > > > > -- > *Mike Holmes* > Linaro Sr Technical Manager > LNG - ODP
On 31 December 2014 at 01:33, Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote: > On Mon, Dec 29, 2014 at 09:24:01PM -0500, Mike Holmes wrote: > > Add tests for odp_thread_core and odp_thread_id > > > > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > > --- > > test/validation/.gitignore | 1 + > > test/validation/Makefile.am | 5 +++-- > > test/validation/odp_thread.c | 47 > ++++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 51 insertions(+), 2 deletions(-) > > create mode 100644 test/validation/odp_thread.c > > > > diff --git a/test/validation/.gitignore b/test/validation/.gitignore > > index d08db73..5b80834 100644 > > --- a/test/validation/.gitignore > > +++ b/test/validation/.gitignore > > @@ -8,3 +8,4 @@ odp_shm > > odp_system > > odp_pktio > > odp_buffer > > +odp_thread > > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > > index c0545b7..d52fbdb 100644 > > --- a/test/validation/Makefile.am > > +++ b/test/validation/Makefile.am > > @@ -6,9 +6,9 @@ AM_LDFLAGS += -static > > TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} > > > > if ODP_CUNIT_ENABLED > > -TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule > odp_pktio_run odp_buffer odp_system > > +TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule > odp_pktio_run odp_buffer odp_system odp_thread > > check_PROGRAMS = ${bin_PROGRAMS} > > -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule > odp_pktio odp_buffer odp_system > > +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule > odp_pktio odp_buffer odp_system odp_thread > > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > > odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer > > endif > > @@ -27,3 +27,4 @@ dist_odp_buffer_SOURCES = > buffer/odp_buffer_pool_test.c \ > > buffer/odp_packet_test.c \ > > odp_buffer.c common/odp_cunit_common.c > > dist_odp_system_SOURCES = odp_system.c common/odp_cunit_common.c > > +dist_odp_thread_SOURCES = odp_thread.c common/odp_cunit_common.c > > diff --git a/test/validation/odp_thread.c b/test/validation/odp_thread.c > > new file mode 100644 > > index 0000000..1c03b16 > > --- /dev/null > > +++ b/test/validation/odp_thread.c > > @@ -0,0 +1,47 @@ > > +/* Copyright (c) 2014, Linaro Limited > > + * All rights reserved. > > + * > > + * SPDX-License-Identifier: BSD-3-Clause > > + */ > > + > > +#include <odp.h> > > +#include <odp_cunit_common.h> > > + > > +static void *run_thread_id_core(void *arg) > > +{ > > + int thr, core; > > + pthrd_arg *thrdarg = arg; > > + > > + thr = odp_thread_id(); > > + core = odp_thread_core(); > > + > > + /* cores start from 0 */ > > + CU_ASSERT((core >= 0) && (core <= thrdarg->numthrds-1)); > > thrdarg is pointing to the stack(allocated in test_odp_thread_id_core()). > Use odp shared mem > to share the data between the cores or in this case, > odp_sys_core_count()/MAX_WORKERS can > be use here to find thrdarg->numthrds in run_thread_id_core() > > Will do > > + /* threads start from 1 */ > > + CU_ASSERT((thr >= 1) && (core <= thrdarg->numthrds)); > > Is there any specific reason why thread id has to be start from one(Why > not zero)? > Only because in this test the main thread will have run and so it will have taken 0 already. > > > + return arg; > > +} > > + > > +static void test_odp_thread_id_core(void) > > +{ > > + pthrd_arg thrdarg; > > + > > + thrdarg.numthrds = odp_sys_core_count(); > > + > > + if (thrdarg.numthrds > MAX_WORKERS) > > + thrdarg.numthrds = MAX_WORKERS; > > + > > + odp_cunit_thread_create(run_thread_id_core, &thrdarg); > > + odp_cunit_thread_exit(&thrdarg); > > +} > > + > > +CU_TestInfo test_odp_thread[] = { > > + {"id & core range", test_odp_thread_id_core}, > > + CU_TEST_INFO_NULL, > > +}; > > + > > +CU_SuiteInfo odp_testsuites[] = { > > + {"Thread", NULL, NULL, NULL, NULL, test_odp_thread}, > > + CU_SUITE_INFO_NULL, > > +}; > > + > > -- > > 2.1.0 > > > > > > _______________________________________________ > > lng-odp mailing list > > lng-odp@lists.linaro.org > > http://lists.linaro.org/mailman/listinfo/lng-odp >
On 2 January 2015 at 00:55, Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote: > On Wed, Dec 31, 2014 at 11:30:03AM -0500, Mike Holmes wrote: > > On 31 December 2014 at 01:33, Jerin Jacob < > jerin.jacob@caviumnetworks.com> > > wrote: > > > > > On Mon, Dec 29, 2014 at 09:24:01PM -0500, Mike Holmes wrote: > > > > Add tests for odp_thread_core and odp_thread_id > > > > > > > > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > > > > --- > > > > test/validation/.gitignore | 1 + > > > > test/validation/Makefile.am | 5 +++-- > > > > test/validation/odp_thread.c | 47 > > > ++++++++++++++++++++++++++++++++++++++++++++ > > > > 3 files changed, 51 insertions(+), 2 deletions(-) > > > > create mode 100644 test/validation/odp_thread.c > > > > > > > > diff --git a/test/validation/.gitignore b/test/validation/.gitignore > > > > index d08db73..5b80834 100644 > > > > --- a/test/validation/.gitignore > > > > +++ b/test/validation/.gitignore > > > > @@ -8,3 +8,4 @@ odp_shm > > > > odp_system > > > > odp_pktio > > > > odp_buffer > > > > +odp_thread > > > > diff --git a/test/validation/Makefile.am > b/test/validation/Makefile.am > > > > index c0545b7..d52fbdb 100644 > > > > --- a/test/validation/Makefile.am > > > > +++ b/test/validation/Makefile.am > > > > @@ -6,9 +6,9 @@ AM_LDFLAGS += -static > > > > TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} > > > > > > > > if ODP_CUNIT_ENABLED > > > > -TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule > > > odp_pktio_run odp_buffer odp_system > > > > +TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule > > > odp_pktio_run odp_buffer odp_system odp_thread > > > > check_PROGRAMS = ${bin_PROGRAMS} > > > > -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule > > > odp_pktio odp_buffer odp_system > > > > +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule > > > odp_pktio odp_buffer odp_system odp_thread > > > > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > > > > odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer > > > > endif > > > > @@ -27,3 +27,4 @@ dist_odp_buffer_SOURCES = > > > buffer/odp_buffer_pool_test.c \ > > > > buffer/odp_packet_test.c \ > > > > odp_buffer.c common/odp_cunit_common.c > > > > dist_odp_system_SOURCES = odp_system.c common/odp_cunit_common.c > > > > +dist_odp_thread_SOURCES = odp_thread.c common/odp_cunit_common.c > > > > diff --git a/test/validation/odp_thread.c > b/test/validation/odp_thread.c > > > > new file mode 100644 > > > > index 0000000..1c03b16 > > > > --- /dev/null > > > > +++ b/test/validation/odp_thread.c > > > > @@ -0,0 +1,47 @@ > > > > +/* Copyright (c) 2014, Linaro Limited > > > > + * All rights reserved. > > > > + * > > > > + * SPDX-License-Identifier: BSD-3-Clause > > > > + */ > > > > + > > > > +#include <odp.h> > > > > +#include <odp_cunit_common.h> > > > > + > > > > +static void *run_thread_id_core(void *arg) > > > > +{ > > > > + int thr, core; > > > > + pthrd_arg *thrdarg = arg; > > > > + > > > > + thr = odp_thread_id(); > > > > + core = odp_thread_core(); > > > > + > > > > + /* cores start from 0 */ > > > > + CU_ASSERT((core >= 0) && (core <= thrdarg->numthrds-1)); > > > > > > thrdarg is pointing to the stack(allocated in > test_odp_thread_id_core()). > > > Use odp shared mem > > > to share the data between the cores or in this case, > > > odp_sys_core_count()/MAX_WORKERS can > > > be use here to find thrdarg->numthrds in run_thread_id_core() > > > > > > > > Will do > > > > > > > > + /* threads start from 1 */ > > > > + CU_ASSERT((thr >= 1) && (core <= thrdarg->numthrds)); > > > > > > Is there any specific reason why thread id has to be start from one(Why > > > not zero)? > > > > > > > Only because in this test the main thread will have run and so it will > have > > taken 0 already. > > Its bit of odp platform implementation specific.Runtime environments like > baremetal may map > thread to core directly.so in that case, core 0(thread 0) can be executed > in > run_thread_id_core(). IMO, we need to change the assert to thr >= 0 > > No problem I am just looking for the loosest sunny day test because the API documentation specifies almost nothing, I will change that. > > > > > > > > > > > > + return arg; > > > > +} > > > > + > > > > +static void test_odp_thread_id_core(void) > > > > +{ > > > > + pthrd_arg thrdarg; > > > > + > > > > + thrdarg.numthrds = odp_sys_core_count(); > > > > + > > > > + if (thrdarg.numthrds > MAX_WORKERS) > > > > + thrdarg.numthrds = MAX_WORKERS; > > > > + > > > > + odp_cunit_thread_create(run_thread_id_core, &thrdarg); > > > > + odp_cunit_thread_exit(&thrdarg); > > > > +} > > > > + > > > > +CU_TestInfo test_odp_thread[] = { > > > > + {"id & core range", test_odp_thread_id_core}, > > > > + CU_TEST_INFO_NULL, > > > > +}; > > > > + > > > > +CU_SuiteInfo odp_testsuites[] = { > > > > + {"Thread", NULL, NULL, NULL, NULL, test_odp_thread}, > > > > + CU_SUITE_INFO_NULL, > > > > +}; > > > > + > > > > -- > > > > 2.1.0 > > > > > > > > > > > > _______________________________________________ > > > > lng-odp mailing list > > > > lng-odp@lists.linaro.org > > > > http://lists.linaro.org/mailman/listinfo/lng-odp > > > > > > > > > > > -- > > *Mike Holmes* > > Linaro Sr Technical Manager > > LNG - ODP >
diff --git a/test/validation/.gitignore b/test/validation/.gitignore index d08db73..5b80834 100644 --- a/test/validation/.gitignore +++ b/test/validation/.gitignore @@ -8,3 +8,4 @@ odp_shm odp_system odp_pktio odp_buffer +odp_thread diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index c0545b7..d52fbdb 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -6,9 +6,9 @@ AM_LDFLAGS += -static TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} if ODP_CUNIT_ENABLED -TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system +TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system odp_thread check_PROGRAMS = ${bin_PROGRAMS} -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_thread odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer endif @@ -27,3 +27,4 @@ dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \ buffer/odp_packet_test.c \ odp_buffer.c common/odp_cunit_common.c dist_odp_system_SOURCES = odp_system.c common/odp_cunit_common.c +dist_odp_thread_SOURCES = odp_thread.c common/odp_cunit_common.c diff --git a/test/validation/odp_thread.c b/test/validation/odp_thread.c new file mode 100644 index 0000000..1c03b16 --- /dev/null +++ b/test/validation/odp_thread.c @@ -0,0 +1,47 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <odp.h> +#include <odp_cunit_common.h> + +static void *run_thread_id_core(void *arg) +{ + int thr, core; + pthrd_arg *thrdarg = arg; + + thr = odp_thread_id(); + core = odp_thread_core(); + + /* cores start from 0 */ + CU_ASSERT((core >= 0) && (core <= thrdarg->numthrds-1)); + /* threads start from 1 */ + CU_ASSERT((thr >= 1) && (core <= thrdarg->numthrds)); + return arg; +} + +static void test_odp_thread_id_core(void) +{ + pthrd_arg thrdarg; + + thrdarg.numthrds = odp_sys_core_count(); + + if (thrdarg.numthrds > MAX_WORKERS) + thrdarg.numthrds = MAX_WORKERS; + + odp_cunit_thread_create(run_thread_id_core, &thrdarg); + odp_cunit_thread_exit(&thrdarg); +} + +CU_TestInfo test_odp_thread[] = { + {"id & core range", test_odp_thread_id_core}, + CU_TEST_INFO_NULL, +}; + +CU_SuiteInfo odp_testsuites[] = { + {"Thread", NULL, NULL, NULL, NULL, test_odp_thread}, + CU_SUITE_INFO_NULL, +}; +
Add tests for odp_thread_core and odp_thread_id Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- test/validation/.gitignore | 1 + test/validation/Makefile.am | 5 +++-- test/validation/odp_thread.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 test/validation/odp_thread.c