[rtems commit] psxtests : Add POSIX API Signature Compliance Tests for semaphore.h (GCI 2018)
Joel Sherrill
joel at rtems.org
Thu Nov 29 17:21:56 UTC 2018
Module: rtems
Branch: master
Commit: 7ea4c0260468c33dcca163626838d517f040b5d5
Changeset: http://git.rtems.org/rtems/commit/?id=7ea4c0260468c33dcca163626838d517f040b5d5
Author: Himanshu40 <himanshuwindows8.1 at gmail.com>
Date: Thu Nov 29 22:51:19 2018 +0530
psxtests : Add POSIX API Signature Compliance Tests for semaphore.h (GCI 2018)
---
testsuites/psxtests/Makefile.am | 12 +++++-
testsuites/psxtests/psxhdrs/semaphore/sem_close.c | 45 ++++++++++++++++++++
.../psxtests/psxhdrs/semaphore/sem_destroy.c | 45 ++++++++++++++++++++
.../psxtests/psxhdrs/semaphore/sem_getvalue.c | 46 ++++++++++++++++++++
testsuites/psxtests/psxhdrs/semaphore/sem_init.c | 43 +++++++++++++++++++
testsuites/psxtests/psxhdrs/semaphore/sem_open.c | 46 ++++++++++++++++++++
testsuites/psxtests/psxhdrs/semaphore/sem_post.c | 44 +++++++++++++++++++
.../psxtests/psxhdrs/semaphore/sem_timedwait.c | 49 ++++++++++++++++++++++
.../psxtests/psxhdrs/semaphore/sem_trywait.c | 44 +++++++++++++++++++
testsuites/psxtests/psxhdrs/semaphore/sem_unlink.c | 44 +++++++++++++++++++
testsuites/psxtests/psxhdrs/semaphore/sem_wait.c | 44 +++++++++++++++++++
11 files changed, 461 insertions(+), 1 deletion(-)
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 2385ec8..553b259 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -1103,7 +1103,17 @@ lib_a_SOURCES = psxhdrs/devctl/posix_devctl.c \
psxhdrs/mqueue/mq_send.c \
psxhdrs/mqueue/mq_timedreceive.c \
psxhdrs/mqueue/mq_timedsend.c \
- psxhdrs/mqueue/mq_unlink.c
+ psxhdrs/mqueue/mq_unlink.c \
+ psxhdrs/semaphore/sem_init.c \
+ psxhdrs/semaphore/sem_destroy.c \
+ psxhdrs/semaphore/sem_open.c \
+ psxhdrs/semaphore/sem_close.c \
+ psxhdrs/semaphore/sem_getvalue.c \
+ psxhdrs/semaphore/sem_unlink.c \
+ psxhdrs/semaphore/sem_post.c \
+ psxhdrs/semaphore/sem_wait.c \
+ psxhdrs/semaphore/sem_trywait.c \
+ psxhdrs/semaphore/sem_timedwait.c
endif
rtems_tests_PROGRAMS = $(psx_tests)
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_close.c b/testsuites/psxtests/psxhdrs/semaphore/sem_close.c
new file mode 100644
index 0000000..9bac9b9
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_close.c
@@ -0,0 +1,45 @@
+/**
+ * @file
+ * @brief sem_close() 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 <fcntl.h>
+ #include <sys/stat.h>
+ #include <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t *sem1;
+ int oflag = O_CREAT;
+ int result;
+ int value;
+
+ value = 1;
+
+ sem1 = sem_open( "sem", oflag, 0777, value );
+ result = sem_close( sem1 );
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_destroy.c b/testsuites/psxtests/psxhdrs/semaphore/sem_destroy.c
new file mode 100644
index 0000000..13599ca
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_destroy.c
@@ -0,0 +1,45 @@
+/**
+ * @file
+ * @brief sem_destroy() 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 <fcntl.h>
+ #include <sys/stat.h>
+ #include <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t *sem1;
+ int oflag = O_CREAT;
+ int result;
+ int value;
+
+ value = 1;
+
+ sem1 = sem_open( "sem", oflag, 0777, value );
+ result = sem_destroy( sem1 );
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_getvalue.c b/testsuites/psxtests/psxhdrs/semaphore/sem_getvalue.c
new file mode 100644
index 0000000..1aefeaf
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_getvalue.c
@@ -0,0 +1,46 @@
+/**
+ * @file
+ * @brief sem_getval() 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 <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t sem;
+ int pshared;
+ unsigned int value;
+ int sval;
+ int result;
+
+ pshared = 0;
+ value = 1;
+ sval = 1;
+
+ sem_init( &sem, pshared, value );
+ result = sem_getvalue( &sem, &sval );
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_init.c b/testsuites/psxtests/psxhdrs/semaphore/sem_init.c
new file mode 100644
index 0000000..0f8c771
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_init.c
@@ -0,0 +1,43 @@
+/**
+ * @file
+ * @brief sem_init() 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 <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t sem;
+ int pshared;
+ unsigned int value;
+ int result;
+
+ pshared = 0;
+ value = 1;
+
+ result = sem_init( &sem, pshared, value );
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_open.c b/testsuites/psxtests/psxhdrs/semaphore/sem_open.c
new file mode 100644
index 0000000..d3b63d5
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_open.c
@@ -0,0 +1,46 @@
+/**
+ * @file
+ * @brief sem_open() 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 <fcntl.h>
+ #include <sys/stat.h>
+ #include <semaphore.h>
+
+ int test( void );
+
+ int result = 1;
+
+ int test( void )
+ {
+ sem_t *sem1;
+ int oflag = O_CREAT;
+ unsigned int value;
+
+ value = 1;
+
+ sem1 = sem_open( "sem", oflag, 0777, value );
+ (void) sem1;
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_post.c b/testsuites/psxtests/psxhdrs/semaphore/sem_post.c
new file mode 100644
index 0000000..5612c70
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_post.c
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * @brief sem_post() 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 <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t sem;
+ int pshared;
+ unsigned int value;
+ int result;
+
+ pshared = 0;
+ value = 1;
+
+ sem_init( &sem, pshared, value );
+ result = sem_post( &sem );
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_timedwait.c b/testsuites/psxtests/psxhdrs/semaphore/sem_timedwait.c
new file mode 100644
index 0000000..9a1827a
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_timedwait.c
@@ -0,0 +1,49 @@
+/**
+ * @file
+ * @brief sem_timedwait() 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 <fcntl.h>
+ #include <time.h>
+ #include <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t sem;
+ struct timespec abs_timeout;
+ int pshared;
+ unsigned int value;
+ int result;
+
+ pshared = 0;
+ value = 1;
+ abs_timeout.tv_sec = 0;
+ abs_timeout.tv_nsec = 0;
+
+ sem_init( &sem, pshared, value );
+ result = sem_timedwait( &sem, &abs_timeout );
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_trywait.c b/testsuites/psxtests/psxhdrs/semaphore/sem_trywait.c
new file mode 100644
index 0000000..25486fb
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_trywait.c
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * @brief sem_trywait() 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 <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t sem;
+ int pshared;
+ unsigned int value;
+ int result;
+
+ pshared = 0;
+ value = 1;
+
+ sem_init( &sem, pshared, value );
+ result = sem_trywait( &sem );
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_unlink.c b/testsuites/psxtests/psxhdrs/semaphore/sem_unlink.c
new file mode 100644
index 0000000..8f4619a
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_unlink.c
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * @brief sem_unlink() 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 <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t sem;
+ int pshared;
+ unsigned int value;
+ int result;
+
+ pshared = 0;
+ value = 1;
+
+ sem_init( &sem, pshared, value );
+ result = sem_unlink( "sem" );
+
+ return result;
+ }
diff --git a/testsuites/psxtests/psxhdrs/semaphore/sem_wait.c b/testsuites/psxtests/psxhdrs/semaphore/sem_wait.c
new file mode 100644
index 0000000..03d77cf
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/semaphore/sem_wait.c
@@ -0,0 +1,44 @@
+/**
+ * @file
+ * @brief sem_wait() 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 <semaphore.h>
+
+ int test( void );
+
+ int test( void )
+ {
+ sem_t sem;
+ int pshared;
+ unsigned int value;
+ int result;
+
+ pshared = 0;
+ value = 1;
+
+ sem_init( &sem, pshared, value );
+ result = sem_wait( &sem );
+
+ return result;
+ }
More information about the vc
mailing list