[PATCH 6/6] smptests/smpschededf01: New test

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jun 29 13:23:18 UTC 2017


Update #3056.
---
 testsuites/smptests/Makefile.am                    |   1 +
 testsuites/smptests/configure.ac                   |   1 +
 testsuites/smptests/smpschededf01/Makefile.am      |  19 +++
 testsuites/smptests/smpschededf01/init.c           | 161 +++++++++++++++++++++
 .../smptests/smpschededf01/smpschededf01.doc       |  12 ++
 .../smptests/smpschededf01/smpschededf01.scn       |  21 +++
 6 files changed, 215 insertions(+)
 create mode 100644 testsuites/smptests/smpschededf01/Makefile.am
 create mode 100644 testsuites/smptests/smpschededf01/init.c
 create mode 100644 testsuites/smptests/smpschededf01/smpschededf01.doc
 create mode 100644 testsuites/smptests/smpschededf01/smpschededf01.scn

diff --git a/testsuites/smptests/Makefile.am b/testsuites/smptests/Makefile.am
index 6c1bd1294f..01dc52e524 100644
--- a/testsuites/smptests/Makefile.am
+++ b/testsuites/smptests/Makefile.am
@@ -35,6 +35,7 @@ _SUBDIRS += smppsxaffinity02
 _SUBDIRS += smpschedaffinity03
 _SUBDIRS += smpschedaffinity04
 _SUBDIRS += smpschedaffinity05
+_SUBDIRS += smpschededf01
 _SUBDIRS += smpschedsem01
 _SUBDIRS += smpscheduler01
 _SUBDIRS += smpscheduler02
diff --git a/testsuites/smptests/configure.ac b/testsuites/smptests/configure.ac
index 59b27ef397..f3a840b593 100644
--- a/testsuites/smptests/configure.ac
+++ b/testsuites/smptests/configure.ac
@@ -90,6 +90,7 @@ smpschedaffinity02/Makefile
 smpschedaffinity03/Makefile
 smpschedaffinity04/Makefile
 smpschedaffinity05/Makefile
+smpschededf01/Makefile
 smpschedsem01/Makefile
 smpscheduler01/Makefile
 smpscheduler02/Makefile
