[PATCH] Testsuite for inttypes methods.

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Sep 6 07:06:52 UTC 2017


On 06/09/17 08:53, Aditya Upadhyay wrote:

> ---
>   testsuites/psxtests/psxinttypes01/Makefile.am      |  22 +++++
>   testsuites/psxtests/psxinttypes01/init.c           | 107 +++++++++++++++++++++
>   .../psxtests/psxinttypes01/psxinttypes01.scn       |  11 +++
>   3 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/psxinttypes01/Makefile.am b/testsuites/psxtests/psxinttypes01/Makefile.am
> new file mode 100644
> index 0000000..90608d4
> --- /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$(psxinttypes01_LDADD)
> +
> +LINK_OBJS = $(psxinttypes01_OBJECTS)
> +LINK_LIBS = $(psxinttypes01_LDLIBS)
> +
> +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..43d49f6
> --- /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 <stdio.h>
> +#include <errno.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();

Please don't use the printer explicitly. Use the TEST_BEGIN() and 
TEST_END() marcos.

> +
> +  char* endptr, *nptr;
> +
> +  uintmax_t j, k;
> +
> +  int base = 10;
> +
> +  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 != 0);
> +  rtems_test_assert (!(*endptr1));
> +
> +  printf( "wcstoimax = %jd\n", m );
> +
> +  /* test for strtoumax */
> +
> +  j = strtoumax (nptr, &endptr, base);
> +  rtems_test_assert (j != 0);
> +  rtems_test_assert (*endptr);
> +
> +  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 != 0);
> +  rtems_test_assert (!(*endptr1));
> +
> +  printf( "wcstoumax = %ju\n", k );
> +
> +  /*Test for imaxdiv */
> +
> +  imaxdiv_t retrival = imaxdiv ( 27, 4 );
> +  printf( "imax div value = %jd\n", retrival.rem );

Did you check that a function call is generated? The compiler may 
replace this with a constant. Better add -fno-builtin to the compiler 
flags. See

testsuites/benchmarks/linpack/Makefile.am

> +
> +  /*Test for imaxabs  */
> +
> +  printf( "imaxabs_value = %jd\n", imaxabs (-1234));
> +
> +  /*Test for strtoimax */
> +
> +  n = strtoimax ("-123junk", &endptr, base);
> +  rtems_test_assert (n != 0);
> +  rtems_test_assert (*endptr);
> +
> +  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..79553be
> --- /dev/null
> +++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> @@ -0,0 +1,11 @@
> +*** BEGIN OF TEST PSXINTTYPES 01 ***
> +wcstoimax = 10110134932
> +strtoumax = 20690239864 ( base 10 )
> +Stopped scan at abc
> +
> +wcstoumax = 10110134932
> +imax div value = 3
> +imaxabs_value = 1234
> +strtoimax value = -123
> +*** END OF TEST PSXINTTYPES 01 ***
> +

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the devel mailing list