[PATCH 14/14] posix: Enable more sptests test cases by default

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Oct 29 09:03:23 UTC 2018


Update #2514.
---
 testsuites/sptests/spmutex01/init.c      | 58 +++++++++-----------------------
 testsuites/sptests/spstdthreads01/init.c |  7 ----
 testsuites/sptests/spsysinit01/init.c    | 35 ++++++-------------
 testsuites/sptests/spthreadq01/init.c    | 31 +++++------------
 4 files changed, 35 insertions(+), 96 deletions(-)

diff --git a/testsuites/sptests/spmutex01/init.c b/testsuites/sptests/spmutex01/init.c
index fa5e716bd8..0bd67436b3 100644
--- a/testsuites/sptests/spmutex01/init.c
+++ b/testsuites/sptests/spmutex01/init.c
@@ -16,17 +16,14 @@
   #include "config.h"
 #endif
 
-#include <threads.h>
+#include <errno.h>
+#include <pthread.h>
 #include <setjmp.h>
+#include <threads.h>
 
 #include <rtems.h>
 #include <rtems/libcsupport.h>
 
-#ifdef RTEMS_POSIX_API
-#include <errno.h>
-#include <pthread.h>
-#endif
-
 #include "tmacros.h"
 
 const char rtems_test_name[] = "SPMUTEX 1";
@@ -70,9 +67,7 @@ typedef enum {
 typedef struct {
   rtems_id mtx[MTX_COUNT];
   mtx_t mtx_c11;
-#ifdef RTEMS_POSIX_API
   pthread_mutex_t mtx_posix;
-#endif
   rtems_id tasks[TASK_COUNT];
   int generation[TASK_COUNT];
   int expected_generation[TASK_COUNT];
@@ -222,7 +217,6 @@ static void release_c11(test_context *ctx)
   rtems_test_assert(status == thrd_success);
 }
 
-#ifdef RTEMS_POSIX_API
 static void obtain_posix(test_context *ctx)
 {
   int error;
@@ -246,7 +240,6 @@ static void release_posix(test_context *ctx)
   error = pthread_mutex_unlock(&ctx->mtx_posix);
   rtems_test_assert(error == 0);
 }
-#endif
 
 static void check_generations(test_context *ctx, task_id a, task_id b)
 {
@@ -368,7 +361,6 @@ static void worker(rtems_task_argument arg)
       ++ctx->generation[id];
     }
 
-#ifdef RTEMS_POSIX_API
     if ((events & REQ_MTX_POSIX_OBTAIN) != 0) {
       obtain_posix(ctx);
       ++ctx->generation[id];
@@ -378,7 +370,6 @@ static void worker(rtems_task_argument arg)
       release_posix(ctx);
       ++ctx->generation[id];
     }
-#endif
   }
 }
 
@@ -387,6 +378,8 @@ static void set_up(test_context *ctx)
   rtems_status_code sc;
   int status;
   size_t i;
+  int error;
+  pthread_mutexattr_t attr;
 
   ctx->tasks[M] = rtems_task_self();
   start_task(ctx, A_1, worker, 1);
@@ -408,24 +401,17 @@ static void set_up(test_context *ctx)
   status = mtx_init(&ctx->mtx_c11, mtx_plain);
   rtems_test_assert(status == thrd_success);
 
-#ifdef RTEMS_POSIX_API
-  {
-    int error;
-    pthread_mutexattr_t attr;
-
-    error = pthread_mutexattr_init(&attr);
-    rtems_test_assert(error == 0);
+  error = pthread_mutexattr_init(&attr);
+  rtems_test_assert(error == 0);
 
-    error = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
-    rtems_test_assert(error == 0);
+  error = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
+  rtems_test_assert(error == 0);
 
-    error = pthread_mutex_init(&ctx->mtx_posix, &attr);
-    rtems_test_assert(error == 0);
+  error = pthread_mutex_init(&ctx->mtx_posix, &attr);
+  rtems_test_assert(error == 0);
 
-    error = pthread_mutexattr_destroy(&attr);
-    rtems_test_assert(error == 0);
-  }
-#endif
+  error = pthread_mutexattr_destroy(&attr);
+  rtems_test_assert(error == 0);
 }
 
 static void test_inherit(test_context *ctx)
