[PATCH 10/13] tmtests: Avoid build system defined defines

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Nov 8 14:02:58 UTC 2019


Update #3818.
---
 testsuites/tmtests/Makefile.am     |  28 +++---
 testsuites/tmtests/tm02/task1.c    | 189 +------------------------------------
 testsuites/tmtests/tm02/tm02impl.h | 187 ++++++++++++++++++++++++++++++++++++
 testsuites/tmtests/tm03/task1.c    | 180 +----------------------------------
 testsuites/tmtests/tm03/tm03impl.h | 178 ++++++++++++++++++++++++++++++++++
 testsuites/tmtests/tm31/task1.c    |   2 +
 testsuites/tmtests/tm32/task1.c    |   2 +
 testsuites/tmtests/tm33/task1.c    |   2 +
 testsuites/tmtests/tm34/task1.c    |   2 +
 testsuites/tmtests/tm35/task1.c    |   2 +
 testsuites/tmtests/tm36/task1.c    |   2 +
 11 files changed, 395 insertions(+), 379 deletions(-)
 create mode 100644 testsuites/tmtests/tm02/tm02impl.h
 create mode 100644 testsuites/tmtests/tm03/tm03impl.h
 create mode 100644 testsuites/tmtests/tm31/task1.c
 create mode 100644 testsuites/tmtests/tm32/task1.c
 create mode 100644 testsuites/tmtests/tm33/task1.c
 create mode 100644 testsuites/tmtests/tm34/task1.c
 create mode 100644 testsuites/tmtests/tm35/task1.c
 create mode 100644 testsuites/tmtests/tm36/task1.c

diff --git a/testsuites/tmtests/Makefile.am b/testsuites/tmtests/Makefile.am
index eb5d2dfeaa..70b67fa6dd 100644
--- a/testsuites/tmtests/Makefile.am
+++ b/testsuites/tmtests/Makefile.am
@@ -28,7 +28,7 @@ tm_docs += tm02/tm02.doc
 tm02_SOURCES = tm02/task1.c tm02/system.h include/timesys.h \
 	../support/src/tmtests_empty_function.c
 tm02_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tm02) $(support_includes) \
-	-I$(top_srcdir)/include -DTM02
+	-I$(top_srcdir)/include
 endif
 
 if TEST_tm03
@@ -37,7 +37,7 @@ tm_docs += tm03/tm03.doc
 tm03_SOURCES = tm03/task1.c tm03/system.h include/timesys.h \
 	../support/src/tmtests_empty_function.c
 tm03_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tm03) $(support_includes) \
-	-I$(top_srcdir)/include -DTM03
+	-I$(top_srcdir)/include
 endif
 
 if TEST_tm04
@@ -287,55 +287,55 @@ endif
 if TEST_tm31
 tm_tests += tm31
 tm_docs += tm31/tm31.doc
-tm31_SOURCES = tm02/task1.c tm02/system.h include/timesys.h \
+tm31_SOURCES = tm31/task1.c tm02/system.h include/timesys.h \
 	../support/src/tmtests_empty_function.c
 tm31_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tm31) $(support_includes) \
-	-I$(top_srcdir)/../tm02 -I$(top_srcdir)/include -DTM31
+	-I$(top_srcdir)/../tm02 -I$(top_srcdir)/include
 endif
 
 if TEST_tm32
 tm_tests += tm32
 tm_docs += tm32/tm32.doc
-tm32_SOURCES = tm03/task1.c tm03/system.h include/timesys.h \
+tm32_SOURCES = tm32/task1.c tm03/system.h include/timesys.h \
 	../support/src/tmtests_empty_function.c
 tm32_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tm32) $(support_includes) \
-	-I$(top_srcdir)/../tm03 -I$(top_srcdir)/include -DTM32
+	-I$(top_srcdir)/../tm03 -I$(top_srcdir)/include
 endif
 
 if TEST_tm33
 tm_tests += tm33
 tm_docs += tm33/tm33.doc
-tm33_SOURCES = tm02/task1.c tm02/system.h include/timesys.h \
+tm33_SOURCES = tm33/task1.c tm02/system.h include/timesys.h \
 	../support/src/tmtests_empty_function.c
 tm33_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tm33) $(support_includes) \
