diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-09-16 07:13:58 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-12-08 09:25:22 +0100 |
commit | b618d8cfc54f84d4ed03dc7b7fa510c872e6128a (patch) | |
tree | 324b769a7866c0ac2ce8f5208861e5207834d9a4 /testsuites | |
parent | 9736283857a54008d1dcf63c8c892942e35824a6 (diff) |
Add RTEMS linker sets
Update #2408.
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/sptests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/sptests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/sptests/splinkersets01/Makefile.am | 23 | ||||
-rw-r--r-- | testsuites/sptests/splinkersets01/init.c | 152 | ||||
-rw-r--r-- | testsuites/sptests/splinkersets01/items.c | 23 | ||||
-rw-r--r-- | testsuites/sptests/splinkersets01/sets.c | 23 | ||||
-rw-r--r-- | testsuites/sptests/splinkersets01/splinkersets01.doc | 25 | ||||
-rw-r--r-- | testsuites/sptests/splinkersets01/splinkersets01.h | 40 | ||||
-rw-r--r-- | testsuites/sptests/splinkersets01/splinkersets01.scn | 2 |
9 files changed, 290 insertions, 0 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 54b8555533..32ce1dad57 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -43,6 +43,7 @@ endif if HAS_THREADS_H _SUBDIRS += spstdthreads01 endif +_SUBDIRS += splinkersets01 _SUBDIRS += sptasknopreempt01 _SUBDIRS += spintrcritical23 _SUBDIRS += sptimecounter01 diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index e6c51b4f52..2f50ceb568 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -46,6 +46,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes") # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile +splinkersets01/Makefile spstdthreads01/Makefile spsyslock01/Makefile sptasknopreempt01/Makefile diff --git a/testsuites/sptests/splinkersets01/Makefile.am b/testsuites/sptests/splinkersets01/Makefile.am new file mode 100644 index 0000000000..ad70761f78 --- /dev/null +++ b/testsuites/sptests/splinkersets01/Makefile.am @@ -0,0 +1,23 @@ +rtems_tests_PROGRAMS = splinkersets01 +splinkersets01_SOURCES = init.c +splinkersets01_DEPENDENCIES = libsplinkersets01.a + +noinst_LIBRARIES = libsplinkersets01.a +libsplinkersets01_a_SOURCES = sets.c items.c + +dist_rtems_tests_DATA = splinkersets01.scn splinkersets01.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 = $(splinkersets01_OBJECTS) +LINK_LIBS = $(splinkersets01_LDLIBS) libsplinkersets01.a + +splinkersets01$(EXEEXT): $(splinkersets01_OBJECTS) $(splinkersets01_DEPENDENCIES) + @rm -f splinkersets01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/splinkersets01/init.c b/testsuites/sptests/splinkersets01/init.c new file mode 100644 index 0000000000..3d35a4e614 --- /dev/null +++ b/testsuites/sptests/splinkersets01/init.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2015 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.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include "tmacros.h" + +#include "splinkersets01.h" + +const char rtems_test_name[] = "SPLINKERSETS 1"; + +RTEMS_LINKER_RWSET(test_rw_i, const int *); + +RTEMS_LINKER_ROSET(test_ro_i, const int *); + +RTEMS_LINKER_RWSET_DECLARE(test_rw_i, const int *); + +RTEMS_LINKER_ROSET_DECLARE(test_ro_i, const int *); + +const int a[4]; + +const int ca[5]; + +RTEMS_LINKER_RWSET_ITEM(test_rw, const int *, a3) = &a[3]; +RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw, const int *, a2, 2) = &a[2]; +RTEMS_LINKER_RWSET_ITEM_REFERENCE(test_rw, const int *, a1); +RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw, const int *, a0, 0) = &a[0]; + +/* Items are ordered lexicographically */ +RTEMS_LINKER_RWSET_ITEM(test_rw_i, const int *, a3) = &a[3]; +RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw_i, const int *, a2, 2) = &a[2]; +RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw_i, const int *, a1, 11) = &a[1]; +RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw_i, const int *, a0, 0) = &a[0]; + +#define OZ OA + +RTEMS_LINKER_ROSET_ITEM(test_ro, const int *, ca4) = &ca[4]; +RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro, const int *, ca3, OD) = &ca[3]; +RTEMS_LINKER_ROSET_ITEM_REFERENCE(test_ro, const int *, ca2); +RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro, const int *, ca1, OB) = &ca[1]; +RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro, const int *, ca0, OZ) = &ca[0]; + +RTEMS_LINKER_ROSET_ITEM(test_ro_i, const int *, ca4) = &ca[4]; +RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro_i, const int *, ca3, OD) = &ca[3]; +RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro_i, const int *, ca2, OC) = &ca[2]; +RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro_i, const int *, ca1, OB) = &ca[1]; +RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro_i, const int *, ca0, OZ) = &ca[0]; + +/* + * Demonstrate safe (= define must exist) order definitions, otherwise typos + * are undetected and may lead to an unpredictable order. See also above OB + * vs. OZ. + */ + +#define SAFE_ORDER_A 00000 +#define SAFE_ORDER_B 00001 +#define SAFE_ORDER_C 00002 + +#define ITEM(i, o) \ + enum { test_ro_s_##i = o - o }; \ + RTEMS_LINKER_RWSET_ITEM_ORDERED(test_ro_s, const int *, i, o) = &i + +RTEMS_LINKER_RWSET(test_ro_s, const int *); + +static const int s0; +static const int s1; +static const int s2; + +ITEM(s2, SAFE_ORDER_C); +ITEM(s1, SAFE_ORDER_B); +ITEM(s0, SAFE_ORDER_A); + +static void test(void) +{ + const int * volatile *b = RTEMS_LINKER_SET_BEGIN(test_rw); + const int * volatile *e = RTEMS_LINKER_SET_END(test_rw); + const int * volatile const *cb = RTEMS_LINKER_SET_BEGIN(test_ro); + const int * volatile const *ce = RTEMS_LINKER_SET_END(test_ro); + const int * volatile *bi = RTEMS_LINKER_SET_BEGIN(test_rw_i); + const int * volatile *ei = RTEMS_LINKER_SET_END(test_rw_i); + const int * volatile const *cbi = RTEMS_LINKER_SET_BEGIN(test_ro_i); + const int * volatile const *cei = RTEMS_LINKER_SET_END(test_ro_i); + const int * volatile const *sb = RTEMS_LINKER_SET_BEGIN(test_ro_s); + const int * volatile const *se = RTEMS_LINKER_SET_END(test_ro_s); + size_t i; + + rtems_test_assert((size_t) (e - b) == RTEMS_ARRAY_SIZE(a)); + rtems_test_assert((size_t) (ce - cb) == RTEMS_ARRAY_SIZE(ca)); + rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_rw) == RTEMS_ARRAY_SIZE(a)); + rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_ro) == RTEMS_ARRAY_SIZE(ca)); + + rtems_test_assert((size_t) (ei - bi) == RTEMS_ARRAY_SIZE(a)); + rtems_test_assert((size_t) (cei - cbi) == RTEMS_ARRAY_SIZE(ca)); + rtems_test_assert((size_t) (se - sb) == 3); + rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_rw_i) == RTEMS_ARRAY_SIZE(a)); + rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_ro_i) == RTEMS_ARRAY_SIZE(ca)); + rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_ro_s) == 3); + + for (i = 0; i < RTEMS_ARRAY_SIZE(a); ++i) { + rtems_test_assert(&a[i] == b[i]); + } + + for (i = 0; i < RTEMS_ARRAY_SIZE(ca); ++i) { + rtems_test_assert(&ca[i] == cb[i]); + } + + for (i = 0; i < RTEMS_ARRAY_SIZE(a); ++i) { + rtems_test_assert(&a[i] == bi[i]); + } + + for (i = 0; i < RTEMS_ARRAY_SIZE(ca); ++i) { + rtems_test_assert(&ca[i] == cbi[i]); + } + + rtems_test_assert(&s0 == sb[0]); + rtems_test_assert(&s1 == sb[1]); + rtems_test_assert(&s2 == sb[2]); +} + +static void Init(rtems_task_argument arg) +{ + TEST_BEGIN(); + + test(); + + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/sptests/splinkersets01/items.c b/testsuites/sptests/splinkersets01/items.c new file mode 100644 index 0000000000..7ca6f53bb2 --- /dev/null +++ b/testsuites/sptests/splinkersets01/items.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015 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.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include "splinkersets01.h" + +RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw, const int *, a1, 1) = &a[1]; + +RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro, const int *, ca2, OC) = &ca[2]; diff --git a/testsuites/sptests/splinkersets01/sets.c b/testsuites/sptests/splinkersets01/sets.c new file mode 100644 index 0000000000..0cc1993925 --- /dev/null +++ b/testsuites/sptests/splinkersets01/sets.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015 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.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include "splinkersets01.h" + +RTEMS_LINKER_RWSET(test_rw, const int *); + +RTEMS_LINKER_ROSET(test_ro, const int *); diff --git a/testsuites/sptests/splinkersets01/splinkersets01.doc b/testsuites/sptests/splinkersets01/splinkersets01.doc new file mode 100644 index 0000000000..1dece7f8c2 --- /dev/null +++ b/testsuites/sptests/splinkersets01/splinkersets01.doc @@ -0,0 +1,25 @@ +This file describes the directives and concepts tested by this test set. + +test set name: splinkersets01 + +directives: + + - RTEMS_LINKER_SET_BEGIN() + - RTEMS_LINKER_SET_END() + - RTEMS_LINKER_SET_SIZE() + - RTEMS_LINKER_ROSET_DECLARE() + - RTEMS_LINKER_ROSET() + - RTEMS_LINKER_ROSET_ITEM_DECLARE() + - RTEMS_LINKER_ROSET_ITEM_REFERENCE() + - RTEMS_LINKER_ROSET_ITEM() + - RTEMS_LINKER_ROSET_ITEM_ORDERED() + - RTEMS_LINKER_RWSET_DECLARE() + - RTEMS_LINKER_RWSET() + - RTEMS_LINKER_RWSET_ITEM_DECLARE() + - RTEMS_LINKER_RWSET_ITEM_REFERENCE() + - RTEMS_LINKER_RWSET_ITEM() + - RTEMS_LINKER_RWSET_ITEM_ORDERED() + +concepts: + + - Ensure that the RTEMS linker sets work. diff --git a/testsuites/sptests/splinkersets01/splinkersets01.h b/testsuites/sptests/splinkersets01/splinkersets01.h new file mode 100644 index 0000000000..5da8ec6613 --- /dev/null +++ b/testsuites/sptests/splinkersets01/splinkersets01.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 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.com/license/LICENSE. + */ + +#ifndef SPLINKERSET01_H +#define SPLINKERSET01_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <rtems/linkersets.h> + +extern const int a[4]; + +extern const int ca[5]; + +RTEMS_LINKER_RWSET_DECLARE(test_rw, const int *); + +RTEMS_LINKER_ROSET_DECLARE(test_ro, const int *); + +RTEMS_LINKER_RWSET_ITEM_DECLARE(test_rw, const int *, a1); + +RTEMS_LINKER_ROSET_ITEM_DECLARE(test_ro, const int *, ca2); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SPLINKERSET01_H */ diff --git a/testsuites/sptests/splinkersets01/splinkersets01.scn b/testsuites/sptests/splinkersets01/splinkersets01.scn new file mode 100644 index 0000000000..36c3cd12ff --- /dev/null +++ b/testsuites/sptests/splinkersets01/splinkersets01.scn @@ -0,0 +1,2 @@ +*** BEGIN OF TEST SPLINKERSETS 1 *** +*** END OF TEST SPLINKERSETS 1 *** |