diff --git a/testsuites/smptests/smpschededf01/Makefile.am b/testsuites/smptests/smpschededf01/Makefile.am
new file mode 100644
index 0000000000..aaed6bcd33
--- /dev/null
+++ b/testsuites/smptests/smpschededf01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = smpschededf01
+smpschededf01_SOURCES = init.c
+
+dist_rtems_tests_DATA = smpschededf01.scn smpschededf01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(smpschededf01_OBJECTS)
+LINK_LIBS = $(smpschededf01_LDLIBS)
+
+smpschededf01$(EXEEXT): $(smpschededf01_OBJECTS) $(smpschededf01_DEPENDENCIES)
+	@rm -f smpschededf01$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/smptests/smpschededf01/init.c b/testsuites/smptests/smpschededf01/init.c
new file mode 100644
index 0000000000..c1c995e69b
--- /dev/null
+++ b/testsuites/smptests/smpschededf01/init.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/cpuuse.h>
+#include <rtems/printer.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "SMPSCHEDEDF 1";
+
+typedef struct {
+  uint_fast32_t one_tick_busy;
+  rtems_id task[2];
+} test_context;
+
+static test_context test_instance;
+
+static void t(test_context *ctx, rtems_interval p, uint_fast32_t c)
+{
+  rtems_status_code sc;
+  rtems_id period;
+  rtems_name name;
+  uint_fast32_t busy;
+
+  sc = rtems_object_get_classic_name(rtems_task_self(), &name);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_rate_monotonic_create(name, &period);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  busy = (c - 1) * ctx->one_tick_busy + (4 * ctx->one_tick_busy) / 5;
+
+  while (true) {
+    rtems_test_busy(busy);
+
+    sc = rtems_rate_monotonic_period(period, p);
+    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  }
+}
+
+static void t1(rtems_task_argument arg)
+{
+  test_context *ctx = (test_context *) arg;
+
+  t(ctx, 50, 25);
+}
+
+static void t2(rtems_task_argument arg)
+{
+  test_context *ctx = (test_context *) arg;
+
+  t(ctx, 75, 30);
+}
+
+static void test(test_context *ctx)
+{
+  rtems_status_code sc;
+  rtems_printer printer;
+
+  ctx->one_tick_busy = rtems_test_get_one_tick_busy_count();
+
+  sc = rtems_task_create(
+    rtems_build_name('T', '1', ' ', ' '),
+    2,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &ctx->task[0]
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_create(
+    rtems_build_name('T', '2', ' ', ' '),
+    2,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &ctx->task[1]
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_wake_after(1);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_start(ctx->task[0], t1, (rtems_task_argument) ctx);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_start(ctx->task[1], t2, (rtems_task_argument) ctx);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  rtems_cpu_usage_reset();
+
+  sc = rtems_task_wake_after(50 * 75);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_suspend(ctx->task[0]);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_suspend(ctx->task[1]);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  rtems_print_printer_printf(&printer);
+  rtems_cpu_usage_report_with_plugin(&printer);
+  rtems_rate_monotonic_report_statistics_with_plugin(&printer);
+}
+
+static void Init(rtems_task_argument arg)
+{
+  test_context *ctx = &test_instance;
+
+  TEST_BEGIN();
+
+  test(ctx);
+
+  TEST_END();
+  rtems_test_exit(0);
+}
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 1000
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 3
+#define CONFIGURE_MAXIMUM_PERIODS 2
+
+#define CONFIGURE_SCHEDULER_EDF_SMP
+
+#include <rtems/scheduler.h>
+
+RTEMS_SCHEDULER_CONTEXT_EDF_SMP(a);
+
+#define CONFIGURE_SCHEDULER_CONTROLS \
+  RTEMS_SCHEDULER_CONTROL_EDF_SMP(a, rtems_build_name('E', 'D', 'F', ' '))
+
+#define CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS \
+  RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY)
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/smptests/smpschededf01/smpschededf01.doc b/testsuites/smptests/smpschededf01/smpschededf01.doc
new file mode 100644
index 0000000000..ce5d6d4121
--- /dev/null
+++ b/testsuites/smptests/smpschededf01/smpschededf01.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: smpschededf01
+
+directives:
+
+  - EDF SMP scheduler job release/cancel operations
+
+concepts:
+
+  - Ensure that a task set schedulable with EDF runs correctly.  This task set
+    is not schedulable with RMS.
diff --git a/testsuites/smptests/smpschededf01/smpschededf01.scn b/testsuites/smptests/smpschededf01/smpschededf01.scn
new file mode 100644
index 0000000000..0d8c0902d2
--- /dev/null
+++ b/testsuites/smptests/smpschededf01/smpschededf01.scn
@@ -0,0 +1,21 @@
+*** BEGIN OF TEST SMPSCHEDEDF 1 ***
+-------------------------------------------------------------------------------
+                              CPU USAGE BY THREAD
+------------+----------------------------------------+---------------+---------
+ ID         | NAME                                   | SECONDS       | PERCENT
+------------+----------------------------------------+---------------+---------
+ 0x09010001 | IDLE                                   |      0.280040 |   7.420
+ 0x0a010001 | UI1                                    |      0.014090 |   0.372
+ 0x0a010002 | T1                                     |      1.943912 |  51.413
+ 0x0a010003 | T2                                     |      1.539647 |  40.679
+------------+----------------------------------------+---------------+---------
+ TIME SINCE LAST CPU USAGE RESET IN SECONDS:                          3.784815
+-------------------------------------------------------------------------------
+Period information by period
+--- CPU times are in seconds ---
+--- Wall times are in seconds ---
+   ID     OWNER COUNT MISSED          CPU TIME                  WALL TIME
+                                    MIN/MAX/AVG                MIN/MAX/AVG
+0x42010001 T1      75      0 0.025057/0.025513/0.025233 0.025134/0.031772/0.027562
+0x42010002 T2      49      0 0.030511/0.030741/0.030615 0.049538/0.056644/0.053052
+*** END OF TEST SMPSCHEDEDF 1 ***
-- 
2.12.3




More information about the devel mailing list