summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-08 11:14:27 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-15 08:37:12 +0200
commit0712d172d0bce40f3a9190af511249256ddac5f1 (patch)
treeedfe262b0e46134e3704641cac50ff9d147e9e2a /testsuites
parentscore: Simplify thread control initialization (diff)
downloadrtems-0712d172d0bce40f3a9190af511249256ddac5f1.tar.bz2
score: Task get/set affinity
Make rtems_task_get_affinity() and rtems_task_set_affinity() available on non-SMP configurations. Allow larger CPU sets.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/sptests/Makefile.am3
-rw-r--r--testsuites/sptests/configure.ac1
-rw-r--r--testsuites/sptests/spscheduler01/Makefile.am19
-rw-r--r--testsuites/sptests/spscheduler01/init.c130
-rw-r--r--testsuites/sptests/spscheduler01/spscheduler01.doc13
-rw-r--r--testsuites/sptests/spscheduler01/spscheduler01.scn2
6 files changed, 167 insertions, 1 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 1d530e2654..0477e26aa9 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -37,7 +37,8 @@ if HAS_SMP
else
SUBDIRS += sp29
endif
- SUBDIRS += spprofiling01
+SUBDIRS += spscheduler01
+SUBDIRS += spprofiling01
SUBDIRS += spfatal28
SUBDIRS += spthreadlife01
SUBDIRS += spprofiling01
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 30d2787bc7..6be14e4626 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -40,6 +40,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile
+spscheduler01/Makefile
spfatal28/Makefile
spthreadlife01/Makefile
spprofiling01/Makefile
diff --git a/testsuites/sptests/spscheduler01/Makefile.am b/testsuites/sptests/spscheduler01/Makefile.am
new file mode 100644
index 0000000000..f108426b0c
--- /dev/null
+++ b/testsuites/sptests/spscheduler01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = spscheduler01
+spscheduler01_SOURCES = init.c
+
+dist_rtems_tests_DATA = spscheduler01.scn spscheduler01.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 = $(spscheduler01_OBJECTS)
+LINK_LIBS = $(spscheduler01_LDLIBS)
+
+spscheduler01$(EXEEXT): $(spscheduler01_OBJECTS) $(spscheduler01_DEPENDENCIES)
+ @rm -f spscheduler01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spscheduler01/init.c b/testsuites/sptests/spscheduler01/init.c
new file mode 100644
index 0000000000..f8c4bb2717
--- /dev/null
+++ b/testsuites/sptests/spscheduler01/init.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@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/libcsupport.h>
+
+#include <limits.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "SPSCHEDULER 1";
+
+static rtems_id invalid_id = 1;
+
+static void test_task_get_set_affinity(void)
+{
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+ rtems_id self_id = rtems_task_self();
+ rtems_status_code sc;
+ cpu_set_t cpusetone;
+ cpu_set_t cpuset;
+ size_t big = 2 * CHAR_BIT * sizeof(cpu_set_t);
+ size_t cpusetbigsize = CPU_ALLOC_SIZE(big);
+ cpu_set_t *cpusetbigone;
+ cpu_set_t *cpusetbig;
+
+ CPU_ZERO(&cpusetone);
+ CPU_SET(0, &cpusetone);
+
+ sc = rtems_task_get_affinity(RTEMS_SELF, sizeof(cpuset), NULL);
+ rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);
+
+ sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(cpuset), NULL);
+ rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);
+
+ sc = rtems_task_get_affinity(RTEMS_SELF, 0, &cpuset);
+ rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
+
+ sc = rtems_task_set_affinity(RTEMS_SELF, 0, &cpuset);
+ rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
+
+ sc = rtems_task_get_affinity(invalid_id, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+ sc = rtems_task_set_affinity(invalid_id, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+ sc = rtems_task_get_affinity(RTEMS_SELF, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ rtems_test_assert(CPU_EQUAL(&cpuset, &cpusetone));
+
+ sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_get_affinity(self_id, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ rtems_test_assert(CPU_EQUAL(&cpuset, &cpusetone));
+
+ sc = rtems_task_set_affinity(self_id, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ cpusetbigone = CPU_ALLOC(big);
+ rtems_test_assert(cpusetbigone != NULL);
+
+ cpusetbig = CPU_ALLOC(big);
+ rtems_test_assert(cpusetbig != NULL);
+
+ CPU_ZERO_S(cpusetbigsize, cpusetbigone);
+ CPU_SET_S(0, cpusetbigsize, cpusetbigone);
+
+ sc = rtems_task_get_affinity(RTEMS_SELF, cpusetbigsize, cpusetbig);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ rtems_test_assert(CPU_EQUAL_S(cpusetbigsize, cpusetbig, cpusetbigone));
+
+ sc = rtems_task_set_affinity(RTEMS_SELF, cpusetbigsize, cpusetbig);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ CPU_FREE(cpusetbig);
+ CPU_FREE(cpusetbigone);
+#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
+}
+
+static void Init(rtems_task_argument arg)
+{
+ rtems_resource_snapshot snapshot;
+
+ TEST_BEGIN();
+
+ rtems_resource_snapshot_take(&snapshot);
+
+ test_task_get_set_affinity();
+
+ rtems_test_assert(rtems_resource_snapshot_check(&snapshot));
+
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#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/sptests/spscheduler01/spscheduler01.doc b/testsuites/sptests/spscheduler01/spscheduler01.doc
new file mode 100644
index 0000000000..00ac13e8c1
--- /dev/null
+++ b/testsuites/sptests/spscheduler01/spscheduler01.doc
@@ -0,0 +1,13 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spscheduler01
+
+directives:
+
+ - rtems_task_get_affinity()
+ - rtems_task_set_affinity()
+
+concepts:
+
+ - Ensure that the task set/get affinity functions work on non-SMP
+ configurations.
diff --git a/testsuites/sptests/spscheduler01/spscheduler01.scn b/testsuites/sptests/spscheduler01/spscheduler01.scn
new file mode 100644
index 0000000000..8c73372c49
--- /dev/null
+++ b/testsuites/sptests/spscheduler01/spscheduler01.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST SPSCHEDULER 1 ***
+*** END OF TEST SPSCHEDULER 1 ***