From e3086c9c5af3c5d46da12b6e9796d2f209114bf8 Mon Sep 17 00:00:00 2001 From: Himanshu40 Date: Sat, 1 Dec 2018 23:23:06 +0530 Subject: psxhdrs: add POSIX API signature tests for strings.h file (GCI 2018) --- testsuites/psxtests/Makefile.am | 11 +++++- testsuites/psxtests/psxhdrs/strings/bcmp.c | 36 +++++++++++++++++++ testsuites/psxtests/psxhdrs/strings/bcopy.c | 40 +++++++++++++++++++++ testsuites/psxtests/psxhdrs/strings/ffs.c | 39 ++++++++++++++++++++ testsuites/psxtests/psxhdrs/strings/index.c | 41 ++++++++++++++++++++++ testsuites/psxtests/psxhdrs/strings/rindex.c | 41 ++++++++++++++++++++++ testsuites/psxtests/psxhdrs/strings/strcasecmp.c | 38 ++++++++++++++++++++ testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c | 39 ++++++++++++++++++++ testsuites/psxtests/psxhdrs/strings/strncasecmp.c | 38 ++++++++++++++++++++ .../psxtests/psxhdrs/strings/strncasecmp_l.c | 39 ++++++++++++++++++++ 10 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 testsuites/psxtests/psxhdrs/strings/bcmp.c create mode 100644 testsuites/psxtests/psxhdrs/strings/bcopy.c create mode 100644 testsuites/psxtests/psxhdrs/strings/ffs.c create mode 100644 testsuites/psxtests/psxhdrs/strings/index.c create mode 100644 testsuites/psxtests/psxhdrs/strings/rindex.c create mode 100644 testsuites/psxtests/psxhdrs/strings/strcasecmp.c create mode 100644 testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c create mode 100644 testsuites/psxtests/psxhdrs/strings/strncasecmp.c create mode 100644 testsuites/psxtests/psxhdrs/strings/strncasecmp_l.c diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 553b259245..d40df4cf55 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -1113,7 +1113,16 @@ lib_a_SOURCES = psxhdrs/devctl/posix_devctl.c \ psxhdrs/semaphore/sem_post.c \ psxhdrs/semaphore/sem_wait.c \ psxhdrs/semaphore/sem_trywait.c \ - psxhdrs/semaphore/sem_timedwait.c + psxhdrs/semaphore/sem_timedwait.c \ + psxhdrs/strings/bcmp.c \ + psxhdrs/strings/bcopy.c \ + psxhdrs/strings/ffs.c \ + psxhdrs/strings/index.c \ + psxhdrs/strings/rindex.c \ + psxhdrs/strings/strcasecmp.c \ + psxhdrs/strings/strcasecmp_l.c \ + psxhdrs/strings/strncasecmp.c \ + psxhdrs/strings/strncasecmp_l.c endif rtems_tests_PROGRAMS = $(psx_tests) diff --git a/testsuites/psxtests/psxhdrs/strings/bcmp.c b/testsuites/psxtests/psxhdrs/strings/bcmp.c new file mode 100644 index 0000000000..0e95a694f9 --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/bcmp.c @@ -0,0 +1,36 @@ +/** + * @file + * @brief bcmp() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + + int test( void ); + + int test( void ) + { + int result; + + result = bcmp( "Hello there", "Hello world", 6 ); + + return result; + } diff --git a/testsuites/psxtests/psxhdrs/strings/bcopy.c b/testsuites/psxtests/psxhdrs/strings/bcopy.c new file mode 100644 index 0000000000..0a54f5a801 --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/bcopy.c @@ -0,0 +1,40 @@ +/** + * @file + * @brief bcopy() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + + int test( void ); + + int result = 1; + + int test( void ) + { + auto char buffer[50]; + + bcopy( "Hello ", buffer, 6 ); + bcopy( "world", &buffer[6], 6 ); + result = 0; + + return result; + } diff --git a/testsuites/psxtests/psxhdrs/strings/ffs.c b/testsuites/psxtests/psxhdrs/strings/ffs.c new file mode 100644 index 0000000000..e4b212d9f5 --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/ffs.c @@ -0,0 +1,39 @@ +/** + * @file + * @brief ffs() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + + int test( void ); + + int test( void ) + { + int i; + int result; + + i = 64; + + result = ffs( i ); + + return result; + } diff --git a/testsuites/psxtests/psxhdrs/strings/index.c b/testsuites/psxtests/psxhdrs/strings/index.c new file mode 100644 index 0000000000..b4dbc32aaf --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/index.c @@ -0,0 +1,41 @@ +/** + * @file + * @brief index() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + + int test( void ); + + int result = 1; + + int test( void ) + { + char *p; + char *string = "This is a string for testing"; + + p = index( string, 'i' ); + (void) p; + result = 0; + + return result; + } diff --git a/testsuites/psxtests/psxhdrs/strings/rindex.c b/testsuites/psxtests/psxhdrs/strings/rindex.c new file mode 100644 index 0000000000..220a6553d4 --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/rindex.c @@ -0,0 +1,41 @@ +/** + * @file + * @brief rindex() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + + int test( void ); + + int result = 1; + + int test( void ) + { + char *p; + char *string = "This is a string for testing"; + + p = rindex( string, 'i' ); + (void) p; + result = 0; + + return result; + } diff --git a/testsuites/psxtests/psxhdrs/strings/strcasecmp.c b/testsuites/psxtests/psxhdrs/strings/strcasecmp.c new file mode 100644 index 0000000000..3ed4b511e7 --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/strcasecmp.c @@ -0,0 +1,38 @@ +/** + * @file + * @brief strcasecmp() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + + int test( void ); + + int test( void ) + { + char *string1 = "STRING"; + char *string2 = "string"; + int result; + + result = strcasecmp( string1, string2 ); + + return result; + } diff --git a/testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c b/testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c new file mode 100644 index 0000000000..cdcdff7de2 --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/strcasecmp_l.c @@ -0,0 +1,39 @@ +/** + * @file + * @brief strcasecmp_l() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + #include + + int test( void ); + + int test( void ) + { + char *string1 = "STRING"; + char *string2 = "string"; + int result; + + result = strcasecmp_l( string1, string2, LC_CTYPE ); + + return result; + } diff --git a/testsuites/psxtests/psxhdrs/strings/strncasecmp.c b/testsuites/psxtests/psxhdrs/strings/strncasecmp.c new file mode 100644 index 0000000000..26899f73a7 --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/strncasecmp.c @@ -0,0 +1,38 @@ +/** + * @file + * @brief strncasecmp() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + + int test( void ); + + int test( void ) + { + char *string1 = "STRING ONE"; + char *string2 = "string TWO"; + int result; + + result = strncasecmp( string1, string2, 6 ); + + return result; + } diff --git a/testsuites/psxtests/psxhdrs/strings/strncasecmp_l.c b/testsuites/psxtests/psxhdrs/strings/strncasecmp_l.c new file mode 100644 index 0000000000..9b0792fda5 --- /dev/null +++ b/testsuites/psxtests/psxhdrs/strings/strncasecmp_l.c @@ -0,0 +1,39 @@ +/** + * @file + * @brief strcasecmp_l() API Conformance Test + */ +/* + * COPYRIGHT (c) 2018. + * Himanshu Sekhar Nayak + * + * 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 + #include + + int test( void ); + + int test( void ) + { + char *string1 = "STRING"; + char *string2 = "string"; + int result; + + result = strncasecmp_l( string1, string2, 6, LC_CTYPE ); + + return result; + } -- cgit v1.2.3