-	-I$(top_srcdir)/../tm02 -I$(top_srcdir)/include -DTM33
+	-I$(top_srcdir)/../tm02 -I$(top_srcdir)/include
 endif
 
 if TEST_tm34
 tm_tests += tm34
 tm_docs += tm34/tm34.doc
-tm34_SOURCES = tm03/task1.c tm03/system.h include/timesys.h \
+tm34_SOURCES = tm34/task1.c tm03/system.h include/timesys.h \
 	../support/src/tmtests_empty_function.c
 tm34_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tm34) $(support_includes) \
-	-I$(top_srcdir)/../tm03 -I$(top_srcdir)/include -DTM34
+	-I$(top_srcdir)/../tm03 -I$(top_srcdir)/include
 endif
 
 if TEST_tm35
 tm_tests += tm35
 tm_docs += tm35/tm35.doc
-tm35_SOURCES = tm02/task1.c tm02/system.h include/timesys.h \
+tm35_SOURCES = tm35/task1.c tm02/system.h include/timesys.h \
 	../support/src/tmtests_empty_function.c
 tm35_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tm35) $(support_includes) \
-	-I$(top_srcdir)/../tm02 -I$(top_srcdir)/include -DTM35
+	-I$(top_srcdir)/../tm02 -I$(top_srcdir)/include
 endif
 
 if TEST_tm36
 tm_tests += tm36
 tm_docs += tm36/tm36.doc
-tm36_SOURCES = tm03/task1.c tm03/system.h include/timesys.h \
+tm36_SOURCES = tm36/task1.c tm03/system.h include/timesys.h \
 	../support/src/tmtests_empty_function.c
 tm36_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tm36) $(support_includes) \
-	-I$(top_srcdir)/../tm03 -I$(top_srcdir)/include -DTM36
+	-I$(top_srcdir)/../tm03 -I$(top_srcdir)/include
 endif
 
 if TEST_tmck
