[ovs-dev] [PATCH] test-atomic: Stop testing when running slow.

Motonori Shindo motonori at shin.do
Tue Jan 13 07:48:48 UTC 2015


Jarno,

Thanks for the patch. With this patch, I confirmed that I no longer
encounter the problem I reported before. Just curious but where is
VLOG_INFO() written to in this case?

---
Motonori Shindo


2015-01-13 6:27 GMT+09:00 Jarno Rajahalme <jrajahalme at nicira.com>:

> When the test suite is run on an OS with 1 core (e.g., a VM with one
> core assigned to it), some of the atomic memory model tests take a
> long time, with the effect that the test seems stuck.
>
> This patch stops these tests after one second and only fails the test
> if there has not been any significant progress, allowing the test to
> pass also when running only with one core.
>
> Reported-by: Motonori Shindo <motonori at shin.do>
> Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
> ---
>  tests/test-atomic.c |   40 ++++++++++++++++++++++++++++++++++++----
>  1 file changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/tests/test-atomic.c b/tests/test-atomic.c
> index dcd0a73..0f7f2c0 100644
> --- a/tests/test-atomic.c
> +++ b/tests/test-atomic.c
> @@ -17,9 +17,13 @@
>  #include <config.h>
>  #undef NDEBUG
>  #include "ovs-atomic.h"
> -#include "util.h"
>  #include "ovstest.h"
>  #include "ovs-thread.h"
> +#include "timeval.h"
> +#include "util.h"
> +#include "openvswitch/vlog.h"
> +
> +VLOG_DEFINE_THIS_MODULE(test_atomic);
>
>  #define TEST_ATOMIC_TYPE(ATOMIC_TYPE, BASE_TYPE)        \
>      {                                                   \
> @@ -186,6 +190,7 @@ atomic_consumer(void * arg1 OVS_UNUSED)
>  {
>      struct atomic_aux *old_aux = NULL;
>      uint64_t count;
> +    long long int stop_time = time_msec() + 1000;
>
>      do {
>          struct atomic_aux *aux;
> @@ -202,7 +207,14 @@ atomic_consumer(void * arg1 OVS_UNUSED)
>          ovs_assert(b == count + 42);
>
>          old_aux = aux;
> -    } while (count < ATOMIC_ITEM_COUNT - 1);
> +    } while (count < ATOMIC_ITEM_COUNT - 1 && time_msec() < stop_time);
> +
> +    if (time_msec() >= stop_time) {
> +        if (count < 10) {
> +            VLOG_INFO("atomic_consumer test stopped due to excessive
> runtime. "
> +                      "Count = %"PRIu64, count);
> +        }
> +    }
>
>      return NULL;
>  }
> @@ -249,6 +261,8 @@ atomic_reader(void *aux_)
>      struct atomic_aux *aux = aux_;
>      uint64_t count;
>      uint64_t data;
> +    long long int now = time_msec();
> +    long long int stop_time = now + 1000;
>
>      do {
>          /* Non-synchronized add. */
> @@ -256,7 +270,15 @@ atomic_reader(void *aux_)
>
>          do {
>              atomic_read_explicit(&aux->data64, &data,
> memory_order_acquire);
> -        } while (!data);
> +        } while (!data && (now = time_msec()) < stop_time);
> +
> +        if (now >= stop_time) {
> +            if (count < 10) {
> +                VLOG_INFO("atomic_reader test stopped due to excessive "
> +                          "runtime. Count = %"PRIu64, count);
> +            }
> +            break;
> +        }
>
>          ovs_assert(data == a && data == aux->b && a == aux->b);
>
> @@ -277,12 +299,22 @@ atomic_writer(void *aux_)
>      uint64_t old_count;
>      uint64_t data;
>      size_t i;
> +    long long int now = time_msec();
> +    long long int stop_time = now + 1000;
>
>      for (i = 0; i < ATOMIC_ITEM_COUNT; i++) {
>          /* Wait for the reader to be done with the data. */
>          do {
>              atomic_read_explicit(&aux->data64, &data,
> memory_order_acquire);
> -        } while (data);
> +        } while (data && (now = time_msec()) < stop_time);
> +
> +        if (now >= stop_time) {
> +            if (i < 10) {
> +                VLOG_INFO("atomic_writer test stopped due to excessive "
> +                          "runtime, Count = %"PRIuSIZE, i);
> +            }
> +            break;
> +        }
>
>          a = i + 1;
>          atomic_add_explicit(&aux->count, 1, &old_count,
> memory_order_relaxed);
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list