This patch is incomplete. Since you're adding a max_size, we need to
add a test for that. If an implementation says the max size of a queue
is n (n > 0) then we have to attempt to allocate a queue of that size
and verify that trying to add an n+1st element to it will fail.
Otherwise, we shouldn't have a max_size at all (which we had
discussed) since applications only care about minimums. If the
application's requested minimum exceeds any implementation-defined
max_size then the queue_create() call will simply fail.


On Fri, Mar 31, 2017 at 6:46 AM, Petri Savolainen
<petri.savolai...@linaro.org> wrote:
> Updated implementation and test with type specific number of
> queues.
>
> Signed-off-by: Petri Savolainen <petri.savolai...@linaro.org>
> ---
>  platform/linux-generic/odp_queue.c            |  2 ++
>  test/common_plat/validation/api/queue/queue.c | 43 
> ++++++++++++++++-----------
>  2 files changed, 28 insertions(+), 17 deletions(-)
>
> diff --git a/platform/linux-generic/odp_queue.c 
> b/platform/linux-generic/odp_queue.c
> index fcf4bf5..1114c95 100644
> --- a/platform/linux-generic/odp_queue.c
> +++ b/platform/linux-generic/odp_queue.c
> @@ -175,6 +175,8 @@ int odp_queue_capability(odp_queue_capability_t *capa)
>         capa->max_ordered_locks = sched_fn->max_ordered_locks();
>         capa->max_sched_groups  = sched_fn->num_grps();
>         capa->sched_prios       = odp_schedule_num_prio();
> +       capa->plain.max_num     = capa->max_queues;
> +       capa->sched.max_num     = capa->max_queues;

Shouldn't odp_queue_create() also be checking that queue_params.size > 0?

>
>         return 0;
>  }
> diff --git a/test/common_plat/validation/api/queue/queue.c 
> b/test/common_plat/validation/api/queue/queue.c
> index 1f7913a..8a874a4 100644
> --- a/test/common_plat/validation/api/queue/queue.c
> +++ b/test/common_plat/validation/api/queue/queue.c
> @@ -56,7 +56,7 @@ void queue_test_capa(void)
>         odp_queue_param_t qparams;
>         char name[ODP_QUEUE_NAME_LEN];
>         odp_queue_t queue[MAX_QUEUES];
> -       uint32_t num_queues, i;
> +       uint32_t num_queues, i, j;
>
>         memset(&capa, 0, sizeof(odp_queue_capability_t));
>         CU_ASSERT(odp_queue_capability(&capa) == 0);
> @@ -65,34 +65,43 @@ void queue_test_capa(void)
>         CU_ASSERT(capa.max_ordered_locks != 0);
>         CU_ASSERT(capa.max_sched_groups != 0);
>         CU_ASSERT(capa.sched_prios != 0);
> +       CU_ASSERT(capa.plain.max_num != 0);
> +       CU_ASSERT(capa.sched.max_num != 0);
>
>         for (i = 0; i < ODP_QUEUE_NAME_LEN; i++)
>                 name[i] = 'A' + (i % 26);
>
>         name[ODP_QUEUE_NAME_LEN - 1] = 0;
>
> -       if (capa.max_queues > MAX_QUEUES)
> -               num_queues = MAX_QUEUES;
> -       else
> -               num_queues = capa.max_queues;
> -
>         odp_queue_param_init(&qparams);
>
> -       for (i = 0; i < num_queues; i++) {
> -               generate_name(name, i);
> -               queue[i] = odp_queue_create(name, &qparams);
> +       for (j = 0; j < 2; j++) {
> +               if (j == 0) {
> +                       num_queues = capa.plain.max_num;
> +               } else {
> +                       num_queues = capa.sched.max_num;
> +                       qparams.type = ODP_QUEUE_TYPE_SCHED;
> +               }
> +
> +               if (num_queues > MAX_QUEUES)
> +                       num_queues = MAX_QUEUES;
> +
> +               for (i = 0; i < num_queues; i++) {

This code is incorrect since if either max_num is 0 (indicating
unbounded numbers of queues supported) num_queues will be set to zero
so this loop will not create any queues at all.

> +                       generate_name(name, i);
> +                       queue[i] = odp_queue_create(name, &qparams);
>
> -               if (queue[i] == ODP_QUEUE_INVALID) {
> -                       CU_FAIL("Queue create failed");
> -                       num_queues = i;
> -                       break;
> +                       if (queue[i] == ODP_QUEUE_INVALID) {
> +                               CU_FAIL("Queue create failed");
> +                               num_queues = i;
> +                               break;
> +                       }
> +
> +                       CU_ASSERT(odp_queue_lookup(name) != 
> ODP_QUEUE_INVALID);
>                 }
>
> -               CU_ASSERT(odp_queue_lookup(name) != ODP_QUEUE_INVALID);
> +               for (i = 0; i < num_queues; i++)
> +                       CU_ASSERT(odp_queue_destroy(queue[i]) == 0);
>         }
> -
> -       for (i = 0; i < num_queues; i++)
> -               CU_ASSERT(odp_queue_destroy(queue[i]) == 0);
>  }
>
>  void queue_test_mode(void)
> --
> 2.8.1
>

Reply via email to