diff --git a/testsuites/tmtests/tm02/task1.c b/testsuites/tmtests/tm02/task1.c
index 8fe1bfd08f..c77039068e 100644
--- a/testsuites/tmtests/tm02/task1.c
+++ b/testsuites/tmtests/tm02/task1.c
@@ -1,187 +1,2 @@
-/*
- *  COPYRIGHT (c) 1989-2014.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if !defined(OPERATION_COUNT)
-#define OPERATION_COUNT 100
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define CONFIGURE_INIT
-#include "system.h"
-
-#if defined(TM02)
-const char rtems_test_name[] = "TIME TEST 2";
-#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO)
-#define ATTR_DESC "counting/FIFO"
-
-#elif defined(TM31)
-const char rtems_test_name[] = "TIME TEST 31";
-#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_PRIORITY)
-#define ATTR_DESC "counting/priority"
-
-#elif defined(TM33)
-const char rtems_test_name[] = "TIME TEST 33";
-#define SEMAPHORE_ATTRIBUTES RTEMS_BINARY_SEMAPHORE
-#define ATTR_DESC "binary/FIFO"
-
-#elif defined(TM35)
-const char rtems_test_name[] = "TIME TEST 35";
-#define SEMAPHORE_ATTRIBUTES (RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY)
-#define ATTR_DESC "binary/priority"
-
-#else
-#error "Unknown test configuration"
-#endif
-
-rtems_id High_id;
-rtems_id Low_id;
-rtems_id Semaphore_id;
-
-rtems_task High_task(
-  rtems_task_argument argument
-);
-
-rtems_task Middle_tasks(
-  rtems_task_argument argument
-);
-
-rtems_task Low_task(
-  rtems_task_argument argument
-);
-
-int operation_count = OPERATION_COUNT;
-
-void test_init(void);
-
-rtems_task Init(
-  rtems_task_argument argument
-)
-{
-  rtems_status_code status;
-
-  Print_Warning();
-
-  TEST_BEGIN();
-
-  test_init();
-
-  status = rtems_task_suspend( RTEMS_SELF );
-  directive_failed( status, "rtems_task_suspend" );
-}
-
-void test_init(void)
-{
-  rtems_status_code   status;
-  int                 index;
-  rtems_task_priority priority;
-
-  priority = 2;
-
-  status = rtems_task_create(
-    rtems_build_name( 'H', 'I', 'G', 'H' ),
-    priority,
-    RTEMS_MINIMUM_STACK_SIZE,
-    RTEMS_DEFAULT_MODES,
-    RTEMS_DEFAULT_ATTRIBUTES,
-    &High_id
-  );
-  directive_failed( status, "rtems_task_create of high task" );
-
-  priority++;
-
-  status = rtems_task_start( High_id, High_task, 0 );
-  directive_failed( status, "rtems_task_start of high task" );
-
-  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
-    operation_count = (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
-  for ( index=2 ; index < operation_count ; index++ ) {
-    status = rtems_task_create(
-      rtems_build_name( 'M', 'I', 'D', ' ' ),
-      priority,
-      RTEMS_MINIMUM_STACK_SIZE,
-      RTEMS_DEFAULT_MODES,
-      RTEMS_DEFAULT_ATTRIBUTES,
-      &Low_id
-    );
-    directive_failed( status, "rtems_task_create middle" );
-
-    priority++;
-
-    status = rtems_task_start( Low_id, Middle_tasks, 0 );
-    directive_failed( status, "rtems_task_start middle" );
-  }
-
-  status = rtems_task_create(
-    rtems_build_name( 'L', 'O', 'W', ' ' ),
-    priority,
-    RTEMS_MINIMUM_STACK_SIZE,
-    RTEMS_DEFAULT_MODES,
-    RTEMS_DEFAULT_ATTRIBUTES,
-    &Low_id
-  );
-  directive_failed( status, "rtems_task_create low" );
-
-  status = rtems_task_start( Low_id, Low_task, 0 );
-  directive_failed( status, "rtems_task_start low" );
-
-  status = rtems_semaphore_create(
-    rtems_build_name( 'S', 'M', '1', ' '),
-    0,
-    SEMAPHORE_ATTRIBUTES,
-    RTEMS_NO_PRIORITY,
-    &Semaphore_id
-  );
-  directive_failed( status, "rtems_semaphore_create of SM1" );
-}
-
-rtems_task High_task(
-  rtems_task_argument argument
-)
-{
-  /* start blocking rtems_semaphore_obtain time */
-  benchmark_timer_initialize();
-
-  (void) rtems_semaphore_obtain(
-    Semaphore_id,
-    RTEMS_DEFAULT_OPTIONS,
-    RTEMS_NO_TIMEOUT
-  );
-}
-
-rtems_task Middle_tasks(
-  rtems_task_argument argument
-)
-{
-  (void) rtems_semaphore_obtain(
-    Semaphore_id,
-    RTEMS_DEFAULT_OPTIONS,
-    RTEMS_NO_TIMEOUT
-  );
-}
-
-rtems_task Low_task(
-  rtems_task_argument argument
-)
-{
-  end_time = benchmark_timer_read();
-
-  put_time(
-    "rtems_semaphore_obtain: " ATTR_DESC " not available caller blocks",
-    end_time,
-    operation_count - 1,
-    0,
-    0
-  );
-
-  TEST_END();
-  rtems_test_exit( 0 );
-}
+#define TM02
+#include "tm02impl.h"
diff --git a/testsuites/tmtests/tm02/tm02impl.h b/testsuites/tmtests/tm02/tm02impl.h
new file mode 100644
index 0000000000..8fe1bfd08f
--- /dev/null
+++ b/testsuites/tmtests/tm02/tm02impl.h
@@ -0,0 +1,187 @@
+/*
+ *  COPYRIGHT (c) 1989-2014.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+
+#if !defined(OPERATION_COUNT)
+#define OPERATION_COUNT 100
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+#if defined(TM02)
+const char rtems_test_name[] = "TIME TEST 2";
+#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO)
+#define ATTR_DESC "counting/FIFO"
+
+#elif defined(TM31)
+const char rtems_test_name[] = "TIME TEST 31";
+#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_PRIORITY)
+#define ATTR_DESC "counting/priority"
+
+#elif defined(TM33)
+const char rtems_test_name[] = "TIME TEST 33";
+#define SEMAPHORE_ATTRIBUTES RTEMS_BINARY_SEMAPHORE
+#define ATTR_DESC "binary/FIFO"
+
+#elif defined(TM35)
+const char rtems_test_name[] = "TIME TEST 35";
+#define SEMAPHORE_ATTRIBUTES (RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY)
+#define ATTR_DESC "binary/priority"
+
+#else
+#error "Unknown test configuration"
+#endif
+
+rtems_id High_id;
+rtems_id Low_id;
+rtems_id Semaphore_id;
+
+rtems_task High_task(
+  rtems_task_argument argument
+);
+
+rtems_task Middle_tasks(
+  rtems_task_argument argument
+);
+
+rtems_task Low_task(
+  rtems_task_argument argument
+);
+
+int operation_count = OPERATION_COUNT;
+
+void test_init(void);
+
+rtems_task Init(
+  rtems_task_argument argument
+)
+{
+  rtems_status_code status;
+
+  Print_Warning();
+
+  TEST_BEGIN();
+
+  test_init();
+
+  status = rtems_task_suspend( RTEMS_SELF );
+  directive_failed( status, "rtems_task_suspend" );
+}
+
+void test_init(void)
+{
+  rtems_status_code   status;
+  int                 index;
+  rtems_task_priority priority;
+
+  priority = 2;
+
+  status = rtems_task_create(
+    rtems_build_name( 'H', 'I', 'G', 'H' ),
+    priority,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &High_id
+  );
+  directive_failed( status, "rtems_task_create of high task" );
+
+  priority++;
+
+  status = rtems_task_start( High_id, High_task, 0 );
+  directive_failed( status, "rtems_task_start of high task" );
+
+  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
+    operation_count = (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
+  for ( index=2 ; index < operation_count ; index++ ) {
+    status = rtems_task_create(
+      rtems_build_name( 'M', 'I', 'D', ' ' ),
+      priority,
+      RTEMS_MINIMUM_STACK_SIZE,
+      RTEMS_DEFAULT_MODES,
+      RTEMS_DEFAULT_ATTRIBUTES,
+      &Low_id
+    );
+    directive_failed( status, "rtems_task_create middle" );
+
+    priority++;
+
+    status = rtems_task_start( Low_id, Middle_tasks, 0 );
+    directive_failed( status, "rtems_task_start middle" );
+  }
+
+  status = rtems_task_create(
+    rtems_build_name( 'L', 'O', 'W', ' ' ),
+    priority,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &Low_id
+  );
+  directive_failed( status, "rtems_task_create low" );
+
+  status = rtems_task_start( Low_id, Low_task, 0 );
+  directive_failed( status, "rtems_task_start low" );
+
+  status = rtems_semaphore_create(
+    rtems_build_name( 'S', 'M', '1', ' '),
+    0,
+    SEMAPHORE_ATTRIBUTES,
+    RTEMS_NO_PRIORITY,
+    &Semaphore_id
+  );
+  directive_failed( status, "rtems_semaphore_create of SM1" );
+}
+
+rtems_task High_task(
+  rtems_task_argument argument
+)
+{
+  /* start blocking rtems_semaphore_obtain time */
+  benchmark_timer_initialize();
+
+  (void) rtems_semaphore_obtain(
+    Semaphore_id,
+    RTEMS_DEFAULT_OPTIONS,
+    RTEMS_NO_TIMEOUT
+  );
+}
+
+rtems_task Middle_tasks(
+  rtems_task_argument argument
+)
+{
+  (void) rtems_semaphore_obtain(
+    Semaphore_id,
+    RTEMS_DEFAULT_OPTIONS,
+    RTEMS_NO_TIMEOUT
+  );
+}
+
+rtems_task Low_task(
+  rtems_task_argument argument
+)
+{
+  end_time = benchmark_timer_read();
+
+  put_time(
+    "rtems_semaphore_obtain: " ATTR_DESC " not available caller blocks",
+    end_time,
+    operation_count - 1,
+    0,
+    0
+  );
+
+  TEST_END();
+  rtems_test_exit( 0 );
+}
diff --git a/testsuites/tmtests/tm03/task1.c b/testsuites/tmtests/tm03/task1.c
index 50bbe1b4d2..88c13f3b64 100644
--- a/testsuites/tmtests/tm03/task1.c
+++ b/testsuites/tmtests/tm03/task1.c
@@ -1,178 +1,2 @@
-/*
- *  COPYRIGHT (c) 1989-2014.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if !defined(OPERATION_COUNT)
-#define OPERATION_COUNT 100
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define CONFIGURE_INIT
-#include "system.h"
-
-#if defined(TM03)
-const char rtems_test_name[] = "TIME TEST 3";
-#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO)
-#define ATTR_DESC "counting/FIFO"
-
-#elif defined(TM32)
-const char rtems_test_name[] = "TIME TEST 32";
-#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_PRIORITY)
-#define ATTR_DESC "counting/priority"
-
-#elif defined(TM34)
-const char rtems_test_name[] = "TIME TEST 34";
-#define SEMAPHORE_ATTRIBUTES RTEMS_BINARY_SEMAPHORE
-#define ATTR_DESC "binary/FIFO"
-
-#elif defined(TM36)
-const char rtems_test_name[] = "TIME TEST 36";
-#define SEMAPHORE_ATTRIBUTES (RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY)
-#define ATTR_DESC "binary/priority"
-
-#else
-#error "Unknown test configuration"
-#endif
-
-
-rtems_id Semaphore_id;
-rtems_task test_init(
-  rtems_task_argument argument
-);
-
-rtems_task Middle_tasks(
-  rtems_task_argument argument
-);
-
-rtems_task High_task(
-  rtems_task_argument argument
-);
-
-int operation_count = OPERATION_COUNT;
-
-rtems_task Init(
-  rtems_task_argument argument
-)
-{
-  rtems_status_code status;
-  rtems_id          task_id;
-
-  Print_Warning();
-
-  TEST_BEGIN();
-  status = rtems_task_create(
-    rtems_build_name( 'T', 'A', '1', ' ' ),
-    RTEMS_MAXIMUM_PRIORITY - 1u,
-    RTEMS_MINIMUM_STACK_SIZE,
-    RTEMS_DEFAULT_MODES,
-    RTEMS_DEFAULT_ATTRIBUTES,
-    &task_id
-  );
-  directive_failed( status, "rtems_task_create of test_init" );
-
-  status = rtems_task_start( task_id, test_init, 0 );
-  directive_failed( status, "rtems_task_start of test_init" );
-
-  rtems_task_exit();
-}
-
-rtems_task test_init(
-  rtems_task_argument argument
-)
-{
-  rtems_status_code   status;
-  int                 index;
-  rtems_id            task_id;
-  rtems_task_priority priority;
-
-  priority = RTEMS_MAXIMUM_PRIORITY - 2u;
-
-  status = rtems_semaphore_create(
-    rtems_build_name( 'S', 'M', '1', '\0'),
-    0,
-    SEMAPHORE_ATTRIBUTES,
-    RTEMS_NO_PRIORITY,
-    &Semaphore_id
-  );
-  directive_failed( status, "rtems_semaphore_create of SM1" );
-
-  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
-    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
-  for ( index = 2 ; index < operation_count ; index ++ ) {
-    rtems_task_create(
-      rtems_build_name( 'M', 'I', 'D', ' ' ),
-      priority,
-      RTEMS_MINIMUM_STACK_SIZE,
-      RTEMS_DEFAULT_MODES,
-      RTEMS_DEFAULT_ATTRIBUTES,
-      &task_id
-    );
-    directive_failed( status, "rtems_task_create middle" );
-
-    priority--;
-
-    rtems_task_start( task_id, Middle_tasks, 0 );
-    directive_failed( status, "rtems_task_start middle" );
-  }
-
-  status = rtems_task_create(
-    rtems_build_name( 'H', 'I', 'G', 'H' ),
-    priority,
-    RTEMS_MINIMUM_STACK_SIZE,
-    RTEMS_DEFAULT_MODES,
-    RTEMS_DEFAULT_ATTRIBUTES,
-    &task_id
-  );
-  directive_failed( status, "rtems_task_create of high task" );
-
-  status = rtems_task_start( task_id, High_task, 0 );
-  directive_failed( status, "rtems_task_start of high task" );
-
-  benchmark_timer_initialize();                          /* start the timer */
-  status = rtems_semaphore_release( Semaphore_id );
-}
-
-rtems_task Middle_tasks(
-  rtems_task_argument argument
-)
-{
-  (void) rtems_semaphore_obtain(
-    Semaphore_id,
-    RTEMS_DEFAULT_OPTIONS,
-    RTEMS_NO_TIMEOUT
-  );
-
-  (void) rtems_semaphore_release( Semaphore_id );
-}
-
-rtems_task High_task(
-  rtems_task_argument argument
-)
-{
-  (void) rtems_semaphore_obtain(
-    Semaphore_id,
-    RTEMS_DEFAULT_OPTIONS,
-    RTEMS_NO_TIMEOUT
-  );
-
-  end_time = benchmark_timer_read();
-
-  put_time(
-    "rtems_semaphore_release: " ATTR_DESC " task readied preempts caller",
-    end_time,
-    operation_count - 1,
-    0,
-    0
-  );
-
-  TEST_END();
-  rtems_test_exit( 0 );
-}
+#define TM03
+#include "tm03impl.h"
diff --git a/testsuites/tmtests/tm03/tm03impl.h b/testsuites/tmtests/tm03/tm03impl.h
new file mode 100644
index 0000000000..50bbe1b4d2
--- /dev/null
+++ b/testsuites/tmtests/tm03/tm03impl.h
@@ -0,0 +1,178 @@
+/*
+ *  COPYRIGHT (c) 1989-2014.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+
+#if !defined(OPERATION_COUNT)
+#define OPERATION_COUNT 100
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+#if defined(TM03)
+const char rtems_test_name[] = "TIME TEST 3";
+#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO)
+#define ATTR_DESC "counting/FIFO"
+
+#elif defined(TM32)
+const char rtems_test_name[] = "TIME TEST 32";
+#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_PRIORITY)
+#define ATTR_DESC "counting/priority"
+
+#elif defined(TM34)
+const char rtems_test_name[] = "TIME TEST 34";
+#define SEMAPHORE_ATTRIBUTES RTEMS_BINARY_SEMAPHORE
+#define ATTR_DESC "binary/FIFO"
+
+#elif defined(TM36)
+const char rtems_test_name[] = "TIME TEST 36";
+#define SEMAPHORE_ATTRIBUTES (RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY)
+#define ATTR_DESC "binary/priority"
+
+#else
+#error "Unknown test configuration"
+#endif
+
+
+rtems_id Semaphore_id;
+rtems_task test_init(
+  rtems_task_argument argument
+);
+
+rtems_task Middle_tasks(
+  rtems_task_argument argument
+);
+
+rtems_task High_task(
+  rtems_task_argument argument
+);
+
+int operation_count = OPERATION_COUNT;
+
+rtems_task Init(
+  rtems_task_argument argument
+)
+{
+  rtems_status_code status;
+  rtems_id          task_id;
+
+  Print_Warning();
+
+  TEST_BEGIN();
+  status = rtems_task_create(
+    rtems_build_name( 'T', 'A', '1', ' ' ),
+    RTEMS_MAXIMUM_PRIORITY - 1u,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &task_id
+  );
+  directive_failed( status, "rtems_task_create of test_init" );
+
+  status = rtems_task_start( task_id, test_init, 0 );
+  directive_failed( status, "rtems_task_start of test_init" );
+
+  rtems_task_exit();
+}
+
+rtems_task test_init(
+  rtems_task_argument argument
+)
+{
+  rtems_status_code   status;
+  int                 index;
+  rtems_id            task_id;
+  rtems_task_priority priority;
+
+  priority = RTEMS_MAXIMUM_PRIORITY - 2u;
+
+  status = rtems_semaphore_create(
+    rtems_build_name( 'S', 'M', '1', '\0'),
+    0,
+    SEMAPHORE_ATTRIBUTES,
+    RTEMS_NO_PRIORITY,
+    &Semaphore_id
+  );
+  directive_failed( status, "rtems_semaphore_create of SM1" );
+
+  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
+    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
+  for ( index = 2 ; index < operation_count ; index ++ ) {
+    rtems_task_create(
+      rtems_build_name( 'M', 'I', 'D', ' ' ),
+      priority,
+      RTEMS_MINIMUM_STACK_SIZE,
+      RTEMS_DEFAULT_MODES,
+      RTEMS_DEFAULT_ATTRIBUTES,
+      &task_id
+    );
+    directive_failed( status, "rtems_task_create middle" );
+
+    priority--;
+
+    rtems_task_start( task_id, Middle_tasks, 0 );
+    directive_failed( status, "rtems_task_start middle" );
+  }
+
+  status = rtems_task_create(
+    rtems_build_name( 'H', 'I', 'G', 'H' ),
+    priority,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &task_id
+  );
+  directive_failed( status, "rtems_task_create of high task" );
+
+  status = rtems_task_start( task_id, High_task, 0 );
+  directive_failed( status, "rtems_task_start of high task" );
+
+  benchmark_timer_initialize();                          /* start the timer */
+  status = rtems_semaphore_release( Semaphore_id );
+}
+
+rtems_task Middle_tasks(
+  rtems_task_argument argument
+)
+{
+  (void) rtems_semaphore_obtain(
+    Semaphore_id,
+    RTEMS_DEFAULT_OPTIONS,
+    RTEMS_NO_TIMEOUT
+  );
+
+  (void) rtems_semaphore_release( Semaphore_id );
+}
+
+rtems_task High_task(
+  rtems_task_argument argument
+)
+{
+  (void) rtems_semaphore_obtain(
+    Semaphore_id,
+    RTEMS_DEFAULT_OPTIONS,
+    RTEMS_NO_TIMEOUT
+  );
+
+  end_time = benchmark_timer_read();
+
+  put_time(
+    "rtems_semaphore_release: " ATTR_DESC " task readied preempts caller",
+    end_time,
+    operation_count - 1,
+    0,
+    0
+  );
+
+  TEST_END();
+  rtems_test_exit( 0 );
+}
diff --git a/testsuites/tmtests/tm31/task1.c b/testsuites/tmtests/tm31/task1.c
new file mode 100644
index 0000000000..158c2d3dd4
--- /dev/null
+++ b/testsuites/tmtests/tm31/task1.c
@@ -0,0 +1,2 @@
+#define TM31
+#include "../tm02/tm02impl.h"
diff --git a/testsuites/tmtests/tm32/task1.c b/testsuites/tmtests/tm32/task1.c
new file mode 100644
index 0000000000..a1787fdb3e
--- /dev/null
+++ b/testsuites/tmtests/tm32/task1.c
@@ -0,0 +1,2 @@
+#define TM32
+#include "../tm03/tm03impl.h"
diff --git a/testsuites/tmtests/tm33/task1.c b/testsuites/tmtests/tm33/task1.c
new file mode 100644
index 0000000000..17917e11ba
--- /dev/null
+++ b/testsuites/tmtests/tm33/task1.c
@@ -0,0 +1,2 @@
+#define TM33
+#include "../tm02/tm02impl.h"
diff --git a/testsuites/tmtests/tm34/task1.c b/testsuites/tmtests/tm34/task1.c
new file mode 100644
index 0000000000..2f3a888d14
--- /dev/null
+++ b/testsuites/tmtests/tm34/task1.c
@@ -0,0 +1,2 @@
+#define TM34
+#include "../tm03/tm03impl.h"
diff --git a/testsuites/tmtests/tm35/task1.c b/testsuites/tmtests/tm35/task1.c
new file mode 100644
index 0000000000..4f1ee856d4
--- /dev/null
+++ b/testsuites/tmtests/tm35/task1.c
@@ -0,0 +1,2 @@
+#define TM35
+#include "../tm02/tm02impl.h"
diff --git a/testsuites/tmtests/tm36/task1.c b/testsuites/tmtests/tm36/task1.c
new file mode 100644
index 0000000000..1dcdcefd64
--- /dev/null
+++ b/testsuites/tmtests/tm36/task1.c
@@ -0,0 +1,2 @@
+#define TM36
+#include "../tm03/tm03impl.h"
-- 
2.16.4



More information about the devel mailing list