[PATCH] Add Test suite for inttypes.h (psxinttypes.exe) in testsuites/psxtests
VARoDeK
vaibhavgupta40 at gmail.com
Thu May 30 15:17:18 UTC 2019
---
testsuites/psxtests/Makefile.am | 7 +
testsuites/psxtests/configure.ac | 1 +
testsuites/psxtests/psxinttypes01/init.c | 154 ++++++++++++++++++
.../psxtests/psxinttypes01/psxinttypes01.doc | 57 +++++++
.../psxtests/psxinttypes01/psxinttypes01.scn | 28 ++++
5 files changed, 247 insertions(+)
create mode 100644 testsuites/psxtests/psxinttypes01/init.c
create mode 100644 testsuites/psxtests/psxinttypes01/psxinttypes01.doc
create mode 100644 testsuites/psxtests/psxinttypes01/psxinttypes01.scn
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 749258cc0c..f619dd9ae9 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -22,6 +22,13 @@ psx01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psx01) \
$(support_includes) -I$(top_srcdir)/include
endif
+if TEST_psxinttypes01
+psx_tests += psxinttypes01
+psxinttypes01_SOURCES = psxinttypes01/init.c
+psxinttypes01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxinttypes01) \
+ $(support_includes)
+endif
+
if HAS_POSIX
if TEST_psx02
psx_tests += psx02
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index cdd6ee7e4e..e032a6f5ec 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -140,6 +140,7 @@ RTEMS_TEST_CHECK([psxtimes01])
RTEMS_TEST_CHECK([psxualarm])
RTEMS_TEST_CHECK([psxusleep])
RTEMS_TEST_CHECK([lib_a])
+RTEMS_TEST_CHECK([psxinttypes01])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/testsuites/psxtests/psxinttypes01/init.c b/testsuites/psxtests/psxinttypes01/init.c
new file mode 100644
index 0000000000..1c6340afe2
--- /dev/null
+++ b/testsuites/psxtests/psxinttypes01/init.c
@@ -0,0 +1,154 @@
+/**
+ * @file
+ * @brief Test suite for inttypes.h methods
+ */
+
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2019, Vaibhav Gupta
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#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.doc b/testsuites/psxtests/psxinttypes01/psxinttypes01.doc
new file mode 100644
index 0000000000..f9e0951786
--- /dev/null
+++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.doc
@@ -0,0 +1,57 @@
+/**
+ * @file
+ * @brief Doc for Test suite for inttypes.h methods
+ */
+
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2019, Vaibhav Gupta
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+This File describes the concepts tested by this test suite.
+
+inttypes.h - fixed size integer types
+
+test suite name: PSXINTTYPE 01
+
+- Checks for invalid base value
+
+- Checks for Strtoimax Testcases
+ - checks for Garbage end of endptr
+ - checks for Underflow Case
+ - checks for Overflow Case
+
+- Checks for Strtoumax Test Cases
+ - checks for Garbage end of endptr
+ - checks for Overflow Case
+
+- Checks for Wcstoimax Testcases
+ - checks for Garbage end of endptr
+ - checks for Underflow Case
+ - checks for Overflow Case
+
+- Checks for Wcstoumax Testcases
+ - checks for Garbage end of endptr
+ - checks for Overflow Case
diff --git a/testsuites/psxtests/psxinttypes01/psxinttypes01.scn b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
new file mode 100644
index 0000000000..cdd56b327d
--- /dev/null
+++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
@@ -0,0 +1,28 @@
+*** PSXINTTYPE 01 TEST ***
+
+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 PSXINTTYPE 01 TEST ***
+
--
2.21.0
More information about the devel
mailing list