mbox series

[v2,0/3] Add tests for abs(), labs(), llabs() (BZ #30263)

Message ID 20230404135747.3576298-1-josimmon@redhat.com
Headers show
Series Add tests for abs(), labs(), llabs() (BZ #30263) | expand

Message

Joe Simmons-Talbott April 4, 2023, 1:57 p.m. UTC
Add testcases for abs(), labs(), and llabs().  Test the bounds of the
given type, zero, and part of the full range of values for labs() and
llabs().  Test the full range for abs().

Changes in V2:
Reduce number of iterations by using a prime interval.  For llabs() test
the 32bit crossover point.

Joe Simmons-Talbott (3):
  stdlib: Add testcases for abs(). (BZ #30263)
  stdlib: Add testcases for labs(). (BZ #30263)
  stdlib: Add testcases for llabs(). (BZ #30263)

 stdlib/Makefile    |  7 ++++++
 stdlib/tst-abs.c   | 45 +++++++++++++++++++++++++++++++++++++
 stdlib/tst-labs.c  | 51 ++++++++++++++++++++++++++++++++++++++++++
 stdlib/tst-llabs.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 158 insertions(+)
 create mode 100644 stdlib/tst-abs.c
 create mode 100644 stdlib/tst-labs.c
 create mode 100644 stdlib/tst-llabs.c

Comments

Joe Simmons-Talbott April 19, 2023, 2:23 p.m. UTC | #1
On Tue, Apr 04, 2023 at 09:57:44AM -0400, Joe Simmons-Talbott wrote:

Gentle ping.

Thanks,
Joe
> Add testcases for abs(), labs(), and llabs().  Test the bounds of the
> given type, zero, and part of the full range of values for labs() and
> llabs().  Test the full range for abs().
> 
> Changes in V2:
> Reduce number of iterations by using a prime interval.  For llabs() test
> the 32bit crossover point.
> 
> Joe Simmons-Talbott (3):
>   stdlib: Add testcases for abs(). (BZ #30263)
>   stdlib: Add testcases for labs(). (BZ #30263)
>   stdlib: Add testcases for llabs(). (BZ #30263)
> 
>  stdlib/Makefile    |  7 ++++++
>  stdlib/tst-abs.c   | 45 +++++++++++++++++++++++++++++++++++++
>  stdlib/tst-labs.c  | 51 ++++++++++++++++++++++++++++++++++++++++++
>  stdlib/tst-llabs.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 158 insertions(+)
>  create mode 100644 stdlib/tst-abs.c
>  create mode 100644 stdlib/tst-labs.c
>  create mode 100644 stdlib/tst-llabs.c
> 
> -- 
> 2.39.2
>
Joe Simmons-Talbott April 26, 2023, 4:38 p.m. UTC | #2
On Wed, Apr 19, 2023 at 10:23:28AM -0400, Joe Simmons-Talbott via Libc-alpha wrote:
> On Tue, Apr 04, 2023 at 09:57:44AM -0400, Joe Simmons-Talbott wrote:
> 
> Gentle ping.

x2

Thanks,
Joe
Wilco Dijkstra May 4, 2023, 12:53 p.m. UTC | #3
Hi Joe,

> Add testcases for abs(), labs(), and llabs().  Test the bounds of the
> given type, zero, and part of the full range of values for labs() and
> llabs().  Test the full range for abs().
>
> Changes in V2:
> Reduce number of iterations by using a prime interval.  For llabs() test
> the 32bit crossover point.

v2 looks good to me.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>

Cheers,
Wilco
Siddhesh Poyarekar May 16, 2023, 6:58 p.m. UTC | #4
On 2023-05-04 08:53, Wilco Dijkstra via Libc-alpha wrote:
> Hi Joe,
> 
>> Add testcases for abs(), labs(), and llabs().  Test the bounds of the
>> given type, zero, and part of the full range of values for labs() and
>> llabs().  Test the full range for abs().
>>
>> Changes in V2:
>> Reduce number of iterations by using a prime interval.  For llabs() test
>> the 32bit crossover point.
> 
> v2 looks good to me.
> 
> Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>

I've pushed these now.

Thanks,
Sid
Florian Weimer May 16, 2023, 8:52 p.m. UTC | #5
* Siddhesh Poyarekar:

> On 2023-05-04 08:53, Wilco Dijkstra via Libc-alpha wrote:
>> Hi Joe,
>> 
>>> Add testcases for abs(), labs(), and llabs().  Test the bounds of the
>>> given type, zero, and part of the full range of values for labs() and
>>> llabs().  Test the full range for abs().
>>>
>>> Changes in V2:
>>> Reduce number of iterations by using a prime interval.  For llabs() test
>>> the 32bit crossover point.
>> v2 looks good to me.
>> Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
>
> I've pushed these now.

This breaks on various 32-bit architectures.  As seen on microblaze:

tst-llabs.c: In function ‘do_test’:
tst-llabs.c:40:12: error: overflow in conversion from ‘long long int’ to ‘long int’ changes value from ‘-9223372036854775807’ to ‘1’ [-Werror=overflow]
   40 |   for (i = LLONG_MIN + 1; i < LLONG_MIN + INT_MAX; i += LARGE_PRIME)
      |            ^~~~~~~~~
tst-llabs.c:43:12: error: overflow in conversion from ‘long long int’ to ‘long int’ changes value from ‘9223372034707292160’ to ‘-2147483648’ [-Werror=overflow]
   43 |   for (i = LLONG_MAX - INT_MAX; i < LLONG_MAX - LARGE_PRIME; i += LARGE_PRIME)
      |            ^~~~~~~~~
cc1: all warnings being treated as errors

Thanks,
Florian