[PATCH] Testsuite for inttypes.

Joel Sherrill joel at rtems.org
Mon Jun 12 19:07:19 UTC 2017


This is just a test style thing but since you are going to be
doing this all summer, how about Init() calling a "test_XXX"
method for each method under test. That would roughly
correspond to each of the comment blocks in your Init().
This makes it easier to go back and add test cases for
specific coverage cases.

test_imaxdiv()
etc.

Also the code needs to be merged into newlib first so
we need to get your email showing up there.

--joel



On Mon, Jun 12, 2017 at 1:56 PM, Aditya Upadhyay <aadit0402 at gmail.com>
wrote:

> ---
>  testsuites/psxtests/Makefile.am                    |   1 +
>  testsuites/psxtests/configure.ac                   |   1 +
>  testsuites/psxtests/psxinttypes01/Makefile.am      |  22 +++++
>  testsuites/psxtests/psxinttypes01/init.c           | 107
> +++++++++++++++++++++
>  .../psxtests/psxinttypes01/psxinttypes01.scn       |   9 ++
>  5 files changed, 140 insertions(+)
>  create mode 100644 testsuites/psxtests/psxinttypes01/Makefile.am
>  create mode 100644 testsuites/psxtests/psxinttypes01/init.c
>  create mode 100644 testsuites/psxtests/psxinttypes01/psxinttypes01.scn
>
> diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/
> Makefile.am
> index 7bcea46..8b246d8 100644
> --- a/testsuites/psxtests/Makefile.am
> +++ b/testsuites/psxtests/Makefile.am
> @@ -49,6 +49,7 @@ _SUBDIRS += psxfatal01
>  _SUBDIRS += psxfatal02
>  _SUBDIRS += psxgetattrnp01
>  endif
> +_SUBDIRS += psxinttypes01
>  if HAS_POSIX
>  if HAS_CPLUSPLUS
>  _SUBDIRS += psxglobalcon01
> diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/
> configure.ac
> index 1de1312..4db7916 100644
> --- a/testsuites/psxtests/configure.ac
> +++ b/testsuites/psxtests/configure.ac
> @@ -162,6 +162,7 @@ psxid01/Makefile
>  psximfs01/Makefile
>  psximfs02/Makefile
>  psxintrcritical01/Makefile
> +psxinttypes01/Makefile
>  psxitimer/Makefile
>  psxkey01/Makefile
>  psxkey02/Makefile
> diff --git a/testsuites/psxtests/psxinttypes01/Makefile.am
> b/testsuites/psxtests/psxinttypes01/Makefile.am
> new file mode 100644
> index 0000000..517648c
> --- /dev/null
> +++ b/testsuites/psxtests/psxinttypes01/Makefile.am
> @@ -0,0 +1,22 @@
> +
> +rtems_tests_PROGRAMS = psxinttypes01
> +psxinttypes01_SOURCES = init.c
> +
> +dist_rtems_tests_DATA = psxinttypes01.scn
> +
> +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
> +include $(top_srcdir)/../automake/compile.am
> +include $(top_srcdir)/../automake/leaf.am
> +
> +
> +AM_CPPFLAGS += -I$(top_srcdir)/include
> +AM_CPPFLAGS += -I$(top_srcdir)/../support/include
> +
> +LINK_OBJS = $(psxinttypes01_OBJECTS) $(psxinttypes01_LDADD)
> +LINK_LIBS = $(psxinttypes01_LDLIBS)  /home/aditya/development/b-
> sparc/sparc-rtems4.12/c/erc32/cpukit/inttypes/libinttypes.a
> +
> +psxinttypes01$(EXEEXT): $(psxinttypes01_OBJECTS)
> $(psxinttypes01_DEPENDENCIES)
> +       @rm -f psxinttypes01$(EXEEXT)
> +       $(make-exe)
> +
> +include $(top_srcdir)/../automake/local.am
> diff --git a/testsuites/psxtests/psxinttypes01/init.c
> b/testsuites/psxtests/psxinttypes01/init.c
> new file mode 100644
> index 0000000..770b04d
> --- /dev/null
> +++ b/testsuites/psxtests/psxinttypes01/init.c
> @@ -0,0 +1,107 @@
> +/*
> + *  This is the test for inttypes library. It covers these functions :
> + *  imaxabs(), imaxdiv(), strtoimax(), strtoumax(), wcstoimax(),
> wcstoumax().
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
> +#include <rtems/inttypes.h>
> +#include <rtems/printer.h>
> +#include <rtems/test.h>
> +#include <stdlib.h>
> +#include <tmacros.h>
> +
> +/* forward declarations to avoid warnings */
> +
> +rtems_task Init(rtems_task_argument argument);
> +const char rtems_test_name[] = "PSXINTTYPE 01";
> +rtems_printer rtems_test_printer;
> +
> +/*
> + * RTEMS Startup Task
> + */
> +
> +rtems_task Init(
> +  rtems_task_argument ignored
> +)
> +{
> +  rtems_print_printer_printf(&rtems_test_printer);
> +  rtems_test_begin();
> +
> +  char* endptr, *nptr;
> +
> +  uintmax_t j, k;
> +
> +  int base = 10;
> +  rtems_test_assert (base == EINVAL)
> +
> +  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)
> +
> +  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 );
> +}
> +
> +/* NOTICE: the clock driver is explicitly disabled */
> +
> +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
> +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> +
> +#define CONFIGURE_MAXIMUM_TASKS            1
> +
> +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> +
> +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
> +
> +#define CONFIGURE_INIT
> +#include <rtems/confdefs.h>
> +
> diff --git a/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> new file mode 100644
> index 0000000..1625fa7
> --- /dev/null
> +++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> @@ -0,0 +1,9 @@
> +*** 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20170612/cde3d456/attachment-0002.html>


More information about the devel mailing list