Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
On Wed, Dec 17, 2014 at 11:05:52AM +0100, Ola Liljedahl wrote: > On 17 December 2014 at 10:19, Jerin Jacob > wrote: > > On Wed, Dec 17, 2014 at 09:28:48AM +0530, Jerin Jacob wrote: > >> On Mon, Dec 08, 2014 at 11:49:46PM +0100, Ola Liljedahl wrote: > >> > Signed-off-by: Ola Liljedahl > >> > --- > >> > (This document/code contribution attached is provided under the terms of > >> > agreement LES-LTM-21309) > >> > A new cunit test program test/validation/odp_timer.c for the updated > >> > timer API. > >> > > >> > test/validation/.gitignore | 1 + > >> > test/validation/Makefile.am | 4 +- > >> > test/validation/odp_timer.c | 336 > >> > > >> > 3 files changed, 340 insertions(+), 1 deletion(-) > >> > create mode 100644 test/validation/odp_timer.c > >> > > >> > diff --git a/test/validation/.gitignore b/test/validation/.gitignore > >> > index 37e2594..586def0 100644 > >> > --- a/test/validation/.gitignore > >> > +++ b/test/validation/.gitignore > >> > @@ -4,3 +4,4 @@ odp_init > >> > odp_queue > >> > odp_crypto > >> > odp_shm > >> > +odp_timer > >> > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > >> > index 8547085..043bf4c 100644 > >> > --- a/test/validation/Makefile.am > >> > +++ b/test/validation/Makefile.am > >> > @@ -6,13 +6,14 @@ AM_LDFLAGS += -static > >> > if ODP_CUNIT_ENABLED > >> > TESTS = ${bin_PROGRAMS} > >> > check_PROGRAMS = ${bin_PROGRAMS} > >> > -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm > >> > +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_timer > >> > odp_init_LDFLAGS = $(AM_LDFLAGS) > >> > odp_queue_LDFLAGS = $(AM_LDFLAGS) > >> > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > >> > odp_crypto_LDFLAGS = $(AM_LDFLAGS) > >> > odp_shm_CFLAGS = $(AM_CFLAGS) > >> > odp_shm_LDFLAGS = $(AM_LDFLAGS) > >> > +odp_timer_LDFLAGS = $(AM_LDFLAGS) > >> > endif > >> > > >> > dist_odp_init_SOURCES = odp_init.c > >> > @@ -22,3 +23,4 @@ dist_odp_crypto_SOURCES = > >> > crypto/odp_crypto_test_async_inp.c \ > >> > crypto/odp_crypto_test_rng.c \ > >> > odp_crypto.c common/odp_cunit_common.c > >> > dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c > >> > +dist_odp_timer_SOURCES = odp_timer.c common/odp_cunit_common.c > >> > diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c > >> > new file mode 100644 > >> > index 000..4b6b872 > >> > --- /dev/null > >> > +++ b/test/validation/odp_timer.c > >> > @@ -0,0 +1,336 @@ > >> > +/* Copyright (c) 2014, Linaro Limited > >> > + * All rights reserved. > >> > + * > >> > + * SPDX-License-Identifier: BSD-3-Clause > >> > + */ > >> > + > >> > +/** > >> > + * @file > >> > + */ > >> > + > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > +#include "odp_cunit_common.h" > >> > + > >> > +/** @private Timeout range in milliseconds (ms) */ > >> > +#define RANGE_MS 2000 > >> > + > >> > +/** @private Number of timers per thread */ > >> > +#define NTIMERS 2000 > >> > + > >> > +/** @private Timeout pool size per thread */ > >> > +#define TMO_POOL_SIZE (512 * NTIMERS) > >> > + > >> > +/** @private Barrier for thread synchronisation */ > >> > +static odp_barrier_t test_barrier; > >> > + > >> > +/** @private Timeout buffer pool handle used by all threads */ > >> > +static odp_buffer_pool_t tbp; > >> > + > >> > +/** @private Timer pool handle used by all threads */ > >> > +static odp_timer_pool_t tp; > >> > + > >> > +/** @private min() function */ > >> > +static int min(int a, int b) > >> > +{ > >> > + return a < b ? a : b; > >> > +} > >> > + > >> > +/* @private Timer helper structure */ > >> > +struct test_timer { > >> > + odp_timer_t tim; /* Timer handle */ > >> > + odp_buffer_t buf; /* Timeout buffer */ > >> > + odp_buffer_t buf2; /* Copy of buffer handle */ > >> > + uint64_t tick; /* Expiration tick or ODP_TICK_INVALID */ > >> > +}; > >> > + > >> > +/* @private Handle a received (timeout) buffer */ > >> > +static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) > >> > +{ > >> > + odp_timer_t tim = ODP_TIMER_INVALID; > >> > + uint64_t tick = ODP_TICK_INVALID; > >> > + struct test_timer *ttp = NULL; > >> > + > >> > + /* Use assert() for correctness check of test program itself */ > >> > + assert(buf != ODP_BUFFER_INVALID); > >> > + if (!odp_timer_tmo_metadata(buf, &tim, &tick, (void **)&ttp)) { > >> > + /* Not a default timeout buffer */ > >> > + CU_FAIL("Unexpected buffer type received"); > >> > + return; > >> > + } > >> > + > >> > + if (tim == ODP_TIMER_INVALID) > >> > + CU_FAIL("odp_timer_tmo_metadata() invalid timer"); > >> > + if (tick == ODP_TICK_INVALID) > >> > + CU_FAIL("odp_timer_tmo_metadata() invalid tick"); > >> > + if (ttp == NULL) > >> > + CU_FAIL("odp_timer_tmo_metadata() null user ptr"); > >> > + > >> > +
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
On 17 December 2014 at 10:19, Jerin Jacob wrote: > On Wed, Dec 17, 2014 at 09:28:48AM +0530, Jerin Jacob wrote: >> On Mon, Dec 08, 2014 at 11:49:46PM +0100, Ola Liljedahl wrote: >> > Signed-off-by: Ola Liljedahl >> > --- >> > (This document/code contribution attached is provided under the terms of >> > agreement LES-LTM-21309) >> > A new cunit test program test/validation/odp_timer.c for the updated timer >> > API. >> > >> > test/validation/.gitignore | 1 + >> > test/validation/Makefile.am | 4 +- >> > test/validation/odp_timer.c | 336 >> > >> > 3 files changed, 340 insertions(+), 1 deletion(-) >> > create mode 100644 test/validation/odp_timer.c >> > >> > diff --git a/test/validation/.gitignore b/test/validation/.gitignore >> > index 37e2594..586def0 100644 >> > --- a/test/validation/.gitignore >> > +++ b/test/validation/.gitignore >> > @@ -4,3 +4,4 @@ odp_init >> > odp_queue >> > odp_crypto >> > odp_shm >> > +odp_timer >> > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am >> > index 8547085..043bf4c 100644 >> > --- a/test/validation/Makefile.am >> > +++ b/test/validation/Makefile.am >> > @@ -6,13 +6,14 @@ AM_LDFLAGS += -static >> > if ODP_CUNIT_ENABLED >> > TESTS = ${bin_PROGRAMS} >> > check_PROGRAMS = ${bin_PROGRAMS} >> > -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm >> > +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_timer >> > odp_init_LDFLAGS = $(AM_LDFLAGS) >> > odp_queue_LDFLAGS = $(AM_LDFLAGS) >> > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto >> > odp_crypto_LDFLAGS = $(AM_LDFLAGS) >> > odp_shm_CFLAGS = $(AM_CFLAGS) >> > odp_shm_LDFLAGS = $(AM_LDFLAGS) >> > +odp_timer_LDFLAGS = $(AM_LDFLAGS) >> > endif >> > >> > dist_odp_init_SOURCES = odp_init.c >> > @@ -22,3 +23,4 @@ dist_odp_crypto_SOURCES = >> > crypto/odp_crypto_test_async_inp.c \ >> > crypto/odp_crypto_test_rng.c \ >> > odp_crypto.c common/odp_cunit_common.c >> > dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c >> > +dist_odp_timer_SOURCES = odp_timer.c common/odp_cunit_common.c >> > diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c >> > new file mode 100644 >> > index 000..4b6b872 >> > --- /dev/null >> > +++ b/test/validation/odp_timer.c >> > @@ -0,0 +1,336 @@ >> > +/* Copyright (c) 2014, Linaro Limited >> > + * All rights reserved. >> > + * >> > + * SPDX-License-Identifier: BSD-3-Clause >> > + */ >> > + >> > +/** >> > + * @file >> > + */ >> > + >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include >> > +#include "odp_cunit_common.h" >> > + >> > +/** @private Timeout range in milliseconds (ms) */ >> > +#define RANGE_MS 2000 >> > + >> > +/** @private Number of timers per thread */ >> > +#define NTIMERS 2000 >> > + >> > +/** @private Timeout pool size per thread */ >> > +#define TMO_POOL_SIZE (512 * NTIMERS) >> > + >> > +/** @private Barrier for thread synchronisation */ >> > +static odp_barrier_t test_barrier; >> > + >> > +/** @private Timeout buffer pool handle used by all threads */ >> > +static odp_buffer_pool_t tbp; >> > + >> > +/** @private Timer pool handle used by all threads */ >> > +static odp_timer_pool_t tp; >> > + >> > +/** @private min() function */ >> > +static int min(int a, int b) >> > +{ >> > + return a < b ? a : b; >> > +} >> > + >> > +/* @private Timer helper structure */ >> > +struct test_timer { >> > + odp_timer_t tim; /* Timer handle */ >> > + odp_buffer_t buf; /* Timeout buffer */ >> > + odp_buffer_t buf2; /* Copy of buffer handle */ >> > + uint64_t tick; /* Expiration tick or ODP_TICK_INVALID */ >> > +}; >> > + >> > +/* @private Handle a received (timeout) buffer */ >> > +static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) >> > +{ >> > + odp_timer_t tim = ODP_TIMER_INVALID; >> > + uint64_t tick = ODP_TICK_INVALID; >> > + struct test_timer *ttp = NULL; >> > + >> > + /* Use assert() for correctness check of test program itself */ >> > + assert(buf != ODP_BUFFER_INVALID); >> > + if (!odp_timer_tmo_metadata(buf, &tim, &tick, (void **)&ttp)) { >> > + /* Not a default timeout buffer */ >> > + CU_FAIL("Unexpected buffer type received"); >> > + return; >> > + } >> > + >> > + if (tim == ODP_TIMER_INVALID) >> > + CU_FAIL("odp_timer_tmo_metadata() invalid timer"); >> > + if (tick == ODP_TICK_INVALID) >> > + CU_FAIL("odp_timer_tmo_metadata() invalid tick"); >> > + if (ttp == NULL) >> > + CU_FAIL("odp_timer_tmo_metadata() null user ptr"); >> > + >> > + if (ttp->buf2 != buf) >> > + CU_FAIL("odp_timer_tmo_metadata() wrong user ptr"); >> > + if (ttp->tim != tim) >> > + CU_FAIL("odp_timer_tmo_metadata() wrong timer"); >> > + if (stale) { >> > + /* Stale timeout => timer must have invalid tick */ >> > + if (ttp->tick != ODP_TICK_INVALI
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
On Wed, Dec 17, 2014 at 09:28:48AM +0530, Jerin Jacob wrote: > On Mon, Dec 08, 2014 at 11:49:46PM +0100, Ola Liljedahl wrote: > > Signed-off-by: Ola Liljedahl > > --- > > (This document/code contribution attached is provided under the terms of > > agreement LES-LTM-21309) > > A new cunit test program test/validation/odp_timer.c for the updated timer > > API. > > > > test/validation/.gitignore | 1 + > > test/validation/Makefile.am | 4 +- > > test/validation/odp_timer.c | 336 > > > > 3 files changed, 340 insertions(+), 1 deletion(-) > > create mode 100644 test/validation/odp_timer.c > > > > diff --git a/test/validation/.gitignore b/test/validation/.gitignore > > index 37e2594..586def0 100644 > > --- a/test/validation/.gitignore > > +++ b/test/validation/.gitignore > > @@ -4,3 +4,4 @@ odp_init > > odp_queue > > odp_crypto > > odp_shm > > +odp_timer > > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > > index 8547085..043bf4c 100644 > > --- a/test/validation/Makefile.am > > +++ b/test/validation/Makefile.am > > @@ -6,13 +6,14 @@ AM_LDFLAGS += -static > > if ODP_CUNIT_ENABLED > > TESTS = ${bin_PROGRAMS} > > check_PROGRAMS = ${bin_PROGRAMS} > > -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm > > +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_timer > > odp_init_LDFLAGS = $(AM_LDFLAGS) > > odp_queue_LDFLAGS = $(AM_LDFLAGS) > > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > > odp_crypto_LDFLAGS = $(AM_LDFLAGS) > > odp_shm_CFLAGS = $(AM_CFLAGS) > > odp_shm_LDFLAGS = $(AM_LDFLAGS) > > +odp_timer_LDFLAGS = $(AM_LDFLAGS) > > endif > > > > dist_odp_init_SOURCES = odp_init.c > > @@ -22,3 +23,4 @@ dist_odp_crypto_SOURCES = > > crypto/odp_crypto_test_async_inp.c \ > > crypto/odp_crypto_test_rng.c \ > > odp_crypto.c common/odp_cunit_common.c > > dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c > > +dist_odp_timer_SOURCES = odp_timer.c common/odp_cunit_common.c > > diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c > > new file mode 100644 > > index 000..4b6b872 > > --- /dev/null > > +++ b/test/validation/odp_timer.c > > @@ -0,0 +1,336 @@ > > +/* Copyright (c) 2014, Linaro Limited > > + * All rights reserved. > > + * > > + * SPDX-License-Identifier: BSD-3-Clause > > + */ > > + > > +/** > > + * @file > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "odp_cunit_common.h" > > + > > +/** @private Timeout range in milliseconds (ms) */ > > +#define RANGE_MS 2000 > > + > > +/** @private Number of timers per thread */ > > +#define NTIMERS 2000 > > + > > +/** @private Timeout pool size per thread */ > > +#define TMO_POOL_SIZE (512 * NTIMERS) > > + > > +/** @private Barrier for thread synchronisation */ > > +static odp_barrier_t test_barrier; > > + > > +/** @private Timeout buffer pool handle used by all threads */ > > +static odp_buffer_pool_t tbp; > > + > > +/** @private Timer pool handle used by all threads */ > > +static odp_timer_pool_t tp; > > + > > +/** @private min() function */ > > +static int min(int a, int b) > > +{ > > + return a < b ? a : b; > > +} > > + > > +/* @private Timer helper structure */ > > +struct test_timer { > > + odp_timer_t tim; /* Timer handle */ > > + odp_buffer_t buf; /* Timeout buffer */ > > + odp_buffer_t buf2; /* Copy of buffer handle */ > > + uint64_t tick; /* Expiration tick or ODP_TICK_INVALID */ > > +}; > > + > > +/* @private Handle a received (timeout) buffer */ > > +static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) > > +{ > > + odp_timer_t tim = ODP_TIMER_INVALID; > > + uint64_t tick = ODP_TICK_INVALID; > > + struct test_timer *ttp = NULL; > > + > > + /* Use assert() for correctness check of test program itself */ > > + assert(buf != ODP_BUFFER_INVALID); > > + if (!odp_timer_tmo_metadata(buf, &tim, &tick, (void **)&ttp)) { > > + /* Not a default timeout buffer */ > > + CU_FAIL("Unexpected buffer type received"); > > + return; > > + } > > + > > + if (tim == ODP_TIMER_INVALID) > > + CU_FAIL("odp_timer_tmo_metadata() invalid timer"); > > + if (tick == ODP_TICK_INVALID) > > + CU_FAIL("odp_timer_tmo_metadata() invalid tick"); > > + if (ttp == NULL) > > + CU_FAIL("odp_timer_tmo_metadata() null user ptr"); > > + > > + if (ttp->buf2 != buf) > > + CU_FAIL("odp_timer_tmo_metadata() wrong user ptr"); > > + if (ttp->tim != tim) > > + CU_FAIL("odp_timer_tmo_metadata() wrong timer"); > > + if (stale) { > > + /* Stale timeout => timer must have invalid tick */ > > + if (ttp->tick != ODP_TICK_INVALID) > > + CU_FAIL("Stale timeout for active timer"); > > + } else { > > + /* Fresh timeout => timer must have matching tick */ > > + if (ttp->ti
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
On Mon, Dec 08, 2014 at 11:49:46PM +0100, Ola Liljedahl wrote: > Signed-off-by: Ola Liljedahl > --- > (This document/code contribution attached is provided under the terms of > agreement LES-LTM-21309) > A new cunit test program test/validation/odp_timer.c for the updated timer > API. > > test/validation/.gitignore | 1 + > test/validation/Makefile.am | 4 +- > test/validation/odp_timer.c | 336 > > 3 files changed, 340 insertions(+), 1 deletion(-) > create mode 100644 test/validation/odp_timer.c > > diff --git a/test/validation/.gitignore b/test/validation/.gitignore > index 37e2594..586def0 100644 > --- a/test/validation/.gitignore > +++ b/test/validation/.gitignore > @@ -4,3 +4,4 @@ odp_init > odp_queue > odp_crypto > odp_shm > +odp_timer > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > index 8547085..043bf4c 100644 > --- a/test/validation/Makefile.am > +++ b/test/validation/Makefile.am > @@ -6,13 +6,14 @@ AM_LDFLAGS += -static > if ODP_CUNIT_ENABLED > TESTS = ${bin_PROGRAMS} > check_PROGRAMS = ${bin_PROGRAMS} > -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm > +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_timer > odp_init_LDFLAGS = $(AM_LDFLAGS) > odp_queue_LDFLAGS = $(AM_LDFLAGS) > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > odp_crypto_LDFLAGS = $(AM_LDFLAGS) > odp_shm_CFLAGS = $(AM_CFLAGS) > odp_shm_LDFLAGS = $(AM_LDFLAGS) > +odp_timer_LDFLAGS = $(AM_LDFLAGS) > endif > > dist_odp_init_SOURCES = odp_init.c > @@ -22,3 +23,4 @@ dist_odp_crypto_SOURCES = > crypto/odp_crypto_test_async_inp.c \ > crypto/odp_crypto_test_rng.c \ > odp_crypto.c common/odp_cunit_common.c > dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c > +dist_odp_timer_SOURCES = odp_timer.c common/odp_cunit_common.c > diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c > new file mode 100644 > index 000..4b6b872 > --- /dev/null > +++ b/test/validation/odp_timer.c > @@ -0,0 +1,336 @@ > +/* Copyright (c) 2014, Linaro Limited > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +/** > + * @file > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include "odp_cunit_common.h" > + > +/** @private Timeout range in milliseconds (ms) */ > +#define RANGE_MS 2000 > + > +/** @private Number of timers per thread */ > +#define NTIMERS 2000 > + > +/** @private Timeout pool size per thread */ > +#define TMO_POOL_SIZE(512 * NTIMERS) > + > +/** @private Barrier for thread synchronisation */ > +static odp_barrier_t test_barrier; > + > +/** @private Timeout buffer pool handle used by all threads */ > +static odp_buffer_pool_t tbp; > + > +/** @private Timer pool handle used by all threads */ > +static odp_timer_pool_t tp; > + > +/** @private min() function */ > +static int min(int a, int b) > +{ > + return a < b ? a : b; > +} > + > +/* @private Timer helper structure */ > +struct test_timer { > + odp_timer_t tim; /* Timer handle */ > + odp_buffer_t buf; /* Timeout buffer */ > + odp_buffer_t buf2; /* Copy of buffer handle */ > + uint64_t tick; /* Expiration tick or ODP_TICK_INVALID */ > +}; > + > +/* @private Handle a received (timeout) buffer */ > +static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) > +{ > + odp_timer_t tim = ODP_TIMER_INVALID; > + uint64_t tick = ODP_TICK_INVALID; > + struct test_timer *ttp = NULL; > + > + /* Use assert() for correctness check of test program itself */ > + assert(buf != ODP_BUFFER_INVALID); > + if (!odp_timer_tmo_metadata(buf, &tim, &tick, (void **)&ttp)) { > + /* Not a default timeout buffer */ > + CU_FAIL("Unexpected buffer type received"); > + return; > + } > + > + if (tim == ODP_TIMER_INVALID) > + CU_FAIL("odp_timer_tmo_metadata() invalid timer"); > + if (tick == ODP_TICK_INVALID) > + CU_FAIL("odp_timer_tmo_metadata() invalid tick"); > + if (ttp == NULL) > + CU_FAIL("odp_timer_tmo_metadata() null user ptr"); > + > + if (ttp->buf2 != buf) > + CU_FAIL("odp_timer_tmo_metadata() wrong user ptr"); > + if (ttp->tim != tim) > + CU_FAIL("odp_timer_tmo_metadata() wrong timer"); > + if (stale) { > + /* Stale timeout => timer must have invalid tick */ > + if (ttp->tick != ODP_TICK_INVALID) > + CU_FAIL("Stale timeout for active timer"); > + } else { > + /* Fresh timeout => timer must have matching tick */ > + if (ttp->tick != tick) > + CU_FAIL("odp_timer_tmo_metadata() wrong tick"); > + /* Check that timeout was delivered 'timely' */ > + if (tick > odp_timer_current_tick(tp)) > + CU_FAIL("Timeout delivered too early"); >
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
Earlier the debates were pure philosophy. We now have a substantial body of code and that "sleek and stylish" 80-char straightjacket is a lot less comfortable for daily wear than it may have looked "on the rack" before we bought it. Even a bump to 85 would be a welcome relief. 100 or 132 would be equally arbitrary and I'd have no problem with removing the limit altogether and simply relying on the consensus of reviewers as to when lines are "too long". The point is that there's no real justification for keeping 80 other than "well, Linux does it that way". But ODP is not Linux and we've already abandoned Linux''s ban on typedefs so obviously we're not constrained by what Linux does. Bill On Wed, Dec 10, 2014 at 11:19 AM, Ola Liljedahl wrote: > VT100 forever! > However 132 chars per line was supported even back then. I guess only > PC text consoles are limited to 80 chars. > > > On 10 December 2014 at 17:58, Bill Fischofer > wrote: > > Rather than having a list of "privileged" code that gets special > exceptions, > > why not just increase the checkpatch line length limit beyond the > arbitrary > > 80-char limit? We're not coding on punch cards any more. :) > > > > Raising the limit to say 100 chars would eliminate the vast majority of > > these spurious issues. I know I've had to torture the buffer code in > > several places to comply with this procrustean "standard". > > > > Bill > > > > On Wed, Dec 10, 2014 at 10:33 AM, Mike Holmes > > wrote: > >> > >> Agreed, this is one of the exceptions. > >> > >> On 10 December 2014 at 04:22, Ola Liljedahl > >> wrote: > >>> > >>> On 10 December 2014 at 09:13, Anders Roxell > >>> wrote: > >>> > On 2014-12-09 17:56, Mike Holmes wrote: > >>> >> Has checkpatch issues > >>> >> > >>> >> Using patch: > >>> >> > /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox > >>> >> git am > >>> >> > /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox > >>> >> Patch applied, building... > >>> >> WARNING: line over 80 characters > >>> >> #238: FILE: test/validation/odp_timer.c:185: > >>> >> + CU_FAIL("Failed to set timer (tooearly/toolate)"); > >>> >> > >>> >> total: 0 errors, 1 warnings, 0 checks, 359 lines checked > >>> >> > >>> >> NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS > >>> >> > >>> >> 0001-test-odp_timer.h-cunit-test.patch has style problems, please > >>> >> review. > >>> > > >>> > Do we want to split up this printout? > >>> No. > >>> > >>> > If you're not familiar with the code and you run the validation tests > >>> > and got this failure printed out. I would grep for that failure > message > >>> > (the string) in the code too see how I got there. > >>> Exactly. > >>> > >>> > And if we split this string up into multiple rows just to make > >>> > check-patch happy it will make it harder to search after the failure > >>> > message then right? > >>> Correct. > >>> And I even think checkpatch for this reason will complain if you split > >>> the string. > >>> > >>> -- Ola > >>> > >>> > > >>> > Cheers, > >>> > Anders > >> > >> > >> > >> > >> -- > >> Mike Holmes > >> Linaro Sr Technical Manager > >> LNG - ODP > >> > >> ___ > >> 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
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
VT100 forever! However 132 chars per line was supported even back then. I guess only PC text consoles are limited to 80 chars. On 10 December 2014 at 17:58, Bill Fischofer wrote: > Rather than having a list of "privileged" code that gets special exceptions, > why not just increase the checkpatch line length limit beyond the arbitrary > 80-char limit? We're not coding on punch cards any more. :) > > Raising the limit to say 100 chars would eliminate the vast majority of > these spurious issues. I know I've had to torture the buffer code in > several places to comply with this procrustean "standard". > > Bill > > On Wed, Dec 10, 2014 at 10:33 AM, Mike Holmes > wrote: >> >> Agreed, this is one of the exceptions. >> >> On 10 December 2014 at 04:22, Ola Liljedahl >> wrote: >>> >>> On 10 December 2014 at 09:13, Anders Roxell >>> wrote: >>> > On 2014-12-09 17:56, Mike Holmes wrote: >>> >> Has checkpatch issues >>> >> >>> >> Using patch: >>> >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >>> >> git am >>> >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >>> >> Patch applied, building... >>> >> WARNING: line over 80 characters >>> >> #238: FILE: test/validation/odp_timer.c:185: >>> >> + CU_FAIL("Failed to set timer (tooearly/toolate)"); >>> >> >>> >> total: 0 errors, 1 warnings, 0 checks, 359 lines checked >>> >> >>> >> NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS >>> >> >>> >> 0001-test-odp_timer.h-cunit-test.patch has style problems, please >>> >> review. >>> > >>> > Do we want to split up this printout? >>> No. >>> >>> > If you're not familiar with the code and you run the validation tests >>> > and got this failure printed out. I would grep for that failure message >>> > (the string) in the code too see how I got there. >>> Exactly. >>> >>> > And if we split this string up into multiple rows just to make >>> > check-patch happy it will make it harder to search after the failure >>> > message then right? >>> Correct. >>> And I even think checkpatch for this reason will complain if you split >>> the string. >>> >>> -- Ola >>> >>> > >>> > Cheers, >>> > Anders >> >> >> >> >> -- >> Mike Holmes >> Linaro Sr Technical Manager >> LNG - ODP >> >> ___ >> 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
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
On 10 December 2014 at 11:58, Bill Fischofer wrote: > Rather than having a list of "privileged" code that gets special > exceptions, > I don't think it is privileged, but as checkpatch docs say, if you have a good case for ignoring a guideline in a given case - ok > why not just increase the checkpatch line length limit beyond the > arbitrary 80-char limit? > We can start that thread again but it went in huge loops last time with no agreement between large camps on suggestions between 120 or 80 chars > We're not coding on punch cards any more. :) > That was the argument form the 120 crowd :) > > Raising the limit to say 100 chars would eliminate the vast majority of > these spurious issues. I know I've had to torture the buffer code in > several places to comply with this procrustean "standard". > If we get a quorum - why not change it, I have no issue. > > Bill > > On Wed, Dec 10, 2014 at 10:33 AM, Mike Holmes > wrote: > >> Agreed, this is one of the exceptions. >> >> On 10 December 2014 at 04:22, Ola Liljedahl >> wrote: >> >>> On 10 December 2014 at 09:13, Anders Roxell >>> wrote: >>> > On 2014-12-09 17:56, Mike Holmes wrote: >>> >> Has checkpatch issues >>> >> >>> >> Using patch: >>> >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >>> >> git am >>> >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >>> >> Patch applied, building... >>> >> WARNING: line over 80 characters >>> >> #238: FILE: test/validation/odp_timer.c:185: >>> >> + CU_FAIL("Failed to set timer (tooearly/toolate)"); >>> >> >>> >> total: 0 errors, 1 warnings, 0 checks, 359 lines checked >>> >> >>> >> NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS >>> >> >>> >> 0001-test-odp_timer.h-cunit-test.patch has style problems, please >>> review. >>> > >>> > Do we want to split up this printout? >>> No. >>> >>> > If you're not familiar with the code and you run the validation tests >>> > and got this failure printed out. I would grep for that failure message >>> > (the string) in the code too see how I got there. >>> Exactly. >>> >>> > And if we split this string up into multiple rows just to make >>> > check-patch happy it will make it harder to search after the failure >>> > message then right? >>> Correct. >>> And I even think checkpatch for this reason will complain if you split >>> the string. >>> >>> -- Ola >>> >>> > >>> > Cheers, >>> > Anders >>> >> >> >> >> -- >> *Mike Holmes* >> Linaro Sr Technical Manager >> LNG - ODP >> >> ___ >> 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 ___ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
On 10 December 2014 at 17:33, Mike Holmes wrote: > Agreed, this is one of the exceptions. It should be possible to fix checkpatch so that it does not warn for too long lines when that line is a string constant. I could remove some of the indentation but I assume checkpatch would complain on that intstead. > > On 10 December 2014 at 04:22, Ola Liljedahl > wrote: >> >> On 10 December 2014 at 09:13, Anders Roxell >> wrote: >> > On 2014-12-09 17:56, Mike Holmes wrote: >> >> Has checkpatch issues >> >> >> >> Using patch: >> >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >> >> git am >> >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >> >> Patch applied, building... >> >> WARNING: line over 80 characters >> >> #238: FILE: test/validation/odp_timer.c:185: >> >> + CU_FAIL("Failed to set timer (tooearly/toolate)"); >> >> >> >> total: 0 errors, 1 warnings, 0 checks, 359 lines checked >> >> >> >> NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS >> >> >> >> 0001-test-odp_timer.h-cunit-test.patch has style problems, please >> >> review. >> > >> > Do we want to split up this printout? >> No. >> >> > If you're not familiar with the code and you run the validation tests >> > and got this failure printed out. I would grep for that failure message >> > (the string) in the code too see how I got there. >> Exactly. >> >> > And if we split this string up into multiple rows just to make >> > check-patch happy it will make it harder to search after the failure >> > message then right? >> Correct. >> And I even think checkpatch for this reason will complain if you split >> the string. >> >> -- Ola >> >> > >> > Cheers, >> > Anders > > > > > -- > Mike Holmes > Linaro Sr Technical Manager > LNG - ODP ___ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
Rather than having a list of "privileged" code that gets special exceptions, why not just increase the checkpatch line length limit beyond the arbitrary 80-char limit? We're not coding on punch cards any more. :) Raising the limit to say 100 chars would eliminate the vast majority of these spurious issues. I know I've had to torture the buffer code in several places to comply with this procrustean "standard". Bill On Wed, Dec 10, 2014 at 10:33 AM, Mike Holmes wrote: > Agreed, this is one of the exceptions. > > On 10 December 2014 at 04:22, Ola Liljedahl > wrote: > >> On 10 December 2014 at 09:13, Anders Roxell >> wrote: >> > On 2014-12-09 17:56, Mike Holmes wrote: >> >> Has checkpatch issues >> >> >> >> Using patch: >> >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >> >> git am >> >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >> >> Patch applied, building... >> >> WARNING: line over 80 characters >> >> #238: FILE: test/validation/odp_timer.c:185: >> >> + CU_FAIL("Failed to set timer (tooearly/toolate)"); >> >> >> >> total: 0 errors, 1 warnings, 0 checks, 359 lines checked >> >> >> >> NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS >> >> >> >> 0001-test-odp_timer.h-cunit-test.patch has style problems, please >> review. >> > >> > Do we want to split up this printout? >> No. >> >> > If you're not familiar with the code and you run the validation tests >> > and got this failure printed out. I would grep for that failure message >> > (the string) in the code too see how I got there. >> Exactly. >> >> > And if we split this string up into multiple rows just to make >> > check-patch happy it will make it harder to search after the failure >> > message then right? >> Correct. >> And I even think checkpatch for this reason will complain if you split >> the string. >> >> -- Ola >> >> > >> > Cheers, >> > Anders >> > > > > -- > *Mike Holmes* > Linaro Sr Technical Manager > LNG - ODP > > ___ > 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
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
Agreed, this is one of the exceptions. On 10 December 2014 at 04:22, Ola Liljedahl wrote: > On 10 December 2014 at 09:13, Anders Roxell > wrote: > > On 2014-12-09 17:56, Mike Holmes wrote: > >> Has checkpatch issues > >> > >> Using patch: > >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox > >> git am > >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox > >> Patch applied, building... > >> WARNING: line over 80 characters > >> #238: FILE: test/validation/odp_timer.c:185: > >> + CU_FAIL("Failed to set timer (tooearly/toolate)"); > >> > >> total: 0 errors, 1 warnings, 0 checks, 359 lines checked > >> > >> NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS > >> > >> 0001-test-odp_timer.h-cunit-test.patch has style problems, please > review. > > > > Do we want to split up this printout? > No. > > > If you're not familiar with the code and you run the validation tests > > and got this failure printed out. I would grep for that failure message > > (the string) in the code too see how I got there. > Exactly. > > > And if we split this string up into multiple rows just to make > > check-patch happy it will make it harder to search after the failure > > message then right? > Correct. > And I even think checkpatch for this reason will complain if you split > the string. > > -- Ola > > > > > Cheers, > > Anders > -- *Mike Holmes* Linaro Sr Technical Manager LNG - ODP ___ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
On 10 December 2014 at 09:13, Anders Roxell wrote: > On 2014-12-09 17:56, Mike Holmes wrote: >> Has checkpatch issues >> >> Using patch: >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >> git am >> /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox >> Patch applied, building... >> WARNING: line over 80 characters >> #238: FILE: test/validation/odp_timer.c:185: >> + CU_FAIL("Failed to set timer (tooearly/toolate)"); >> >> total: 0 errors, 1 warnings, 0 checks, 359 lines checked >> >> NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS >> >> 0001-test-odp_timer.h-cunit-test.patch has style problems, please review. > > Do we want to split up this printout? No. > If you're not familiar with the code and you run the validation tests > and got this failure printed out. I would grep for that failure message > (the string) in the code too see how I got there. Exactly. > And if we split this string up into multiple rows just to make > check-patch happy it will make it harder to search after the failure > message then right? Correct. And I even think checkpatch for this reason will complain if you split the string. -- Ola > > Cheers, > Anders ___ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
On 2014-12-09 17:56, Mike Holmes wrote: > Has checkpatch issues > > Using patch: > /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox > git am > /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox > Patch applied, building... > WARNING: line over 80 characters > #238: FILE: test/validation/odp_timer.c:185: > + CU_FAIL("Failed to set timer (tooearly/toolate)"); > > total: 0 errors, 1 warnings, 0 checks, 359 lines checked > > NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS > > 0001-test-odp_timer.h-cunit-test.patch has style problems, please review. Do we want to split up this printout? If you're not familiar with the code and you run the validation tests and got this failure printed out. I would grep for that failure message (the string) in the code too see how I got there. And if we split this string up into multiple rows just to make check-patch happy it will make it harder to search after the failure message then right? Cheers, Anders ___ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp
Re: [lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
Has checkpatch issues Using patch: /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox git am /home/mike/incoming/lng-odp_PATCH_3-3_test_odp_timer.h_cunit_test.mbox Patch applied, building... WARNING: line over 80 characters #238: FILE: test/validation/odp_timer.c:185: + CU_FAIL("Failed to set timer (tooearly/toolate)"); total: 0 errors, 1 warnings, 0 checks, 359 lines checked NOTE: Ignored message types: DEPRECATED_VARIABLE NEW_TYPEDEFS 0001-test-odp_timer.h-cunit-test.patch has style problems, please review. On 8 December 2014 at 17:49, Ola Liljedahl wrote: > Signed-off-by: Ola Liljedahl > --- > (This document/code contribution attached is provided under the terms of > agreement LES-LTM-21309) > A new cunit test program test/validation/odp_timer.c for the updated timer > API. > > test/validation/.gitignore | 1 + > test/validation/Makefile.am | 4 +- > test/validation/odp_timer.c | 336 > > 3 files changed, 340 insertions(+), 1 deletion(-) > create mode 100644 test/validation/odp_timer.c > > diff --git a/test/validation/.gitignore b/test/validation/.gitignore > index 37e2594..586def0 100644 > --- a/test/validation/.gitignore > +++ b/test/validation/.gitignore > @@ -4,3 +4,4 @@ odp_init > odp_queue > odp_crypto > odp_shm > +odp_timer > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > index 8547085..043bf4c 100644 > --- a/test/validation/Makefile.am > +++ b/test/validation/Makefile.am > @@ -6,13 +6,14 @@ AM_LDFLAGS += -static > if ODP_CUNIT_ENABLED > TESTS = ${bin_PROGRAMS} > check_PROGRAMS = ${bin_PROGRAMS} > -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm > +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_timer > odp_init_LDFLAGS = $(AM_LDFLAGS) > odp_queue_LDFLAGS = $(AM_LDFLAGS) > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > odp_crypto_LDFLAGS = $(AM_LDFLAGS) > odp_shm_CFLAGS = $(AM_CFLAGS) > odp_shm_LDFLAGS = $(AM_LDFLAGS) > +odp_timer_LDFLAGS = $(AM_LDFLAGS) > endif > > dist_odp_init_SOURCES = odp_init.c > @@ -22,3 +23,4 @@ dist_odp_crypto_SOURCES = > crypto/odp_crypto_test_async_inp.c \ > crypto/odp_crypto_test_rng.c \ > odp_crypto.c common/odp_cunit_common.c > dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c > +dist_odp_timer_SOURCES = odp_timer.c common/odp_cunit_common.c > diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c > new file mode 100644 > index 000..4b6b872 > --- /dev/null > +++ b/test/validation/odp_timer.c > @@ -0,0 +1,336 @@ > +/* Copyright (c) 2014, Linaro Limited > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +/** > + * @file > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include "odp_cunit_common.h" > + > +/** @private Timeout range in milliseconds (ms) */ > +#define RANGE_MS 2000 > + > +/** @private Number of timers per thread */ > +#define NTIMERS 2000 > + > +/** @private Timeout pool size per thread */ > +#define TMO_POOL_SIZE (512 * NTIMERS) > + > +/** @private Barrier for thread synchronisation */ > +static odp_barrier_t test_barrier; > + > +/** @private Timeout buffer pool handle used by all threads */ > +static odp_buffer_pool_t tbp; > + > +/** @private Timer pool handle used by all threads */ > +static odp_timer_pool_t tp; > + > +/** @private min() function */ > +static int min(int a, int b) > +{ > + return a < b ? a : b; > +} > + > +/* @private Timer helper structure */ > +struct test_timer { > + odp_timer_t tim; /* Timer handle */ > + odp_buffer_t buf; /* Timeout buffer */ > + odp_buffer_t buf2; /* Copy of buffer handle */ > + uint64_t tick; /* Expiration tick or ODP_TICK_INVALID */ > +}; > + > +/* @private Handle a received (timeout) buffer */ > +static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) > +{ > + odp_timer_t tim = ODP_TIMER_INVALID; > + uint64_t tick = ODP_TICK_INVALID; > + struct test_timer *ttp = NULL; > + > + /* Use assert() for correctness check of test program itself */ > + assert(buf != ODP_BUFFER_INVALID); > + if (!odp_timer_tmo_metadata(buf, &tim, &tick, (void **)&ttp)) { > + /* Not a default timeout buffer */ > + CU_FAIL("Unexpected buffer type received"); > + return; > + } > + > + if (tim == ODP_TIMER_INVALID) > + CU_FAIL("odp_timer_tmo_metadata() invalid timer"); > + if (tick == ODP_TICK_INVALID) > + CU_FAIL("odp_timer_tmo_metadata() invalid tick"); > + if (ttp == NULL) > + CU_FAIL("odp_timer_tmo_metadata() null user ptr"); > + > + if (ttp->buf2 != buf) > + CU_FAIL("odp_timer_tmo_metadata() wrong user ptr"); > + if (ttp->tim != tim) > + CU_FAIL("odp_timer_tmo_metadata() wrong timer"); > + if (st
[lng-odp] [PATCH 3/3] test: odp_timer.h: cunit test
Signed-off-by: Ola Liljedahl --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) A new cunit test program test/validation/odp_timer.c for the updated timer API. test/validation/.gitignore | 1 + test/validation/Makefile.am | 4 +- test/validation/odp_timer.c | 336 3 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 test/validation/odp_timer.c diff --git a/test/validation/.gitignore b/test/validation/.gitignore index 37e2594..586def0 100644 --- a/test/validation/.gitignore +++ b/test/validation/.gitignore @@ -4,3 +4,4 @@ odp_init odp_queue odp_crypto odp_shm +odp_timer diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index 8547085..043bf4c 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -6,13 +6,14 @@ AM_LDFLAGS += -static if ODP_CUNIT_ENABLED TESTS = ${bin_PROGRAMS} check_PROGRAMS = ${bin_PROGRAMS} -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_timer odp_init_LDFLAGS = $(AM_LDFLAGS) odp_queue_LDFLAGS = $(AM_LDFLAGS) odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto odp_crypto_LDFLAGS = $(AM_LDFLAGS) odp_shm_CFLAGS = $(AM_CFLAGS) odp_shm_LDFLAGS = $(AM_LDFLAGS) +odp_timer_LDFLAGS = $(AM_LDFLAGS) endif dist_odp_init_SOURCES = odp_init.c @@ -22,3 +23,4 @@ dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \ crypto/odp_crypto_test_rng.c \ odp_crypto.c common/odp_cunit_common.c dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c +dist_odp_timer_SOURCES = odp_timer.c common/odp_cunit_common.c diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c new file mode 100644 index 000..4b6b872 --- /dev/null +++ b/test/validation/odp_timer.c @@ -0,0 +1,336 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + */ + +#include +#include +#include +#include +#include +#include +#include "odp_cunit_common.h" + +/** @private Timeout range in milliseconds (ms) */ +#define RANGE_MS 2000 + +/** @private Number of timers per thread */ +#define NTIMERS 2000 + +/** @private Timeout pool size per thread */ +#define TMO_POOL_SIZE (512 * NTIMERS) + +/** @private Barrier for thread synchronisation */ +static odp_barrier_t test_barrier; + +/** @private Timeout buffer pool handle used by all threads */ +static odp_buffer_pool_t tbp; + +/** @private Timer pool handle used by all threads */ +static odp_timer_pool_t tp; + +/** @private min() function */ +static int min(int a, int b) +{ + return a < b ? a : b; +} + +/* @private Timer helper structure */ +struct test_timer { + odp_timer_t tim; /* Timer handle */ + odp_buffer_t buf; /* Timeout buffer */ + odp_buffer_t buf2; /* Copy of buffer handle */ + uint64_t tick; /* Expiration tick or ODP_TICK_INVALID */ +}; + +/* @private Handle a received (timeout) buffer */ +static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) +{ + odp_timer_t tim = ODP_TIMER_INVALID; + uint64_t tick = ODP_TICK_INVALID; + struct test_timer *ttp = NULL; + + /* Use assert() for correctness check of test program itself */ + assert(buf != ODP_BUFFER_INVALID); + if (!odp_timer_tmo_metadata(buf, &tim, &tick, (void **)&ttp)) { + /* Not a default timeout buffer */ + CU_FAIL("Unexpected buffer type received"); + return; + } + + if (tim == ODP_TIMER_INVALID) + CU_FAIL("odp_timer_tmo_metadata() invalid timer"); + if (tick == ODP_TICK_INVALID) + CU_FAIL("odp_timer_tmo_metadata() invalid tick"); + if (ttp == NULL) + CU_FAIL("odp_timer_tmo_metadata() null user ptr"); + + if (ttp->buf2 != buf) + CU_FAIL("odp_timer_tmo_metadata() wrong user ptr"); + if (ttp->tim != tim) + CU_FAIL("odp_timer_tmo_metadata() wrong timer"); + if (stale) { + /* Stale timeout => timer must have invalid tick */ + if (ttp->tick != ODP_TICK_INVALID) + CU_FAIL("Stale timeout for active timer"); + } else { + /* Fresh timeout => timer must have matching tick */ + if (ttp->tick != tick) + CU_FAIL("odp_timer_tmo_metadata() wrong tick"); + /* Check that timeout was delivered 'timely' */ + if (tick > odp_timer_current_tick(tp)) + CU_FAIL("Timeout delivered too early"); + if (tick < prev_tick) + CU_FAIL("Timeout delivered too late"); + } + + /* Use assert() for correctness check of test program itself */ + assert(ttp->buf == ODP_BUFFER_INVALID); + ttp->buf = buf; +} + +/* @private Worker