[PATCH v2] Testsuite for inttypes methods

Gedare Bloom gedare at rtems.org
Sun Aug 27 13:59:52 UTC 2017


I'm pretty sure the error code is returned via 'errno', not as a
return value. Re-read the specification again.

On Sat, Aug 26, 2017 at 3:38 PM, Joel Sherrill <joel at rtems.org> wrote:
>
>
> On Fri, Aug 25, 2017 at 9:05 AM, Gedare Bloom <gedare at rtems.org> wrote:
>>
>> Merge this with the previous commits to only provide 1 single commit
>> adding this new test.
>>
>> On Wed, Aug 23, 2017 at 3:35 PM, Aditya Upadhyay <aadit0402 at gmail.com>
>> wrote:
>> > ---
>> >  testsuites/psxtests/Makefile.am                    |  5 --
>> >  testsuites/psxtests/configure.ac                   |  5 --
>> >  testsuites/psxtests/psxinttypes01/init.c           | 66
>> > +++++++++++++++++++---
>> >  .../psxtests/psxinttypes01/psxinttypes01.scn       |  8 +++
>> >  4 files changed, 66 insertions(+), 18 deletions(-)
>> >
>> > diff --git a/testsuites/psxtests/Makefile.am
>> > b/testsuites/psxtests/Makefile.am
>> > index cda0061..5d3d41d 100644
>> > --- a/testsuites/psxtests/Makefile.am
>> > +++ b/testsuites/psxtests/Makefile.am
>> > @@ -59,11 +59,6 @@ _SUBDIRS += psxintrcritical01
>> >  _SUBDIRS += psxitimer
>> >  endif
>> >  _SUBDIRS += psxinttypes01
>> > -_SUBDIRS += psxinttypes02
>> > -_SUBDIRS += psxinttypes03
>> > -_SUBDIRS += psxinttypes04
>> > -_SUBDIRS += psxinttypes05
>> > -_SUBDIRS += psxinttypes06
>> >  _SUBDIRS += psxkey01
>> >  _SUBDIRS += psxkey02
>> >  _SUBDIRS += psxkey03
>> > diff --git a/testsuites/psxtests/configure.ac
>> > b/testsuites/psxtests/configure.ac
>> > index dd5f23f..b2b00b7 100644
>> > --- a/testsuites/psxtests/configure.ac
>> > +++ b/testsuites/psxtests/configure.ac
>> > @@ -163,11 +163,6 @@ psximfs01/Makefile
>> >  psximfs02/Makefile
>> >  psxintrcritical01/Makefile
>> >  psxinttypes01/Makefile
>> > -psxinttypes02/Makefile
>> > -psxinttypes03/Makefile
>> > -psxinttypes04/Makefile
>> > -psxinttypes05/Makefile
>> > -psxinttypes06/Makefile
>> >  psxitimer/Makefile
>> >  psxkey01/Makefile
>> >  psxkey02/Makefile
>> > diff --git a/testsuites/psxtests/psxinttypes01/init.c
>> > b/testsuites/psxtests/psxinttypes01/init.c
>> > index ad41a6d..72f036a 100644
>> > --- a/testsuites/psxtests/psxinttypes01/init.c
>> > +++ b/testsuites/psxtests/psxinttypes01/init.c
>> > @@ -1,5 +1,6 @@
>> >  /*
>> > - *  This is the test for inttypes imaxabs method.
>> > + *  This is the test for inttypes library. It covers these functions :
>> > + *  imaxabs(), imaxdiv(), strtoimax(), strtoumax(), wcstoimax(),
>> > wcstoumax().
>> >   */
>> >
>> >  #ifdef HAVE_CONFIG_H
>> > @@ -11,8 +12,6 @@
>> >  #include <rtems/test.h>
>> >  #include <stdlib.h>
>> >  #include <stdio.h>
>> > -#include <bsp.h>
>> > -#include <stdint.h>
>> >  #include <errno.h>
>> >  #include <tmacros.h>
>> >
>> > @@ -32,11 +31,63 @@ rtems_task Init(
>> >  {
>> >    rtems_print_printer_printf(&rtems_test_printer);
>> >    rtems_test_begin();
>> > -
>> > -  intmax_t a = -1234;
>> >
>> > -  intmax_t b = imaxabs(a);
>> > -  printf( "imaxabs_value = %jd\n", b);
>> > +  char* endptr, *nptr;
>> > +
>> > +  uintmax_t j, k;
>> > +
>> > +  int base = 10;
>> > +  rtems_test_assert (base == EINVAL);
>> I don't know why this is being asserted.
>>
>> > +
>> > +  wchar_t *nptr1, *endptr1;
>> > +
>> > +  intmax_t m, n;
>> > +
>> > +  nptr1 = L"10110134932";
>> > +  nptr  = "20690239864abc";
>> > +
>> > +  /* Test for wcstoimax */
>> > +
>> > +  m = wcstoimax(nptr1, &endptr1, base);
>> > +  rtems_test_assert (m == ERANGE);
>> > +  rtems_test_assert (m == EINVAL);
>> > +
>> I don't understand these two asserts, Perhaps you meant to check errno?
>>
>> Is it possible to check the correctness of the return value 'm' in an
>> rtems_test_assert() to automate verification of the return?
>>
>
> I don't see how both of those assert's would ever pass. m cannot
> equal both those values. Is it "m == ERANGE || m == EINVAL"?
> Don't we know the single error case it is trying to exercise?
>
>>
>> These same comments apply to the other tests below.
>>
>> You should also add some other boundary condition tests, e.g., NULL
>> endptr, base != 10, and some invalid cases too.
>>
>> > +  printf( "wcstoimax = %jd\n", m );
>> > +
>> > +  /* test for strtoumax */
>> > +
>> > +  j = strtoumax (nptr, &endptr, base);
>> > +  rtems_test_assert (j == ERANGE);
>> > +  rtems_test_assert (j == EINVAL);
>> > +
>> > +  printf( "strtoumax = %ju ( base %d )\n", j, base );
>> > +  printf( "Stopped scan at %s\n\n", endptr );
>> > +
>> > +  /*test for wcstoumax */
>> > +
>> > +  k = wcstoumax (nptr1, &endptr1, base);
>> > +  rtems_test_assert (k == ERANGE);
>> > +  rtems_test_assert (k == EINVAL);
>> > +
>> > +  printf( "wcstoumax = %ju\n", k );
>> > +
>> > +  /*Test for imaxdiv */
>> > +
>> > +  imaxdiv_t retrival = imaxdiv ( 27, 4 );
>> > +  printf( "imax div value = %jd\n", retrival.rem );
>> > +
>> > +  /*Test for imaxabs  */
>> > +
>> > +  printf( "imaxabs_value = %jd\n", imaxabs (-1234));
>> > +
>> > +  /*Test for strtoimax */
>> > +
>> > +  n = strtoimax ("11111111", &endptr, 2);
>> > +  rtems_test_assert (n == ERANGE);
>> > +  rtems_test_assert (n == EINVAL);
>> > +
>> > +  printf( "strtoimax value = %jd\n", n);
>> > +
>> >
>> >    rtems_test_end();
>> >    exit( 0 );
>> > @@ -55,4 +106,3 @@ rtems_task Init(
>> >
>> >  #define CONFIGURE_INIT
>> >  #include <rtems/confdefs.h>
>> > -
>> > diff --git a/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
>> > b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
>> > index 15051e1..47a5416 100644
>> > --- a/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
>> > +++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
>> > @@ -1,3 +1,11 @@
>> >  *** BEGIN OF TEST PSXINTTYPE 01 ***
>> > +wcstoimax = 10110134932
>> > +strtoumax = 20690239864 ( base 10 )
>> > +Stopped scan at abc
>> > +
>> > +wcstoumax = 10110134932
>> > +imax div value = 3
>> >  imaxabs_value = 1234
>> > +strtoimax value = 255
>> >  *** END OF TEST PSXINTTYPE 01 ***
>> > +
>> > --
>> > 2.7.4
>> >
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>
>


More information about the devel mailing list