This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via c440dfceff97526d2763383afd8da064faef3d0d (commit) via 93591a6134fbc5655c0cf6a25e0b4e0668357971 (commit) via fec701841dbe2e963cf3adc7c74c98b41e059b9d (commit) via 0e24607e3075a573ebe4ac408703c76daac7236c (commit) via 5d4be5077adeec54d1956c86dcb87b186c39a7cb (commit) via 3aa3f4352083d159260cebc23b87607e73aa6f2b (commit) via 0d4271e31fe685a8a82381d21d5166f0398080c1 (commit) via d324b9de12c510ccf9fa1c1b6ece327c578ee53d (commit) from e828b4d6f503ff94c40e30b1d8babf0dcbecde91 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit c440dfceff97526d2763383afd8da064faef3d0d Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Sun Apr 22 10:18:17 2018 +0300
linux-generic: random: split from crypto module
While random and crypto might share some implementation details, in case of linux-generic and linux-DPDK it might be easier to split them to two different files.
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 4f03eab1..7d1d5554 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -175,6 +175,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_queue_if.c \ odp_queue_lf.c \ odp_queue_scalable.c \ + odp_random.c \ odp_rwlock.c \ odp_rwlock_recursive.c \ odp_schedule_basic.c \ diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 852f0212..aca822d8 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdlib.h>
-#include <openssl/rand.h> #include <openssl/hmac.h> #include <openssl/cmac.h> #include <openssl/evp.h> @@ -1954,47 +1953,6 @@ int _odp_crypto_term_local(void) return 0; }
-odp_random_kind_t odp_random_max_kind(void) -{ - return ODP_RANDOM_CRYPTO; -} - -int32_t odp_random_data(uint8_t *buf, uint32_t len, odp_random_kind_t kind) -{ - int rc; - - switch (kind) { - case ODP_RANDOM_BASIC: - case ODP_RANDOM_CRYPTO: - rc = RAND_bytes(buf, len); - return (1 == rc) ? (int)len /*success*/: -1 /*failure*/; - - case ODP_RANDOM_TRUE: - default: - return -1; - } -} - -int32_t odp_random_test_data(uint8_t *buf, uint32_t len, uint64_t *seed) -{ - union { - uint32_t rand_word; - uint8_t rand_byte[4]; - } u; - uint32_t i = 0, j; - uint32_t seed32 = (*seed) & 0xffffffff; - - while (i < len) { - u.rand_word = rand_r(&seed32); - - for (j = 0; j < 4 && i < len; j++, i++) - *buf++ = u.rand_byte[j]; - } - - *seed = seed32; - return len; -} - odp_crypto_compl_t odp_crypto_compl_from_event(odp_event_t ev) { /* This check not mandated by the API specification */ diff --git a/platform/linux-generic/odp_random.c b/platform/linux-generic/odp_random.c new file mode 100644 index 00000000..22894c47 --- /dev/null +++ b/platform/linux-generic/odp_random.c @@ -0,0 +1,54 @@ +/* Copyright (c) 2014-2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" + +#include <odp_posix_extensions.h> +#include <odp_internal.h> +#include <odp/api/random.h> + +#include <openssl/rand.h> + +odp_random_kind_t odp_random_max_kind(void) +{ + return ODP_RANDOM_CRYPTO; +} + +int32_t odp_random_data(uint8_t *buf, uint32_t len, odp_random_kind_t kind) +{ + int rc; + + switch (kind) { + case ODP_RANDOM_BASIC: + case ODP_RANDOM_CRYPTO: + rc = RAND_bytes(buf, len); + return (1 == rc) ? (int)len /*success*/: -1 /*failure*/; + + case ODP_RANDOM_TRUE: + default: + return -1; + } +} + +int32_t odp_random_test_data(uint8_t *buf, uint32_t len, uint64_t *seed) +{ + union { + uint32_t rand_word; + uint8_t rand_byte[4]; + } u; + uint32_t i = 0, j; + uint32_t seed32 = (*seed) & 0xffffffff; + + while (i < len) { + u.rand_word = rand_r(&seed32); + + for (j = 0; j < 4 && i < len; j++, i++) + *buf++ = u.rand_byte[j]; + } + + *seed = seed32; + return len; +}
commit 93591a6134fbc5655c0cf6a25e0b4e0668357971 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Apr 20 14:25:30 2018 +0300
validation: timer: honor min timeout param value
Timeout requests should be between min_tmo and max_tmo timer pool parameters, if too early/too late return codes are reported as test failures.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index f81a3d09..a34885c0 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -497,7 +497,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED) uint32_t ncancel; uint32_t ntoolate; uint32_t ms; - uint64_t prev_tick; + uint64_t prev_tick, nsec; odp_event_t ev; struct timespec ts; uint32_t nstale; @@ -539,9 +539,9 @@ static int worker_entrypoint(void *arg TEST_UNUSED) /* Initial set all timers with a random expiration time */ nset = 0; for (i = 0; i < allocated; i++) { - tck = odp_timer_current_tick(tp) + 1 + - odp_timer_ns_to_tick(tp, (rand_r(&seed) % RANGE_MS) - * 1000000ULL); + nsec = MIN_TMO + (rand_r(&seed) % RANGE_MS) * 1000000ULL; + tck = odp_timer_current_tick(tp) + + odp_timer_ns_to_tick(tp, nsec); timer_rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].ev); if (timer_rc == ODP_TIMER_TOOEARLY) { LOG_ERR("Missed tick, setting timer\n"); @@ -585,7 +585,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED) } else { odp_timer_set_t rc; uint64_t cur_tick; - uint64_t tck, nsec; + uint64_t tck;
if (tt[i].ev != ODP_EVENT_INVALID) /* Timer inactive => set */ @@ -594,16 +594,18 @@ static int worker_entrypoint(void *arg TEST_UNUSED) /* Timer active => reset */ nreset++;
- nsec = (rand_r(&seed) % RANGE_MS) * 1000000ULL; - tck = 1 + odp_timer_ns_to_tick(tp, nsec); + nsec = MIN_TMO + + (rand_r(&seed) % RANGE_MS) * 1000000ULL; + tck = odp_timer_ns_to_tick(tp, nsec);
cur_tick = odp_timer_current_tick(tp); rc = odp_timer_set_rel(tt[i].tim, tck, &tt[i].ev);
- if (rc == ODP_TIMER_TOOEARLY || - rc == ODP_TIMER_TOOLATE) { - CU_FAIL("Failed to set timer (tooearly/toolate)"); - } else if (rc != ODP_TIMER_SUCCESS) { + if (rc == ODP_TIMER_TOOEARLY) { + CU_FAIL("Failed to set timer: TOO EARLY"); + } else if (rc == ODP_TIMER_TOOLATE) { + CU_FAIL("Failed to set timer: TOO LATE"); + } else if (rc == ODP_TIMER_NOEVENT) { /* Set/reset failed, timer already expired */ ntoolate++; } else if (rc == ODP_TIMER_SUCCESS) { @@ -611,6 +613,8 @@ static int worker_entrypoint(void *arg TEST_UNUSED) tt[i].tick = cur_tick + tck; /* ODP timer owns the event now */ tt[i].ev = ODP_EVENT_INVALID; + } else { + CU_FAIL("Failed to set timer: bad return code"); } } ts.tv_sec = 0; @@ -743,7 +747,10 @@ static void timer_test_odp_timer_all(void) CU_ASSERT(strcmp(tpinfo.name, NAME) == 0);
LOG_DBG("Timer pool handle: %" PRIu64 "\n", odp_timer_pool_to_u64(tp)); - LOG_DBG("#timers..: %u\n", NTIMERS); + LOG_DBG("Resolution: %" PRIu64 "\n", tparam.res_ns); + LOG_DBG("Min timeout: %" PRIu64 "\n", tparam.min_tmo); + LOG_DBG("Max timeout: %" PRIu64 "\n", tparam.max_tmo); + LOG_DBG("Num timers..: %u\n", tparam.num_timers); LOG_DBG("Tmo range: %u ms (%" PRIu64 " ticks)\n", RANGE_MS, odp_timer_ns_to_tick(tp, 1000000ULL * RANGE_MS));
commit fec701841dbe2e963cf3adc7c74c98b41e059b9d Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Apr 19 17:54:36 2018 +0300
validation: timer: fix timer_all test sync issue
When timer is reset, odp_timer_set_rel() outputs the previous event handle (not ODP_EVENT_INVALID as in case of set). Test case 'timer_all' maintain test status in the event handle variable. Set the variable always to EVENT_INVALID so that both set and reset cases work the same way.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 8ab58137..f81a3d09 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -609,6 +609,8 @@ static int worker_entrypoint(void *arg TEST_UNUSED) } else if (rc == ODP_TIMER_SUCCESS) { /* Save expected expiration tick on success */ tt[i].tick = cur_tick + tck; + /* ODP timer owns the event now */ + tt[i].ev = ODP_EVENT_INVALID; } } ts.tv_sec = 0;
commit 0e24607e3075a573ebe4ac408703c76daac7236c Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Apr 19 14:40:21 2018 +0300
validation: timer: add plain and sched queue tests
Added simple timeout delivery tests for plain and scheduled queues. Current "timer_all" test is complex and tests only plain queues.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index bd4f1b99..8ab58137 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -144,6 +144,170 @@ static void timer_test_timeout_pool_free(void) CU_ASSERT(odp_pool_destroy(pool) == 0); }
+static void timer_test_queue_type(odp_queue_type_t queue_type) +{ + odp_pool_t pool; + const int num = 10; + odp_timeout_t tmo; + odp_event_t ev; + odp_queue_param_t queue_param; + odp_timer_pool_param_t tparam; + odp_timer_pool_t tp; + odp_queue_t queue; + odp_timer_t tim; + int i, ret, num_tmo; + uint64_t tick_base, tick; + uint64_t res_ns, period_ns, period_tick, test_period; + uint64_t diff_period, diff_test; + odp_pool_param_t params; + odp_timer_capability_t timer_capa; + odp_time_t t0, t1, t2; + + odp_pool_param_init(¶ms); + params.type = ODP_POOL_TIMEOUT; + params.tmo.num = num; + + pool = odp_pool_create("timeout_pool", ¶ms); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + if (odp_timer_capability(ODP_CLOCK_CPU, &timer_capa)) + CU_FAIL_FATAL("Timer capability failed") + + res_ns = 20 * ODP_TIME_MSEC_IN_NS; + + if (timer_capa.highest_res_ns > res_ns) + res_ns = timer_capa.highest_res_ns; + + tparam.res_ns = res_ns; + tparam.min_tmo = 5 * res_ns; + tparam.max_tmo = 10000 * tparam.min_tmo; + tparam.num_timers = num + 1; + tparam.priv = 0; + tparam.clk_src = ODP_CLOCK_CPU; + + LOG_DBG("\nTimer pool parameters:\n"); + LOG_DBG(" res_ns %" PRIu64 "\n", tparam.res_ns); + LOG_DBG(" min_tmo %" PRIu64 "\n", tparam.min_tmo); + LOG_DBG(" max_tmo %" PRIu64 "\n", tparam.max_tmo); + + tp = odp_timer_pool_create("timer_pool", &tparam); + if (tp == ODP_TIMER_POOL_INVALID) + CU_FAIL_FATAL("Timer pool create failed"); + + odp_timer_pool_start(); + + odp_queue_param_init(&queue_param); + if (queue_type == ODP_QUEUE_TYPE_SCHED) { + queue_param.type = ODP_QUEUE_TYPE_SCHED; + queue_param.sched.prio = ODP_SCHED_PRIO_DEFAULT; + queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC; + queue_param.sched.group = ODP_SCHED_GROUP_ALL; + } + + queue = odp_queue_create("timer_queue", &queue_param); + if (queue == ODP_QUEUE_INVALID) + CU_FAIL_FATAL("Queue create failed"); + + period_ns = 4 * tparam.min_tmo; + period_tick = odp_timer_ns_to_tick(tp, period_ns); + test_period = num * period_ns; + + LOG_DBG(" period_ns %" PRIu64 "\n", period_ns); + LOG_DBG(" period_tick %" PRIu64 "\n\n", period_tick); + + tick_base = odp_timer_current_tick(tp); + t0 = odp_time_local(); + t1 = t0; + t2 = t0; + + for (i = 0; i < num; i++) { + tmo = odp_timeout_alloc(pool); + CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID); + ev = odp_timeout_to_event(tmo); + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); + + tim = odp_timer_alloc(tp, queue, USER_PTR); + CU_ASSERT_FATAL(tim != ODP_TIMER_INVALID); + + tick = tick_base + ((i + 1) * period_tick); + ret = odp_timer_set_abs(tim, tick, &ev); + + LOG_DBG("abs timer tick %" PRIu64 "\n", tick); + if (ret == ODP_TIMER_TOOEARLY) + LOG_DBG("Too early %" PRIu64 "\n", tick); + else if (ret == ODP_TIMER_TOOLATE) + LOG_DBG("Too late %" PRIu64 "\n", tick); + else if (ret == ODP_TIMER_NOEVENT) + LOG_DBG("No event %" PRIu64 "\n", tick); + + CU_ASSERT(ret == ODP_TIMER_SUCCESS); + } + + num_tmo = 0; + + do { + if (queue_type == ODP_QUEUE_TYPE_SCHED) + ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); + else + ev = odp_queue_deq(queue); + + t2 = odp_time_local(); + diff_test = odp_time_diff_ns(t2, t0); + + if (ev != ODP_EVENT_INVALID) { + diff_period = odp_time_diff_ns(t2, t1); + t1 = odp_time_local(); + tmo = odp_timeout_from_event(ev); + tim = odp_timeout_timer(tmo); + tick = odp_timeout_tick(tmo); + + CU_ASSERT(diff_period > (period_ns - (2 * res_ns))); + CU_ASSERT(diff_period < (period_ns + (2 * res_ns))); + + LOG_DBG("timeout tick %" PRIu64 "\n", tick); + + odp_timeout_free(tmo); + CU_ASSERT(odp_timer_free(tim) == ODP_EVENT_INVALID); + + num_tmo++; + } + + } while (diff_test < (2 * test_period) && num_tmo < num); + + CU_ASSERT(num_tmo == num); + CU_ASSERT(diff_test > (test_period - tparam.min_tmo)); + CU_ASSERT(diff_test < (test_period + tparam.min_tmo)); + + /* Scalable scheduler needs this pause sequence. Otherwise, it gets + * stuck on terminate. */ + if (queue_type == ODP_QUEUE_TYPE_SCHED) { + odp_schedule_pause(); + while (1) { + ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); + if (ev == ODP_EVENT_INVALID) + break; + + CU_FAIL("Drop extra event\n"); + odp_event_free(ev); + } + } + + odp_timer_pool_destroy(tp); + + CU_ASSERT(odp_queue_destroy(queue) == 0); + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + +static void timer_test_plain_queue(void) +{ + timer_test_queue_type(ODP_QUEUE_TYPE_PLAIN); +} + +static void timer_test_sched_queue(void) +{ + timer_test_queue_type(ODP_QUEUE_TYPE_SCHED); +} + static void timer_test_odp_timer_cancel(void) { odp_pool_t pool; @@ -642,6 +806,8 @@ static void timer_test_odp_timer_all(void) odp_testinfo_t timer_suite[] = { ODP_TEST_INFO(timer_test_timeout_pool_alloc), ODP_TEST_INFO(timer_test_timeout_pool_free), + ODP_TEST_INFO(timer_test_plain_queue), + ODP_TEST_INFO(timer_test_sched_queue), ODP_TEST_INFO(timer_test_odp_timer_cancel), ODP_TEST_INFO(timer_test_odp_timer_all), ODP_TEST_INFO_NULL,
commit 5d4be5077adeec54d1956c86dcb87b186c39a7cb Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Apr 19 13:03:29 2018 +0300
validation: timer: don't assume low timer tick frequency
Timer tick can be the same as CPU frequency. So, test cannot loop until two current_tick calls return the same tick value. Similarly, test cannot assume that expiration tick of a relative timeout call can be exactly calculated from a current_tick value.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 9cbb08bb..bd4f1b99 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -291,19 +291,17 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) CU_FAIL("Wrong status (stale) for fresh timeout");
if (!stale) { - /* Fresh timeout => local timer must have matching tick */ - if (ttp->tick != tick) { - LOG_DBG("Wrong tick: expected %" PRIu64 - " actual %" PRIu64 "\n", + /* tmo tick cannot be smaller than pre-calculated tick */ + if (tick < ttp->tick) { + LOG_DBG("Too small tick: pre-calculated %" PRIu64 + " timeout %" PRIu64 "\n", ttp->tick, tick); - CU_FAIL("odp_timeout_tick() wrong tick"); + CU_FAIL("odp_timeout_tick() too small tick"); } - if (ttp->ev != ODP_EVENT_INVALID) - CU_FAIL("Wrong state for fresh timer (event)");
- /* Check that timeout was delivered 'timely' */ if (tick > odp_timer_current_tick(tp)) CU_FAIL("Timeout delivered early"); + if (tick < prev_tick) { LOG_DBG("Too late tick: %" PRIu64 " prev_tick %" PRIu64"\n", @@ -421,23 +419,23 @@ static int worker_entrypoint(void *arg TEST_UNUSED) ncancel++; } } else { + odp_timer_set_t rc; + uint64_t cur_tick; + uint64_t tck, nsec; + if (tt[i].ev != ODP_EVENT_INVALID) /* Timer inactive => set */ nset++; else /* Timer active => reset */ nreset++; - uint64_t tck = 1 + odp_timer_ns_to_tick(tp, - (rand_r(&seed) % RANGE_MS) * 1000000ULL); - odp_timer_set_t rc; - uint64_t cur_tick; - /* Loop until we manage to read cur_tick and set a - * relative timer in the same tick */ - do { - cur_tick = odp_timer_current_tick(tp); - rc = odp_timer_set_rel(tt[i].tim, - tck, &tt[i].ev); - } while (cur_tick != odp_timer_current_tick(tp)); + + nsec = (rand_r(&seed) % RANGE_MS) * 1000000ULL; + tck = 1 + odp_timer_ns_to_tick(tp, nsec); + + cur_tick = odp_timer_current_tick(tp); + rc = odp_timer_set_rel(tt[i].tim, tck, &tt[i].ev); + if (rc == ODP_TIMER_TOOEARLY || rc == ODP_TIMER_TOOLATE) { CU_FAIL("Failed to set timer (tooearly/toolate)");
commit 3aa3f4352083d159260cebc23b87607e73aa6f2b Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Apr 19 11:08:14 2018 +0300
validation: timer: tick conversion may lose precision
Tick <-> nsec conversion may include rounding and thus loss of precision. For example, when tick frequency is higher than 1GHz conversion to nsec lose precision by definition.
Modified test to convert nsec -> tick -> nsec and allow resolution level diffrence between nsec values.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 6d4d3ecd..9cbb08bb 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -25,6 +25,13 @@ /* Number of timers per thread */ #define NTIMERS 2000
+#define NAME "timer_pool" +#define RES (10 * ODP_TIME_MSEC_IN_NS / 3) +#define MIN_TMO (10 * ODP_TIME_MSEC_IN_NS / 3) +#define MAX_TMO (1000000 * ODP_TIME_MSEC_IN_NS) +#define USER_PTR ((void *)0xdead) +#define TICK_INVALID (~(uint64_t)0) + /* Barrier for thread synchronisation */ static odp_barrier_t test_barrier;
@@ -41,6 +48,9 @@ static odp_atomic_u32_t ndelivtoolate; * caches may make this number lower than the capacity of the pool */ static odp_atomic_u32_t timers_allocated;
+/* Timer resolution in nsec */ +static uint64_t resolution_ns; + /* Timer helper structure */ struct test_timer { odp_timer_t tim; /* Timer handle */ @@ -49,8 +59,6 @@ struct test_timer { uint64_t tick; /* Expiration tick or TICK_INVALID */ };
-#define TICK_INVALID (~(uint64_t)0) - static void timer_test_timeout_pool_alloc(void) { odp_pool_t pool; @@ -180,7 +188,6 @@ static void timer_test_odp_timer_cancel(void) if (queue == ODP_QUEUE_INVALID) CU_FAIL_FATAL("Queue create failed");
- #define USER_PTR ((void *)0xdead) tim = odp_timer_alloc(tp, queue, USER_PTR); if (tim == ODP_TIMER_INVALID) CU_FAIL_FATAL("Failed to allocate timer"); @@ -518,9 +525,7 @@ static void timer_test_odp_timer_all(void) odp_timer_pool_param_t tparam; odp_cpumask_t unused; odp_timer_pool_info_t tpinfo; - uint64_t tick; - uint64_t ns; - uint64_t t2; + uint64_t ns, tick, ns2; pthrd_arg thrdarg; odp_timer_capability_t timer_capa;
@@ -546,15 +551,12 @@ static void timer_test_odp_timer_all(void) if (tbp == ODP_POOL_INVALID) CU_FAIL_FATAL("Timeout pool create failed");
-#define NAME "timer_pool" -#define RES (10 * ODP_TIME_MSEC_IN_NS / 3) -#define MIN_TMO (10 * ODP_TIME_MSEC_IN_NS / 3) -#define MAX_TMO (1000000 * ODP_TIME_MSEC_IN_NS) /* Create a timer pool */ if (odp_timer_capability(ODP_CLOCK_CPU, &timer_capa)) CU_FAIL("Error: get timer capacity failed.\n");
- tparam.res_ns = MAX(RES, timer_capa.highest_res_ns); + resolution_ns = MAX(RES, timer_capa.highest_res_ns); + tparam.res_ns = resolution_ns; tparam.min_tmo = MIN_TMO; tparam.max_tmo = MAX_TMO; tparam.num_timers = num_workers * NTIMERS; @@ -581,11 +583,26 @@ static void timer_test_odp_timer_all(void) LOG_DBG("Tmo range: %u ms (%" PRIu64 " ticks)\n", RANGE_MS, odp_timer_ns_to_tick(tp, 1000000ULL * RANGE_MS));
- for (tick = 0; tick < 1000000000000ULL; tick += 1000000ULL) { - ns = odp_timer_tick_to_ns(tp, tick); - t2 = odp_timer_ns_to_tick(tp, ns); - if (tick != t2) - CU_FAIL("Invalid conversion tick->ns->tick"); + tick = odp_timer_ns_to_tick(tp, 0); + CU_ASSERT(tick == 0); + ns2 = odp_timer_tick_to_ns(tp, tick); + CU_ASSERT(ns2 == 0); + + for (ns = resolution_ns; ns < MAX_TMO; ns += resolution_ns) { + tick = odp_timer_ns_to_tick(tp, ns); + ns2 = odp_timer_tick_to_ns(tp, tick); + + if (ns2 < ns - resolution_ns) { + LOG_DBG("FAIL ns:%" PRIu64 " tick:%" PRIu64 " ns2:%" + PRIu64 "\n", ns, tick, ns2); + CU_FAIL("tick conversion: nsec too small\n"); + } + + if (ns2 > ns + resolution_ns) { + LOG_DBG("FAIL ns:%" PRIu64 " tick:%" PRIu64 " ns2:%" + PRIu64 "\n", ns, tick, ns2); + CU_FAIL("tick conversion: nsec too large\n"); + } }
/* Initialize barrier used by worker threads for synchronization */
commit 0d4271e31fe685a8a82381d21d5166f0398080c1 Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Apr 19 10:17:39 2018 +0300
validation: timer: check user pointer once
Code clean up: check only once that user pointer is not NULL.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 06148de8..6d4d3ecd 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -233,6 +233,10 @@ static void timer_test_odp_timer_cancel(void) static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) { odp_event_subtype_t subtype; + odp_timeout_t tmo; + odp_timer_t tim; + uint64_t tick; + struct test_timer *ttp;
CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); /* Internal error */ if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) { @@ -255,33 +259,39 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) CU_FAIL("Unexpected event subtype received"); return; } + /* Read the metadata from the timeout */ - odp_timeout_t tmo = odp_timeout_from_event(ev); - odp_timer_t tim = odp_timeout_timer(tmo); - uint64_t tick = odp_timeout_tick(tmo); - struct test_timer *ttp = odp_timeout_user_ptr(tmo); + tmo = odp_timeout_from_event(ev); + tim = odp_timeout_timer(tmo); + tick = odp_timeout_tick(tmo); + ttp = odp_timeout_user_ptr(tmo);
if (tim == ODP_TIMER_INVALID) CU_FAIL("odp_timeout_timer() invalid timer"); - if (!ttp) + + if (ttp == NULL) { CU_FAIL("odp_timeout_user_ptr() null user ptr"); + return; + }
- if (ttp && ttp->ev2 != ev) + if (ttp->ev2 != ev) CU_FAIL("odp_timeout_user_ptr() wrong user ptr"); - if (ttp && ttp->tim != tim) + + if (ttp->tim != tim) CU_FAIL("odp_timeout_timer() wrong timer");
if (!odp_timeout_fresh(tmo)) CU_FAIL("Wrong status (stale) for fresh timeout"); + if (!stale) { /* Fresh timeout => local timer must have matching tick */ - if (ttp && ttp->tick != tick) { + if (ttp->tick != tick) { LOG_DBG("Wrong tick: expected %" PRIu64 " actual %" PRIu64 "\n", ttp->tick, tick); CU_FAIL("odp_timeout_tick() wrong tick"); } - if (ttp && ttp->ev != ODP_EVENT_INVALID) + if (ttp->ev != ODP_EVENT_INVALID) CU_FAIL("Wrong state for fresh timer (event)");
/* Check that timeout was delivered 'timely' */ @@ -296,11 +306,9 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) } }
- if (ttp) { - /* Internal error */ - CU_ASSERT_FATAL(ttp->ev == ODP_EVENT_INVALID); - ttp->ev = ev; - } + /* Internal error */ + CU_ASSERT_FATAL(ttp->ev == ODP_EVENT_INVALID); + ttp->ev = ev; }
/* Worker thread entrypoint which performs timer alloc/set/cancel/free
commit d324b9de12c510ccf9fa1c1b6ece327c578ee53d Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Apr 19 09:57:42 2018 +0300
validation: timer: remove doxygen tags
Doxygen documentation is not generated from validation test files. Remove partial and unnecessary doxygen tags.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 1cd32cb1..06148de8 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -6,10 +6,6 @@
#include "config.h"
-/** - * @file - */ - /* For rand_r and nanosleep */ #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -23,29 +19,29 @@
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-/** @private Timeout range in milliseconds (ms) */ +/* Timeout range in milliseconds (ms) */ #define RANGE_MS 2000
-/** @private Number of timers per thread */ +/* Number of timers per thread */ #define NTIMERS 2000
-/** @private Barrier for thread synchronisation */ +/* Barrier for thread synchronisation */ static odp_barrier_t test_barrier;
-/** @private Timeout pool handle used by all threads */ +/* Timeout pool handle used by all threads */ static odp_pool_t tbp;
-/** @private Timer pool handle used by all threads */ +/* Timer pool handle used by all threads */ static odp_timer_pool_t tp;
-/** @private Count of timeouts delivered too late */ +/* Count of timeouts delivered too late */ static odp_atomic_u32_t ndelivtoolate;
-/** @private Sum of all allocated timers from all threads. Thread-local +/* Sum of all allocated timers from all threads. Thread-local * caches may make this number lower than the capacity of the pool */ static odp_atomic_u32_t timers_allocated;
-/* @private Timer helper structure */ +/* Timer helper structure */ struct test_timer { odp_timer_t tim; /* Timer handle */ odp_event_t ev; /* Timeout event */ @@ -233,7 +229,7 @@ static void timer_test_odp_timer_cancel(void) CU_FAIL_FATAL("Failed to destroy pool"); }
-/* @private Handle a received (timeout) event */ +/* Handle a received (timeout) event */ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) { odp_event_subtype_t subtype; @@ -307,7 +303,7 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) } }
-/* @private Worker thread entrypoint which performs timer alloc/set/cancel/free +/* Worker thread entrypoint which performs timer alloc/set/cancel/free * tests */ static int worker_entrypoint(void *arg TEST_UNUSED) { @@ -506,7 +502,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED) return CU_get_number_of_failures(); }
-/* @private Timer test case entrypoint */ +/* Timer test case entrypoint */ static void timer_test_odp_timer_all(void) { int rc;
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/Makefile.am | 1 + platform/linux-generic/odp_crypto.c | 42 ----- platform/linux-generic/odp_random.c | 54 ++++++ test/validation/api/timer/timer.c | 336 ++++++++++++++++++++++++++++-------- 4 files changed, 320 insertions(+), 113 deletions(-) create mode 100644 platform/linux-generic/odp_random.c
hooks/post-receive