@@ -634,7 +620,6 @@ static void test_deadlock_classic_and_c11(test_context *ctx)
 
 static void test_deadlock_posix_and_classic(test_context *ctx)
 {
-#ifdef RTEMS_POSIX_API
   obtain_posix(ctx);
   request(ctx, A_1, REQ_MTX_0_OBTAIN);
   check_generations(ctx, A_1, NONE);
@@ -647,12 +632,10 @@ static void test_deadlock_posix_and_classic(test_context *ctx)
   check_generations(ctx, A_1, NONE);
   request(ctx, A_1, REQ_MTX_0_RELEASE);
   check_generations(ctx, A_1, NONE);
-#endif
 }
 
 static void test_deadlock_classic_and_posix(test_context *ctx)
 {
-#ifdef RTEMS_POSIX_API
   obtain(ctx, MTX_0);
   request(ctx, A_1, REQ_MTX_POSIX_OBTAIN);
   check_generations(ctx, A_1, NONE);
@@ -665,13 +648,13 @@ static void test_deadlock_classic_and_posix(test_context *ctx)
   check_generations(ctx, A_1, NONE);
   request(ctx, A_1, REQ_MTX_POSIX_RELEASE);
   check_generations(ctx, A_1, NONE);
-#endif
 }
 
 static void tear_down(test_context *ctx)
 {
   rtems_status_code sc;
   size_t i;
+  int error;
 
   for (i = 1; i < TASK_COUNT; ++i) {
     sc = rtems_task_delete(ctx->tasks[i]);
@@ -685,14 +668,8 @@ static void tear_down(test_context *ctx)
 
   mtx_destroy(&ctx->mtx_c11);
 
-#ifdef RTEMS_POSIX_API
-  {
-    int error;
-
-    error = pthread_mutex_destroy(&ctx->mtx_posix);
-    rtems_test_assert(error == 0);
-  }
-#endif
+  error = pthread_mutex_destroy(&ctx->mtx_posix);
+  rtems_test_assert(error == 0);
 }
 
 static void Init(rtems_task_argument arg)
@@ -748,9 +725,6 @@ static void fatal_extension(
 
 #define CONFIGURE_MAXIMUM_SEMAPHORES 3
 
-#ifdef RTEMS_POSIX_API
-#endif
-
 #define CONFIGURE_INITIAL_EXTENSIONS \
   { .fatal = fatal_extension }, \
   RTEMS_TEST_INITIAL_EXTENSION
diff --git a/testsuites/sptests/spstdthreads01/init.c b/testsuites/sptests/spstdthreads01/init.c
index 5b4538b40a..862542b1f2 100644
--- a/testsuites/sptests/spstdthreads01/init.c
+++ b/testsuites/sptests/spstdthreads01/init.c
@@ -244,16 +244,13 @@ static void test_tss(test_context *ctx)
   tss_delete(ctx->tss);
 }
 
-#if defined(RTEMS_POSIX_API)
 static int thrd(void *arg)
 {
   thrd_exit(123);
 }
-#endif
 
 static void test_thrd(test_context *ctx)
 {
-#if defined(RTEMS_POSIX_API)
   thrd_start_t thrd_start = thrd;
   int status;
   int exit_status;
@@ -292,7 +289,6 @@ static void test_thrd(test_context *ctx)
 
   status = thrd_detach(11235);
   rtems_test_assert(status == thrd_error);
-#endif
 }
 
 static void high_task(rtems_task_argument idx)
@@ -417,10 +413,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_MAXIMUM_POSIX_KEYS 1
 #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 1
-
-#if defined(RTEMS_POSIX_API)
 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1
-#endif
 
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
 
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index b9521b950f..00d07fb18a 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -33,15 +33,17 @@
 #include <rtems/sysinit.h>
 
 #include <rtems/extensionimpl.h>
-#ifdef RTEMS_POSIX_API
 #include <rtems/posix/barrierimpl.h>
 #include <rtems/posix/mqueueimpl.h>
 #include <rtems/posix/muteximpl.h>
+#ifdef RTEMS_POSIX_API
 #include <rtems/posix/psignalimpl.h>
+#endif /* RTEMS_POSIX_API */
 #include <rtems/posix/pthreadimpl.h>
 #include <rtems/posix/rwlockimpl.h>
 #include <rtems/posix/semaphoreimpl.h>
 #include <rtems/posix/shmimpl.h>
+#ifdef RTEMS_POSIX_API
 #include <rtems/posix/timerimpl.h>
 #endif /* RTEMS_POSIX_API */
 #include <rtems/posix/keyimpl.h>
@@ -100,23 +102,23 @@ typedef enum {
 #ifdef RTEMS_POSIX_API
   POSIX_SIGNALS_PRE,
   POSIX_SIGNALS_POST,
+#endif /* RTEMS_POSIX_API */
   POSIX_THREADS_PRE,
   POSIX_THREADS_POST,
   POSIX_MESSAGE_QUEUE_PRE,
   POSIX_MESSAGE_QUEUE_POST,
   POSIX_SEMAPHORE_PRE,
   POSIX_SEMAPHORE_POST,
+#ifdef RTEMS_POSIX_API
   POSIX_TIMER_PRE,
   POSIX_TIMER_POST,
+#endif /* RTEMS_POSIX_API */
   POSIX_SHM_PRE,
   POSIX_SHM_POST,
-#endif /* RTEMS_POSIX_API */
   POSIX_KEYS_PRE,
   POSIX_KEYS_POST,
-#ifdef RTEMS_POSIX_API
   POSIX_CLEANUP_PRE,
   POSIX_CLEANUP_POST,
-#endif /* RTEMS_POSIX_API */
   IDLE_THREADS_PRE,
   IDLE_THREADS_POST,
   LIBIO_PRE,
@@ -129,10 +131,8 @@ typedef enum {
   DEVICE_DRIVERS_POST,
   CLASSIC_USER_TASKS_PRE,
   CLASSIC_USER_TASKS_POST,
-#ifdef RTEMS_POSIX_API
   POSIX_USER_THREADS_PRE,
   POSIX_USER_THREADS_POST,
-#endif /* RTEMS_POSIX_API */
   STD_FILE_DESCRIPTORS_PRE,
   STD_FILE_DESCRIPTORS_POST,
   LAST_FIRST,
@@ -401,7 +401,6 @@ LAST(RTEMS_SYSINIT_CLASSIC_BARRIER)
 }
 
 #ifdef RTEMS_POSIX_API
-
 FIRST(RTEMS_SYSINIT_POSIX_SIGNALS)
 {
   assert(
@@ -425,6 +424,7 @@ LAST(RTEMS_SYSINIT_POSIX_SIGNALS)
   );
   next_step(POSIX_SIGNALS_POST);
 }
+#endif /* RTEMS_POSIX_API */
 
 FIRST(RTEMS_SYSINIT_POSIX_THREADS)
 {
@@ -462,6 +462,7 @@ LAST(RTEMS_SYSINIT_POSIX_SEMAPHORE)
   next_step(POSIX_SEMAPHORE_POST);
 }
 
+#ifdef RTEMS_POSIX_API
 FIRST(RTEMS_SYSINIT_POSIX_TIMER)
 {
   assert(_POSIX_Timer_Information.maximum == 0);
@@ -473,6 +474,7 @@ LAST(RTEMS_SYSINIT_POSIX_TIMER)
   assert(_POSIX_Timer_Information.maximum != 0);
   next_step(POSIX_TIMER_POST);
 }
+#endif /* RTEMS_POSIX_API */
 
 FIRST(RTEMS_SYSINIT_POSIX_SHM)
 {
@@ -504,8 +506,6 @@ LAST(RTEMS_SYSINIT_POSIX_CLEANUP)
   next_step(POSIX_CLEANUP_POST);
 }
 
-#endif /* RTEMS_POSIX_API */
-
 FIRST(RTEMS_SYSINIT_POSIX_KEYS)
 {
   assert(_POSIX_Keys_Information.maximum == 0);
@@ -604,8 +604,6 @@ LAST(RTEMS_SYSINIT_CLASSIC_USER_TASKS)
   next_step(CLASSIC_USER_TASKS_POST);
 }
 
-#ifdef RTEMS_POSIX_API
-
 FIRST(RTEMS_SYSINIT_POSIX_USER_THREADS)
 {
   _Objects_Allocator_lock();
@@ -622,8 +620,6 @@ LAST(RTEMS_SYSINIT_POSIX_USER_THREADS)
   next_step(POSIX_USER_THREADS_POST);
 }
 
-#endif /* RTEMS_POSIX_API */
-
 FIRST(RTEMS_SYSINIT_STD_FILE_DESCRIPTORS)
 {
   struct stat st;
@@ -659,24 +655,18 @@ LAST_STEP(LAST);
 
 static void Init(rtems_task_argument arg)
 {
-#ifdef RTEMS_POSIX_API
   pthread_cleanup_push(NULL, NULL);
   pthread_cleanup_pop(0);
-#endif /* RTEMS_POSIX_API */
   next_step(INIT_TASK);
   TEST_END();
   exit(0);
 }
 
-#ifdef RTEMS_POSIX_API
-
 static void *POSIX_Init(void *arg)
 {
   return NULL;
 }
 
-#endif /* RTEMS_POSIX_API */
-
 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
 
@@ -700,23 +690,20 @@ static void *POSIX_Init(void *arg)
 
 #define CONFIGURE_MAXIMUM_TIMERS 1
 
-#ifdef RTEMS_POSIX_API
-
 #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 1
 
-
 #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1
 
 #define CONFIGURE_MAXIMUM_POSIX_SHMS 1
 
+#ifdef RTEMS_POSIX_API
 #define CONFIGURE_MAXIMUM_POSIX_TIMERS 1
+#endif /* RTEMS_POSIX_API */
 
 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1
 
 #define CONFIGURE_POSIX_INIT_THREAD_TABLE
 
-#endif /* RTEMS_POSIX_API */
-
 #define CONFIGURE_MAXIMUM_POSIX_KEYS 1
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
diff --git a/testsuites/sptests/spthreadq01/init.c b/testsuites/sptests/spthreadq01/init.c
index 64a51bcf18..8af99408b8 100644
--- a/testsuites/sptests/spthreadq01/init.c
+++ b/testsuites/sptests/spthreadq01/init.c
@@ -19,13 +19,11 @@
 
 #include <rtems/score/threadimpl.h>
 
-#if defined(RTEMS_POSIX_API)
-  #include <fcntl.h>
-  #include <mqueue.h>
-  #include <semaphore.h>
-  #include <string.h>
-  #include <pthread.h>
-#endif
+#include <fcntl.h>
+#include <mqueue.h>
+#include <semaphore.h>
+#include <string.h>
+#include <pthread.h>
 
 const char rtems_test_name[] = "SPTHREADQ 1";
 
@@ -39,9 +37,7 @@ typedef struct {
   rtems_id mtx;
   rtems_id mq;
   rtems_id br;
-#if defined(RTEMS_POSIX_API)
   mqd_t pmq;
-#endif
 } test_context;
 
 static test_context test_instance;
@@ -111,7 +107,6 @@ static void classic_worker(test_context *ctx)
 
 static void posix_worker(test_context *ctx)
 {
-#if defined(RTEMS_POSIX_API)
   int rv;
   char buf[1];
 
@@ -121,7 +116,6 @@ static void posix_worker(test_context *ctx)
   buf[0] = 'x';
   rv = mq_send(ctx->pmq, &buf[0], sizeof(buf), 0);
   rtems_test_assert(rv == 0);
-#endif
 }
 
 static rtems_task worker(rtems_task_argument arg)
@@ -176,7 +170,6 @@ static void test_classic_init(test_context *ctx)
 
 static void test_posix_init(test_context *ctx)
 {
-#if defined(RTEMS_POSIX_API)
   struct mq_attr attr;
 
   memset(&attr, 0, sizeof(attr));
@@ -185,7 +178,6 @@ static void test_posix_init(test_context *ctx)
 
   ctx->pmq = mq_open("mq", O_CREAT | O_RDWR, 0x777, &attr);
   rtems_test_assert(ctx->mq != -1);
-#endif
 }
 
 static void test_context_init(test_context *ctx)
@@ -251,7 +243,6 @@ static void test_classic_obj(test_context *ctx)
 
 static void test_posix_obj(test_context *ctx)
 {
-#if defined(RTEMS_POSIX_API)
   char buf[1];
   unsigned prio;
   ssize_t n;
@@ -264,7 +255,6 @@ static void test_posix_obj(test_context *ctx)
   rtems_test_assert(n == (ssize_t) sizeof(buf));
   rtems_test_assert(buf[0] == 'x');
   rtems_test_assert(prio == 0);
-#endif
 }
 
 static rtems_task Init(
@@ -299,14 +289,9 @@ static rtems_task Init(
 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES  1
 #define CONFIGURE_MAXIMUM_BARRIERS  1
 
-#if defined(RTEMS_POSIX_API)
-  #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 1
-  #define CONFIGURE_MESSAGE_BUFFER_MEMORY \
-    (2 * CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(1, 1))
-#else
-  #define CONFIGURE_MESSAGE_BUFFER_MEMORY \
-    CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(1, 1)
-#endif
+#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 1
+#define CONFIGURE_MESSAGE_BUFFER_MEMORY \
+  (2 * CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(1, 1))
 
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
 
-- 
2.16.4




More information about the devel mailing list