[PATCH 1/2] testsuites: added compile tests for new APIs

Matt Joyce mfjoyce2004 at gmail.com
Fri Aug 6 13:42:14 UTC 2021


Added compile only tests for new POSIX standard APIs
pthread_rwlock_clockrdlock() and
pthread_rwlock_clockwrlock() in
testsuites/psxtests/psxhdrs/pthread
---
 spec/build/testsuites/psxtests/libpsxhdrs.yml |  2 +
 .../pthread/pthread_rwlock_clockrdlock.c      | 59 +++++++++++++++++++
 .../pthread/pthread_rwlock_clockwrlock.c      | 59 +++++++++++++++++++
 3 files changed, 120 insertions(+)
 create mode 100644 testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockrdlock.c
 create mode 100644 testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockwrlock.c

diff --git a/spec/build/testsuites/psxtests/libpsxhdrs.yml b/spec/build/testsuites/psxtests/libpsxhdrs.yml
index 6a0ab6d4f7..5e9f808db5 100644
--- a/spec/build/testsuites/psxtests/libpsxhdrs.yml
+++ b/spec/build/testsuites/psxtests/libpsxhdrs.yml
@@ -464,6 +464,8 @@ source:
 - testsuites/psxtests/psxhdrs/pthread/pthread_mutexattr_setprotocol.c
 - testsuites/psxtests/psxhdrs/pthread/pthread_mutexattr_setpshared.c
 - testsuites/psxtests/psxhdrs/pthread/pthread_once.c
+- testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockrdlock.c
+- testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockwrlock.c
 - testsuites/psxtests/psxhdrs/pthread/pthread_self.c
 - testsuites/psxtests/psxhdrs/pthread/pthread_setcancelstate.c
 - testsuites/psxtests/psxhdrs/pthread/pthread_setcanceltype.c
diff --git a/testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockrdlock.c b/testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockrdlock.c
new file mode 100644
index 0000000000..d21919e688
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockrdlock.c
@@ -0,0 +1,59 @@
+/*
+* @file
+* @brief pthread_rwlock_clockrdlock() API Conformance Test
+*/
+
+/* 
+* Copyright (C) 2021 Matthew Joyce
+*
+* 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 <pthread.h>
+
+#ifndef _POSIX_THREADS
+#error "rtems is supposed to have pthread_rwlock_clockrdlock"
+#endif
+#ifndef _POSIX_TIMEOUTS
+#error "rtems is supposed to have pthread_rwlock_clockrdlock"
+#endif
+#ifndef _POSIX_READER_WRITER_LOCKS
+#error "rtems is supposed to have pthread_rwlock_clockrdlock"
+#endif
+
+int test( void );
+
+int test( void )
+{
+  pthread_rwlock_t      rwlock = PTHREAD_RWLOCK_INITIALIZER;
+  clockid_t             clock_id = CLOCK_REALTIME;
+  const struct timespec abstime;
+  int result2;
+
+  result2 = pthread_rwlock_clockrdlock( &rwlock, clock_id, &abstime );
+
+  return result2;
+}
diff --git a/testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockwrlock.c b/testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockwrlock.c
new file mode 100644
index 0000000000..b081d1db56
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/pthread/pthread_rwlock_clockwrlock.c
@@ -0,0 +1,59 @@
+/*
+* @file
+* @brief pthread_rwlock_clockwrlock() API Conformance Test
+*/
+
+/* 
+* Copyright (C) 2021 Matthew Joyce
+*
+* 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 <pthread.h>
+
+#ifndef _POSIX_THREADS
+#error "rtems is supposed to have pthread_rwlock_clockwrlock"
+#endif
+#ifndef _POSIX_TIMEOUTS
+#error "rtems is supposed to have pthread_rwlock_clockwrlock"
+#endif
+#ifndef _POSIX_READER_WRITER_LOCKS
+#error "rtems is supposed to have pthread_rwlock_clockwrlock"
+#endif
+
+int test( void );
+
+int test( void )
+{
+  pthread_rwlock_t      rwlock = PTHREAD_RWLOCK_INITIALIZER;
+  clockid_t             clock_id = CLOCK_REALTIME;
+  const struct timespec abstime;
+  int result;
+
+  result = pthread_rwlock_clockwrlock( &rwlock, clock_id, &abstime );
+
+  return result;
+}
-- 
2.31.1



More information about the devel mailing list