[rtems commit] spmisc01: Add test cases for basedefs.h stuff
Sebastian Huber
sebh at rtems.org
Fri Jun 22 04:31:25 UTC 2018
Module: rtems
Branch: master
Commit: ebc5cfda907930be0bad6e68ed5fd3060f2980d7
Changeset: http://git.rtems.org/rtems/commit/?id=ebc5cfda907930be0bad6e68ed5fd3060f2980d7
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Jun 18 07:06:01 2018 +0200
spmisc01: Add test cases for basedefs.h stuff
---
testsuites/sptests/spmisc01/init.c | 199 +++++++++++++++++++++++++++++++
testsuites/sptests/spmisc01/spmisc01.doc | 26 ++++
2 files changed, 225 insertions(+)
diff --git a/testsuites/sptests/spmisc01/init.c b/testsuites/sptests/spmisc01/init.c
index 4ff6365..4fab3f0 100644
--- a/testsuites/sptests/spmisc01/init.c
+++ b/testsuites/sptests/spmisc01/init.c
@@ -17,19 +17,218 @@
#endif
#include <rtems.h>
+#include <string.h>
#include <tmacros.h>
const char rtems_test_name[] = "SPMISC 1";
+RTEMS_INLINE_ROUTINE int inline_func(void)
+{
+ return 7;
+}
+
+RTEMS_NO_INLINE static int noinline_func(void)
+{
+ return 14;
+}
+
+RTEMS_NO_RETURN void noreturn_func(void);
+
+RTEMS_PURE static int pure_func(void)
+{
+ return 21;
+}
+
+RTEMS_SECTION(".rtemsroset.test") static int section_variable = 28;
+
+RTEMS_USED static int used_func(void)
+{
+ return 35;
+}
+
+RTEMS_USED static int used_variable;
+
+static int unused_arg_and_variable_func(RTEMS_UNUSED int arg)
+{
+ RTEMS_UNUSED int variable;
+
+ return 42;
+}
+
+typedef struct {
+ uint8_t c;
+ uint32_t i;
+} RTEMS_PACKED packed_struct;
+
+static int alias_func(void) RTEMS_ALIAS(noinline_func);
+
+int weak_alias_func(void) RTEMS_WEAK_ALIAS(noinline_func);
+
+static char aligned_variable RTEMS_ALIGNED(64);
+
+typedef struct {
+ uint8_t c;
+ uint8_t aligned_member RTEMS_ALIGNED(64);
+} aligned_member_struct;
+
+static void unreachable(void)
+{
+ if (0) {
+ RTEMS_UNREACHABLE();
+ }
+}
+
+RTEMS_PRINTFLIKE(1, 2) static int printflike_func(const char *fmt, ...)
+{
+ return 56;
+}
+
+static int obfuscate_variable(int i)
+{
+ RTEMS_OBFUSCATE_VARIABLE(i);
+ return i;
+}
+
RTEMS_DECLARE_GLOBAL_SYMBOL(a_global_symbol);
RTEMS_DEFINE_GLOBAL_SYMBOL(a_global_symbol, 0xabc);
+RTEMS_STATIC_ASSERT(0 != 1, zero_neq_one);
+
+static int array[3];
+
+typedef struct {
+ uint32_t i;
+ uint32_t j[RTEMS_ZERO_LENGTH_ARRAY];
+} zero_length_array_struct;
+
+typedef struct {
+ int a;
+ int b;
+} container_of_struct;
+
+static void container_of(void)
+{
+ container_of_struct s;
+ int *b;
+
+ b = &s.b;
+ rtems_test_assert(RTEMS_CONTAINER_OF(b, container_of_struct, b) == &s);
+}
+
+static int deconst(void)
+{
+ const int i = 70;
+ int *p;
+
+ p = RTEMS_DECONST(int *, &i);
+ return *p;
+}
+
+static int devolatile(void)
+{
+ volatile int i = 77;
+ int *p;
+
+ p = RTEMS_DEVOLATILE(int *, &i);
+ return *p;
+}
+
+static int dequalify(void)
+{
+ volatile const int i = 84;
+ int *p;
+
+ p = RTEMS_DEQUALIFY(int *, &i);
+ return *p;
+}
+
+typedef struct {
+ char a;
+ int b;
+} same_member_type_struct;
+
+typedef struct {
+ char c;
+ int d;
+} same_member_type_struct_2;
+
+RTEMS_STATIC_ASSERT(
+ RTEMS_HAVE_MEMBER_SAME_TYPE(
+ same_member_type_struct,
+ b,
+ same_member_type_struct_2,
+ d
+ ),
+ same_member_type_struct_eq
+);
+
+RTEMS_STATIC_ASSERT(
+ !RTEMS_HAVE_MEMBER_SAME_TYPE(
+ same_member_type_struct,
+ b,
+ same_member_type_struct_2,
+ c
+ ),
+ same_member_type_struct_neq
+);
+
+static int concat(void)
+{
+ return 91;
+}
+
+#define CON con
+
+#define CAT cat
+
+#define STR ing
+
static void Init(rtems_task_argument arg)
{
TEST_BEGIN();
+ rtems_test_assert(inline_func() == 7);
+ RTEMS_COMPILER_MEMORY_BARRIER();
+ rtems_test_assert(noinline_func() == 14);
+ rtems_test_assert(pure_func() == 21);
+ rtems_test_assert(section_variable == 28);
+ rtems_test_assert(unused_arg_and_variable_func(49) == 42);
+ rtems_test_assert(sizeof(packed_struct) == 5);
+ rtems_test_assert(alias_func() == 14);
+ rtems_test_assert(weak_alias_func() == 14);
+ rtems_test_assert(((uintptr_t) &aligned_variable) % 64 == 0);
+ rtems_test_assert(offsetof(aligned_member_struct, aligned_member) % 64 == 0);
+ unreachable();
+ rtems_test_assert(printflike_func("%i", 0) == 56);
+ rtems_test_assert(obfuscate_variable(63) == 63);
rtems_test_assert((uintptr_t)a_global_symbol == 0xabc);
+ rtems_test_assert(RTEMS_ARRAY_SIZE(array) == 3);
+ rtems_test_assert(sizeof(zero_length_array_struct) == 4);
+ container_of();
+ rtems_test_assert(deconst() == 70);
+ rtems_test_assert(devolatile() == 77);
+ rtems_test_assert(dequalify() == 84);
+ rtems_test_assert(
+ RTEMS_HAVE_MEMBER_SAME_TYPE(
+ same_member_type_struct,
+ b,
+ same_member_type_struct_2,
+ d
+ )
+ );
+ rtems_test_assert(
+ !RTEMS_HAVE_MEMBER_SAME_TYPE(
+ same_member_type_struct,
+ b,
+ same_member_type_struct_2,
+ c
+ )
+ );
+ rtems_test_assert(RTEMS_CONCAT(con, cat)() == 91);
+ rtems_test_assert(RTEMS_XCONCAT(CON, CAT)() == 91);
+ rtems_test_assert(strcmp(RTEMS_STRING(str), "str") == 0);
+ rtems_test_assert(strcmp(RTEMS_XSTRING(STR), "ing") == 0);
TEST_END();
rtems_test_exit(0);
}
diff --git a/testsuites/sptests/spmisc01/spmisc01.doc b/testsuites/sptests/spmisc01/spmisc01.doc
index 2654788..bcd4cd9 100644
--- a/testsuites/sptests/spmisc01/spmisc01.doc
+++ b/testsuites/sptests/spmisc01/spmisc01.doc
@@ -4,8 +4,34 @@ test set name: spbasedefs01
directives:
+ - RTEMS_ALIAS()
+ - RTEMS_ALIGNED()
+ - RTEMS_ARRAY_SIZE()
+ - RTEMS_COMPILER_MEMORY_BARRIER()
+ - RTEMS_CONCAT()
+ - RTEMS_CONTAINER_OF()
- RTEMS_DECLARE_GLOBAL_SYMBOL()
+ - RTEMS_DECONST()
- RTEMS_DEFINE_GLOBAL_SYMBOL()
+ - RTEMS_DEPRECATED
+ - RTEMS_DEQUALIFY()
+ - RTEMS_DEVOLATILE()
+ - RTEMS_HAVE_MEMBER_SAME_TYPE()
+ - RTEMS_NO_INLINE
+ - RTEMS_NO_RETURN
+ - RTEMS_OBFUSCATE_VARIABLE()
+ - RTEMS_PACKED
+ - RTEMS_PRINTFLIKE()
+ - RTEMS_PURE
+ - RTEMS_SECTION()
+ - RTEMS_STATIC_ASSERT()
+ - RTEMS_STRING()
+ - RTEMS_UNREACHABLE()
+ - RTEMS_UNUSED
+ - RTEMS_USED
+ - RTEMS_WEAK_ALIAS()
+ - RTEMS_XCONCAT()
+ - RTEMS_XSTRING()
concepts:
More information about the vc
mailing list