mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
Implement POSIX API Signature Compliance Tests for inttypes.h
This work was part of GCI 2018
This commit is contained in:
committed by
Joel Sherrill
parent
9feff789be
commit
bf763d3eee
@@ -1573,7 +1573,14 @@ lib_a_SOURCES = psxhdrs/devctl/posix_devctl.c \
|
||||
psxhdrs/wctype/wctrans.c \
|
||||
psxhdrs/wctype/wctrans_l.c \
|
||||
psxhdrs/wctype/wctype.c \
|
||||
psxhdrs/wctype/wctype_l.c
|
||||
psxhdrs/wctype/wctype_l.c \
|
||||
psxhdrs/inttypes/imaxabs.c \
|
||||
psxhdrs/inttypes/imaxdiv.c \
|
||||
psxhdrs/inttypes/strtoimax.c \
|
||||
psxhdrs/inttypes/strtoumax.c \
|
||||
psxhdrs/inttypes/wcstoimax.c \
|
||||
psxhdrs/inttypes/wcstoumax.c
|
||||
|
||||
|
||||
## Not supported by RTEMS, but POSIX API Compliance tests exist.
|
||||
## lib_a_SOURCES += psxhdrs/ulimit/ulimit.c
|
||||
|
||||
38
testsuites/psxtests/psxhdrs/inttypes/imaxabs.c
Normal file
38
testsuites/psxtests/psxhdrs/inttypes/imaxabs.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief imaxabs() API Conformance Test
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2018.
|
||||
* Marçal Comajoan Cara
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software
|
||||
* for any purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
int test( void );
|
||||
|
||||
int test( void )
|
||||
{
|
||||
intmax_t n = -42;
|
||||
intmax_t result;
|
||||
|
||||
result = imaxabs( n );
|
||||
|
||||
return ( result == 42 );
|
||||
}
|
||||
39
testsuites/psxtests/psxhdrs/inttypes/imaxdiv.c
Normal file
39
testsuites/psxtests/psxhdrs/inttypes/imaxdiv.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief imaxdiv() API Conformance Test
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2018.
|
||||
* Marçal Comajoan Cara
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software
|
||||
* for any purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
int test( void );
|
||||
|
||||
int test( void )
|
||||
{
|
||||
intmax_t n = 42;
|
||||
intmax_t denom = 5;
|
||||
imaxdiv_t result;
|
||||
|
||||
result = imaxdiv( n, denom );
|
||||
|
||||
return ( result.quot == 8 && result.rem == 2 );
|
||||
}
|
||||
39
testsuites/psxtests/psxhdrs/inttypes/strtoimax.c
Normal file
39
testsuites/psxtests/psxhdrs/inttypes/strtoimax.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief strtoimax() API Conformance Test
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2018.
|
||||
* Marçal Comajoan Cara
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software
|
||||
* for any purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
int test( void );
|
||||
|
||||
int test( void )
|
||||
{
|
||||
char *n = "-42";
|
||||
intmax_t result;
|
||||
char *endptr;
|
||||
|
||||
result = strtoimax( n, &endptr, 10 );
|
||||
|
||||
return ( result == -42 );
|
||||
}
|
||||
39
testsuites/psxtests/psxhdrs/inttypes/strtoumax.c
Normal file
39
testsuites/psxtests/psxhdrs/inttypes/strtoumax.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief strtoumax() API Conformance Test
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2018.
|
||||
* Marçal Comajoan Cara
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software
|
||||
* for any purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
int test( void );
|
||||
|
||||
int test( void )
|
||||
{
|
||||
char *n = "42";
|
||||
uintmax_t result;
|
||||
char *endptr;
|
||||
|
||||
result = strtoumax( n, &endptr, 10 );
|
||||
|
||||
return ( result == 42 );
|
||||
}
|
||||
40
testsuites/psxtests/psxhdrs/inttypes/wcstoimax.c
Normal file
40
testsuites/psxtests/psxhdrs/inttypes/wcstoimax.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief wcstoimax() API Conformance Test
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2018.
|
||||
* Marçal Comajoan Cara
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software
|
||||
* for any purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int test( void );
|
||||
|
||||
int test( void )
|
||||
{
|
||||
wchar_t *n = L"-42";
|
||||
intmax_t result;
|
||||
wchar_t *endptr;
|
||||
|
||||
result = wcstoimax( n, &endptr, 10 );
|
||||
|
||||
return ( result == -42 );
|
||||
}
|
||||
40
testsuites/psxtests/psxhdrs/inttypes/wcstoumax.c
Normal file
40
testsuites/psxtests/psxhdrs/inttypes/wcstoumax.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief wcstoumax() API Conformance Test
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2018.
|
||||
* Marçal Comajoan Cara
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software
|
||||
* for any purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int test( void );
|
||||
|
||||
int test( void )
|
||||
{
|
||||
wchar_t *n = L"42";
|
||||
uintmax_t result;
|
||||
wchar_t *endptr;
|
||||
|
||||
result = wcstoumax( n, &endptr, 10 );
|
||||
|
||||
return ( result == 42 );
|
||||
}
|
||||
Reference in New Issue
Block a user