[PATCH] POSIX inttypes Testsuite

Aditya Upadhyay aadit0402 at gmail.com
Wed Sep 26 16:30:57 UTC 2018


---
 testsuites/psxtests/Makefile.am                    |  10 ++
 testsuites/psxtests/configure.ac                   |   1 +
 testsuites/psxtests/psxinttypes01/init.c           | 122 +++++++++++++++++++++
 .../psxtests/psxinttypes01/psxinttypes01.scn       |  28 +++++
 4 files changed, 161 insertions(+)
 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 2a18d54..c7b4899 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -15,6 +15,16 @@ psx_lib =
 support_includes = -I$(top_srcdir)/../support/include
 
 if HAS_POSIX
+if TEST_psxinttypes01
+psx_tests += psxinttypes01
+psx_screens += psxinttypes01/psxinttypes01.scn
+psxinttypes01_SOURCES = psxinttypes01/init.c 
+psxinttypes01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxinttypes01) \
+	$(support_includes) -I$(top_srcdir)/include
+endif
+endif
+
+if HAS_POSIX
 if TEST_psx01
 psx_tests += psx01
 psx01_SOURCES = psx01/init.c psx01/task.c psx01/system.h \
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index cdd6ee7..85559e4 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -91,6 +91,7 @@ RTEMS_TEST_CHECK([psxid01])
 RTEMS_TEST_CHECK([psximfs01])
 RTEMS_TEST_CHECK([psximfs02])
 RTEMS_TEST_CHECK([psxintrcritical01])
+RTEMS_TEST_CHECK([psxinttypes01])
 RTEMS_TEST_CHECK([psxitimer])
 RTEMS_TEST_CHECK([psxkey01])
 RTEMS_TEST_CHECK([psxkey02])
diff --git a/testsuites/psxtests/psxinttypes01/init.c b/testsuites/psxtests/psxinttypes01/init.c
new file mode 100644
index 0000000..7f5942a
--- /dev/null
+++ b/testsuites/psxtests/psxinttypes01/init.c
@@ -0,0 +1,122 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/test.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <errno.h>
+#include <tmacros.h>
+#include <stdint.h>
+#include <stddef.h>
+
+const char rtems_test_name[] = "PSXINTTYPE 01";
+
+/* forward declarations to avoid warnings */
+rtems_task Init(rtems_task_argument ignored);
+
+rtems_task Init(rtems_task_argument ignored)
+{
+  int       base     = 10;
+  char     *nptr1    = "123abc";
+  char     *endptr1  = NULL;
+  wchar_t  *nptr2    = L"-123junk";
+  wchar_t  *endptr2  = NULL;
+  intmax_t  status1;
+  uintmax_t status2;
+  
+
+  TEST_BEGIN();
+
+  puts( "\nChecking invalid base value" );
+  rtems_test_assert( base >=2 && base <= 36 );
+  
+  /*Test for strtoimax  */
+  puts( "Strtoimax Testcases...." );
+  puts( "Generating Status" );
+  status1 = strtoimax( nptr1, &endptr1, base );
+ 
+  rtems_test_assert( status1 != 0); 
+  rtems_test_assert( base != EINVAL);
+  
+  puts( "Checking Garbage end of endptr" );  
+  rtems_test_assert( *endptr1 != '\0' );
+  
+  puts( "Checking Underflow Case" );
+  rtems_test_assert( status1 >= INTMAX_MIN );
+  
+  puts( "Checking Overflow Case" );
+  rtems_test_assert( status1 <= INTMAX_MAX ) ;
+  
+  printf( "status = %jd \n" , status1 );
+  
+  /*Test for strtoumax  */
+  puts( "Strtoumax Testcases...." );
+  puts( "Generating Status" );
+  status2 = strtoumax( nptr1, &endptr1, base );
+  
+  rtems_test_assert( status2 != 0); 
+  rtems_test_assert( base != EINVAL);
+
+  puts( "Checking Garbage end of endptr" );  
+  rtems_test_assert( *endptr1 != '\0' );
+  
+  puts( "Checking Overflow Case" );
+  rtems_test_assert( status2 <= UINTMAX_MAX );
+  
+  printf( "status = %ju \n", status2 );
+  
+  /*Test for wcstoimax  */
+  puts( "Wcstoimax Testcases...." );
+  puts( "Generating Status" );
+  status1 = wcstoimax( nptr2, &endptr2, base );
+  
+  rtems_test_assert( status1 != 0); 
+  rtems_test_assert( base != EINVAL);
+  
+  puts( "Checking Garbage end of endptr" );  
+  rtems_test_assert( *endptr2 != '\0' );
+  
+  puts( "Checking Underflow Case" );
+  rtems_test_assert( status1 >= INTMAX_MIN );
+  
+  puts( "Checking Overflow Case" );
+  rtems_test_assert( status1 <= INTMAX_MAX ) ;
+  
+  printf( "status = %jd \n", status1 );
+
+  /*Test for wcstoumax  */
+  puts( "wcstoumax Testcases...." );
+  puts( "Generating Status" );
+  status2 = wcstoumax( nptr2, &endptr2, base );
+  
+  rtems_test_assert( status2 != 0); 
+  rtems_test_assert( base != EINVAL);
+
+  puts( "Checking Garbage end of endptr" );  
+  rtems_test_assert( *endptr2 != '\0' );
+  
+  puts( "Checking Overflow Case" );
+  rtems_test_assert( status2 <= UINTMAX_MAX );
+  
+  printf( "status = %ju \n", status2 );
+  
+ 
+  TEST_END();
+  rtems_test_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..72640b4
--- /dev/null
+++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
@@ -0,0 +1,28 @@
+*** BEGIN OF TEST PSXINTTYPE 01 ***
+Checking invalid base value
+Strtoimax Testcases....
+Generating Status
+Checking Garbage end of endptr
+Checking Underflow Case
+Checking Overflow Case
+status = 123 
+Strtoumax Testcases....
+Generating Status
+Checking Garbage end of endptr
+Checking Overflow Case
+status = 123 
+Wcstoimax Testcases....
+Generating Status
+Checking Garbage end of endptr
+Checking Underflow Case
+Checking Overflow Case
+status = -123 
+wcstoumax Testcases....
+Generating Status
+Checking Garbage end of endptr
+Checking Overflow Case
+status = 18446744073709551493 
+
+*** END OF TEST PSXINTTYPE 01 ***
+
+
-- 
2.7.4



More information about the devel mailing list