summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Averett <jennifer.averett@oarcorp.com>2014-10-24 14:37:24 -0500
committerJennifer Averett <jennifer.averett@oarcorp.com>2014-11-24 14:04:54 -0600
commit44da98f08f0a5b8cf7fcfece45881d6904520aec (patch)
tree97c36eb449a61c3cd07fa301c1c771f5faaa31c6
parentcapture01: Use capture engine print methods. (diff)
downloadrtems-44da98f08f0a5b8cf7fcfece45881d6904520aec.tar.bz2
smpcapture01: New test.
-rw-r--r--testsuites/smptests/Makefile.am1
-rw-r--r--testsuites/smptests/configure.ac1
-rw-r--r--testsuites/smptests/smpcapture01/Makefile.am19
-rw-r--r--testsuites/smptests/smpcapture01/init.c273
-rw-r--r--testsuites/smptests/smpcapture01/smpcapture01.doc50
-rw-r--r--testsuites/smptests/smpcapture01/smpcapture01.scn45
6 files changed, 389 insertions, 0 deletions
diff --git a/testsuites/smptests/Makefile.am b/testsuites/smptests/Makefile.am
index 1e72d43ce4..87c3d7f456 100644
--- a/testsuites/smptests/Makefile.am
+++ b/testsuites/smptests/Makefile.am
@@ -12,6 +12,7 @@ SUBDIRS += smp09
SUBDIRS += smpaffinity01
SUBDIRS += smpatomic01
SUBDIRS += smpcache01
+SUBDIRS += smpcapture01
SUBDIRS += smpfatal01
SUBDIRS += smpfatal02
SUBDIRS += smpfatal03
diff --git a/testsuites/smptests/configure.ac b/testsuites/smptests/configure.ac
index 9b6d99b023..e7b96aeeb1 100644
--- a/testsuites/smptests/configure.ac
+++ b/testsuites/smptests/configure.ac
@@ -67,6 +67,7 @@ smp09/Makefile
smpaffinity01/Makefile
smpatomic01/Makefile
smpcache01/Makefile
+smpcapture01/Makefile
smpfatal01/Makefile
smpfatal02/Makefile
smpfatal03/Makefile
diff --git a/testsuites/smptests/smpcapture01/Makefile.am b/testsuites/smptests/smpcapture01/Makefile.am
new file mode 100644
index 0000000000..084f404298
--- /dev/null
+++ b/testsuites/smptests/smpcapture01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = smpcapture01
+smpcapture01_SOURCES = init.c
+
+dist_rtems_tests_DATA = smpcapture01.scn smpcapture01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(smpcapture01_OBJECTS)
+LINK_LIBS = $(smpcapture01_LDLIBS)
+
+smpcapture01$(EXEEXT): $(smpcapture01_OBJECTS) $(smpcapture01_DEPENDENCIES)
+ @rm -f smpcapture01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/smptests/smpcapture01/init.c b/testsuites/smptests/smpcapture01/init.c
new file mode 100644
index 0000000000..114cd8b36c
--- /dev/null
+++ b/testsuites/smptests/smpcapture01/init.c
@@ -0,0 +1,273 @@
+/*
+ * COPYRIGHT (c) 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.
+ */
+
+/*
+ * The init task UT1 should start on cpu 3 and has priority:affinity set
+ * 7:{2,3} The test creates 4 more tasks TA1 - TA4
+ * with priorty:affinity sets 8:{2,3}, 5:{0,1}, 6:{0,3}, and 9:{1}.
+ * This should result in cpu:task 0:TA3, 1:TA2, 2:TA1, 3:UT1 with
+ * TA4 waiting on a cpu.
+ *
+ * The test then raises the priority of TA4 to 4, resulting
+ * in the following cpu:task 0:TA2, 1:TA4, 2:UT1, 3:TA3 with
+ * TA1 waiting on a CPU. The tasks are then terminated.
+ *
+ * The capture engine is set up read and report the results.
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/captureimpl.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "SMPCAPTURE 1";
+
+#define NUM_CPUS 4
+#define TASK_COUNT 5
+
+struct task_data_t {
+ rtems_id id;
+ cpu_set_t cpuset;
+ rtems_task_priority priority;
+ bool ran;
+ int expected_cpu;
+ int actual_cpu;
+ int migrate_cpu;
+};
+
+static struct task_data_t task_data[TASK_COUNT] = {
+ {0x0, {{0xc}}, 7, false, 3, -1, 2},
+ {0x0, {{0xf}}, 8, false, 2, -1, -1},
+ {0x0, {{0x3}}, 5, false, 1, -1, 0},
+ {0x0, {{0x9}}, 6, false, 0, -1, 3},
+ {0x0, {{0x2}}, 9, false, -1, -1, 1}
+};
+
+rtems_id task_sem;
+
+/*
+ * Spin loop to allow tasks to delay without yeilding the
+ * processor.
+ */
+static void test_delay(int ticks)
+{
+ rtems_interval start, stop;
+ start = rtems_clock_get_ticks_since_boot();
+ do {
+ stop = rtems_clock_get_ticks_since_boot();
+ } while ( (stop - start) < ticks );
+}
+
+static void task(rtems_task_argument arg)
+{
+ rtems_status_code sc;
+
+ while (true) {
+ sc = rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0);
+ if (sc == RTEMS_SUCCESSFUL) {
+ task_data[arg].ran = true;
+ task_data[arg].actual_cpu = rtems_get_current_processor();
+ rtems_semaphore_release(task_sem);
+ }
+ }
+}
+
+static void set_init_task(void)
+{
+ while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
+
+ /* Set Init task data */
+ task_data[0].ran = true;
+ task_data[0].actual_cpu = rtems_get_current_processor();
+
+ rtems_semaphore_release(task_sem);
+}
+
+static void test(void)
+{
+ rtems_status_code sc;
+ rtems_task_argument i;
+ size_t size;
+ uint32_t cpu_count;
+ rtems_task_priority priority;
+
+ /* Get the number of processors that we are using. */
+ cpu_count = rtems_get_processor_count();
+ if (cpu_count != 4) {
+ printf("Test requires a minimum of 4 cores\n");
+ return;
+ }
+
+ size = sizeof(cpu_set_t);
+ task_data[0].id = rtems_task_self();
+
+ sc = rtems_semaphore_create(
+ rtems_build_name('S', 'E', 'M', '0'),
+ 1, /* initial count = 1 */
+ RTEMS_LOCAL |
+ RTEMS_SIMPLE_BINARY_SEMAPHORE |
+ RTEMS_NO_INHERIT_PRIORITY |
+ RTEMS_NO_PRIORITY_CEILING |
+ RTEMS_FIFO,
+ 0,
+ &task_sem
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_set_affinity(
+ task_data[ 0 ].id,
+ size,
+ &task_data[0].cpuset
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+
+ /* Create and start tasks on each cpu with the appropriate affinity. */
+ for (i = 1; i < TASK_COUNT; i++) {
+
+ sc = rtems_task_create(
+ rtems_build_name('T', 'A', '0', '0'+i),
+ task_data[ i ].priority,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &task_data[ i ].id
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_set_affinity(
+ task_data[ i ].id,
+ size,
+ &task_data[i].cpuset
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_start( task_data[ i ].id, task, i );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ }
+
+ /* spin for 10 ticks */
+ test_delay(10);
+
+ set_init_task();
+
+ i = TASK_COUNT - 1;
+ task_data[ i ].priority = 4;
+ sc = rtems_task_set_priority(
+ task_data[ i ].id,
+ task_data[ i ].priority,
+ &priority
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ test_delay(10);
+
+ while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
+ for (i = 0; i < TASK_COUNT; i++) {
+ task_data[ i ].expected_cpu = task_data[ i ].migrate_cpu;
+ task_data[ i ].actual_cpu = -1;
+ task_data[ i ].ran = false;
+ }
+ rtems_semaphore_release(task_sem);
+ test_delay(10);
+ set_init_task();
+
+ for (i = 1; i < TASK_COUNT; i++) {
+ sc = rtems_task_delete( task_data[ i ].id );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ }
+ test_delay(25);
+}
+
+static void Init(rtems_task_argument arg)
+{
+ rtems_status_code sc;
+ rtems_name to_name = rtems_build_name('I', 'D', 'L', 'E');;
+ uint32_t i;
+
+ TEST_BEGIN();
+
+ sc = rtems_capture_open (5000, NULL);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_capture_watch_ceiling (0);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_capture_watch_floor (20);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_capture_watch_global (true);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_capture_set_trigger (
+ 0,
+ 0,
+ to_name,
+ 0,
+ rtems_capture_from_any,
+ rtems_capture_switch
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ for (i = 1; i < TASK_COUNT; i++) {
+ to_name = rtems_build_name('T', 'A', '0', '0'+i);
+ sc = rtems_capture_set_trigger (
+ 0,
+ 0,
+ to_name,
+ 0,
+ rtems_capture_from_any,
+ rtems_capture_switch
+ );
+ }
+
+ sc = rtems_capture_control (true);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ test();
+
+ sc = rtems_capture_control (false);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ rtems_capture_print_trace_records ( 22, false );
+ rtems_capture_print_trace_records ( 22, false );
+ rtems_capture_print_trace_records ( 22, false );
+
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_SMP_APPLICATION
+
+#define CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
+
+#define CONFIGURE_SMP_MAXIMUM_PROCESSORS NUM_CPUS
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT_TASK_PRIORITY 7
+
+#define TASK_ALLOCATION_SIZE (5)
+#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(TASK_ALLOCATION_SIZE)
+#define CONFIGURE_EXTRA_TASK_STACKS (75 * RTEMS_MINIMUM_STACK_SIZE)
+
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS (5)
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/smptests/smpcapture01/smpcapture01.doc b/testsuites/smptests/smpcapture01/smpcapture01.doc
new file mode 100644
index 0000000000..18414fd16a
--- /dev/null
+++ b/testsuites/smptests/smpcapture01/smpcapture01.doc
@@ -0,0 +1,50 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: smpcapture01
+
+directives:
+ rtems_capture_open
+ rtems_capture_watch_ceiling
+ rtems_capture_watch_floor
+ rtems_capture_watch_global
+ rtems_capture_set_trigger
+ rtems_capture_control
+ rtems_capture_print_trace_records
+
+
+concepts:
+
+This test does a worst case migration of 4 tasks on a 4 core system tracking
+and displaying the user extension records. This task is rather complex to
+describe but using the notation TaskName:Priority:{cpu,cpu} where the third
+portion indicates the CPUs the task has affinity for. The test starts with
+the initialization task (UT1:7:{2,3}) starting execution on CPU 3. This
+results in the following tasks assigned across the CPUs:
+
+ CPUs 0-2: Idle threads
+ CPU 3: UT1
+
+The UT1 task creates four more tasks as follows:
+ TA1:8:{2,3}
+ TA2:5:{0,1}
+ TA3:6:{0,3}
+ TA4:9:{1}
+
+This should result in the tasks being assigned to CPUs as follows:
+ CPU 0: TA3
+ CPU 1: TA2
+ CPU 2: TA1
+ CPU 3: UT1
+
+TA4 should be ready to execute but waiting on a CPU it has affinity for
+to become available. The test then raises the priority of TA4 to 4,
+resulting in the tasks being assigned to CPUs as follows:
+ CPU 0: TA2
+ CPU 1: TA4
+ CPU 2: UT1
+ CPU 3: TA3
+
+At this point TA1 should still be ready to execute but is waiting on a CPU
+it has affinity for to become available. The tasks are then terminated.
+Additionally, the capture engine output shows that the migration that can
+occur during task termination adheres to the affinity settings.
diff --git a/testsuites/smptests/smpcapture01/smpcapture01.scn b/testsuites/smptests/smpcapture01/smpcapture01.scn
new file mode 100644
index 0000000000..9f7c639e41
--- /dev/null
+++ b/testsuites/smptests/smpcapture01/smpcapture01.scn
@@ -0,0 +1,45 @@
+*** BEGIN OF TEST SMPCAPTURE 1 ***
+ 1 0:00:00.008653000 0a010003 TA02 5 5 5 4096 TASK_RECORD
+ 0 0:00:00.008659000 0a010004 TA03 6 6 6 4096 TASK_RECORD
+ 2 0:00:00.008663000 0a010002 TA01 8 8 8 4096 TASK_RECORD
+ 1 0:00:00.008681000 0 0a010003 5 5 SWITCHED_IN
+ 0 0:00:00.008686000 0 0a010004 6 6 SWITCHED_IN
+ 2 0:00:00.008691000 0 0a010002 8 8 SWITCHED_IN
+ 1 0:00:00.008734000 53000 0a010003 5 5 BEGIN
+ 0 0:00:00.008738000 52000 0a010004 6 6 BEGIN
+ 2 0:00:00.008743000 52000 0a010002 8 8 BEGIN
+ 3 0:00:00.008914000 0a010001 UI1 7 7 7 4096 TASK_RECORD
+ 3 0:00:00.008943000 0 0a010001 7 7 CREATED_BY
+ 3 0:00:00.009015000 0a010005 TA04 9 9 9 4096 TASK_RECORD
+ 3 0:00:00.009041000 98000 0a010005 9 9 CREATED
+ 3 0:00:00.009298000 257000 0a010001 7 7 STARTED_BY
+ 3 0:00:00.009326000 28000 0a010005 9 9 STARTED
+ 3 0:00:01.000432000 991106000 0a010001 7 7 SWITCHED_OUT
+ 1 0:00:01.000452000 991718000 0a010003 5 5 SWITCHED_OUT
+ 3 0:00:01.000456000 24000 0a010004 6 6 SWITCHED_IN
+ 0 0:00:01.000473000 991735000 0a010004 6 6 SWITCHED_OUT
+ 1 0:00:01.000476000 24000 0a010005 4 4 SWITCHED_IN
+ 2 0:00:01.000491000 991748000 0a010002 8 8 SWITCHED_OUT
+ 0 0:00:01.000496000 23000 0a010003 5 5 SWITCHED_IN
+ 2 0:00:01.000514000 0 0a010001 7 7 SWITCHED_IN
+ 1 0:00:01.000527000 0 0a010005 4 4 BEGIN
+ 2 0:00:01.500426000 499912000 0a010001 7 7 SWITCHED_OUT
+ 2 0:00:01.500450000 24000 0a010002 7 7 SWITCHED_IN
+ 2 0:00:01.500579000 129000 0a010002 7 7 TERMINATED
+ 2 0:00:01.500731000 152000 0a010002 7 7 SWITCHED_OUT
+ 2 0:00:01.500755000 24000 0a010001 7 7 SWITCHED_IN
+ 2 0:00:01.500966000 211000 0a010001 7 7 SWITCHED_OUT
+ 0 0:00:01.501049000 0 0a010003 7 5 TERMINATED
+ 2 0:00:01.501186000 220000 0a010001 7 7 SWITCHED_IN
+ 0 0:00:01.501200000 151000 0a010003 7 5 SWITCHED_OUT
+ 2 0:00:01.501391000 205000 0a010001 7 7 SWITCHED_OUT
+ 3 0:00:01.501476000 0 0a010004 7 6 TERMINATED
+ 3 0:00:01.501623000 147000 0a010004 7 6 SWITCHED_OUT
+ 3 0:00:01.501649000 26000 0a010001 7 7 SWITCHED_IN
+ 3 0:00:01.501867000 218000 0a010001 7 7 SWITCHED_OUT
+ 1 0:00:01.501945000 501418000 0a010005 7 4 TERMINATED
+ 3 0:00:01.502083000 216000 0a010001 7 7 SWITCHED_IN
+ 1 0:00:01.502136000 191000 0a010005 7 4 SWITCHED_OUT
+*** END OF TEST SMPCAPTURE 1 ***
+
+Note: Times may differ