diff mbox

validation: timer: verify timer successfully allocated

Message ID 1463014278-10029-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit acca52168e42778498e637b278c7c3538dea7fbc
Headers show

Commit Message

Bill Fischofer May 12, 2016, 12:51 a.m. UTC
Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2031 by
adding a check to ensure that at least one timer is allocated before
potentially dividing by zero.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 test/validation/timer/timer.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Mike Holmes May 16, 2016, 12:33 p.m. UTC | #1
On 11 May 2016 at 20:51, Bill Fischofer <bill.fischofer@linaro.org> wrote:

> Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2031 by

> adding a check to ensure that at least one timer is allocated before

> potentially dividing by zero.

>

> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

> ---

>  test/validation/timer/timer.c | 2 ++

>  1 file changed, 2 insertions(+)

>

> diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c

> index aad11aa..9d637d0 100644

> --- a/test/validation/timer/timer.c

> +++ b/test/validation/timer/timer.c

> @@ -304,6 +304,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED)

>                 tt[i].tick = TICK_INVALID;

>         }

>


Why is it that the allocating loop above here calls break and exits the
loop forcing us to catch a failure outside, rather than calling
CU_FAIL_FATAL directly ?



>         allocated = i;

> +       if (allocated == 0)

> +               CU_FAIL_FATAL("unable to alloc a timer");

>         odp_atomic_fetch_add_u32(&timers_allocated, allocated);

>

>         odp_barrier_wait(&test_barrier);

> --

> 2.7.4

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>




-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
Bill Fischofer May 16, 2016, 12:36 p.m. UTC | #2
On Mon, May 16, 2016 at 7:33 AM, Mike Holmes <mike.holmes@linaro.org> wrote:

>

> On 11 May 2016 at 20:51, Bill Fischofer <bill.fischofer@linaro.org> wrote:

>

>> Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2031 by

>> adding a check to ensure that at least one timer is allocated before

>> potentially dividing by zero.

>>

>> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

>> ---

>>  test/validation/timer/timer.c | 2 ++

>>  1 file changed, 2 insertions(+)

>>

>> diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c

>> index aad11aa..9d637d0 100644

>> --- a/test/validation/timer/timer.c

>> +++ b/test/validation/timer/timer.c

>> @@ -304,6 +304,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED)

>>                 tt[i].tick = TICK_INVALID;

>>         }

>>

>

> Why is it that the allocating loop above here calls break and exits the

> loop forcing us to catch a failure outside, rather than calling

> CU_FAIL_FATAL directly ?

>


Because no individual allocation failure is in itself fatal. The fatal
condition is if all fail, which is why the check is outside the loop.


>

>

>

>>         allocated = i;

>> +       if (allocated == 0)

>> +               CU_FAIL_FATAL("unable to alloc a timer");

>>         odp_atomic_fetch_add_u32(&timers_allocated, allocated);

>>

>>         odp_barrier_wait(&test_barrier);

>> --

>> 2.7.4

>>

>> _______________________________________________

>> lng-odp mailing list

>> lng-odp@lists.linaro.org

>> https://lists.linaro.org/mailman/listinfo/lng-odp

>>

>

>

>

> --

> Mike Holmes

> Technical Manager - Linaro Networking Group

> Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs

> "Work should be fun and collaborative, the rest follows"

>

>

>
Mike Holmes May 16, 2016, 12:40 p.m. UTC | #3
On 11 May 2016 at 20:51, Bill Fischofer <bill.fischofer@linaro.org> wrote:

> Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2031 by

> adding a check to ensure that at least one timer is allocated before

> potentially dividing by zero.

>

> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

>


Reviewed-by: Mike Holmes <mike.holmes@linaro.org>



> ---

>  test/validation/timer/timer.c | 2 ++

>  1 file changed, 2 insertions(+)

>

> diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c

> index aad11aa..9d637d0 100644

> --- a/test/validation/timer/timer.c

> +++ b/test/validation/timer/timer.c

> @@ -304,6 +304,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED)

>                 tt[i].tick = TICK_INVALID;

>         }

>         allocated = i;

> +       if (allocated == 0)

> +               CU_FAIL_FATAL("unable to alloc a timer");

>         odp_atomic_fetch_add_u32(&timers_allocated, allocated);

>

>         odp_barrier_wait(&test_barrier);

> --

> 2.7.4

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>




-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
Maxim Uvarov May 16, 2016, 1:51 p.m. UTC | #4
Merged,
Maxim.

On 05/16/16 15:40, Mike Holmes wrote:
>
>
> On 11 May 2016 at 20:51, Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>> wrote:
>
>     Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2031 by
>     adding a check to ensure that at least one timer is allocated before
>     potentially dividing by zero.
>
>     Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org
>     <mailto:bill.fischofer@linaro.org>>
>
>
> Reviewed-by: Mike Holmes <mike.holmes@linaro.org 
> <mailto:mike.holmes@linaro.org>>
>
>     ---
>      test/validation/timer/timer.c | 2 ++
>      1 file changed, 2 insertions(+)
>
>     diff --git a/test/validation/timer/timer.c
>     b/test/validation/timer/timer.c
>     index aad11aa..9d637d0 100644
>     --- a/test/validation/timer/timer.c
>     +++ b/test/validation/timer/timer.c
>     @@ -304,6 +304,8 @@ static void *worker_entrypoint(void *arg
>     TEST_UNUSED)
>                     tt[i].tick = TICK_INVALID;
>             }
>             allocated = i;
>     +       if (allocated == 0)
>     +               CU_FAIL_FATAL("unable to alloc a timer");
>             odp_atomic_fetch_add_u32(&timers_allocated, allocated);
>
>             odp_barrier_wait(&test_barrier);
>     --
>     2.7.4
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> -- 
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org <http://www.linaro.org/>***│ *Open source software for ARM SoCs
> "Work should be fun and collaborative, the rest follows"
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
index aad11aa..9d637d0 100644
--- a/test/validation/timer/timer.c
+++ b/test/validation/timer/timer.c
@@ -304,6 +304,8 @@  static void *worker_entrypoint(void *arg TEST_UNUSED)
 		tt[i].tick = TICK_INVALID;
 	}
 	allocated = i;
+	if (allocated == 0)
+		CU_FAIL_FATAL("unable to alloc a timer");
 	odp_atomic_fetch_add_u32(&timers_allocated, allocated);
 
 	odp_barrier_wait(&test_barrier);