Changeset ebc5cfd in rtems for testsuites
- Timestamp:
- 06/18/18 05:06:01 (6 years ago)
- Branches:
- 5, master
- Children:
- 718a84af
- Parents:
- fe46647e
- git-author:
- Sebastian Huber <sebastian.huber@…> (06/18/18 05:06:01)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (06/21/18 09:27:29)
- Location:
- testsuites/sptests/spmisc01
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
testsuites/sptests/spmisc01/init.c
rfe46647e rebc5cfd 18 18 19 19 #include <rtems.h> 20 #include <string.h> 20 21 21 22 #include <tmacros.h> … … 23 24 const char rtems_test_name[] = "SPMISC 1"; 24 25 26 RTEMS_INLINE_ROUTINE int inline_func(void) 27 { 28 return 7; 29 } 30 31 RTEMS_NO_INLINE static int noinline_func(void) 32 { 33 return 14; 34 } 35 36 RTEMS_NO_RETURN void noreturn_func(void); 37 38 RTEMS_PURE static int pure_func(void) 39 { 40 return 21; 41 } 42 43 RTEMS_SECTION(".rtemsroset.test") static int section_variable = 28; 44 45 RTEMS_USED static int used_func(void) 46 { 47 return 35; 48 } 49 50 RTEMS_USED static int used_variable; 51 52 static int unused_arg_and_variable_func(RTEMS_UNUSED int arg) 53 { 54 RTEMS_UNUSED int variable; 55 56 return 42; 57 } 58 59 typedef struct { 60 uint8_t c; 61 uint32_t i; 62 } RTEMS_PACKED packed_struct; 63 64 static int alias_func(void) RTEMS_ALIAS(noinline_func); 65 66 int weak_alias_func(void) RTEMS_WEAK_ALIAS(noinline_func); 67 68 static char aligned_variable RTEMS_ALIGNED(64); 69 70 typedef struct { 71 uint8_t c; 72 uint8_t aligned_member RTEMS_ALIGNED(64); 73 } aligned_member_struct; 74 75 static void unreachable(void) 76 { 77 if (0) { 78 RTEMS_UNREACHABLE(); 79 } 80 } 81 82 RTEMS_PRINTFLIKE(1, 2) static int printflike_func(const char *fmt, ...) 83 { 84 return 56; 85 } 86 87 static int obfuscate_variable(int i) 88 { 89 RTEMS_OBFUSCATE_VARIABLE(i); 90 return i; 91 } 92 25 93 RTEMS_DECLARE_GLOBAL_SYMBOL(a_global_symbol); 26 94 27 95 RTEMS_DEFINE_GLOBAL_SYMBOL(a_global_symbol, 0xabc); 28 96 97 RTEMS_STATIC_ASSERT(0 != 1, zero_neq_one); 98 99 static int array[3]; 100 101 typedef struct { 102 uint32_t i; 103 uint32_t j[RTEMS_ZERO_LENGTH_ARRAY]; 104 } zero_length_array_struct; 105 106 typedef struct { 107 int a; 108 int b; 109 } container_of_struct; 110 111 static void container_of(void) 112 { 113 container_of_struct s; 114 int *b; 115 116 b = &s.b; 117 rtems_test_assert(RTEMS_CONTAINER_OF(b, container_of_struct, b) == &s); 118 } 119 120 static int deconst(void) 121 { 122 const int i = 70; 123 int *p; 124 125 p = RTEMS_DECONST(int *, &i); 126 return *p; 127 } 128 129 static int devolatile(void) 130 { 131 volatile int i = 77; 132 int *p; 133 134 p = RTEMS_DEVOLATILE(int *, &i); 135 return *p; 136 } 137 138 static int dequalify(void) 139 { 140 volatile const int i = 84; 141 int *p; 142 143 p = RTEMS_DEQUALIFY(int *, &i); 144 return *p; 145 } 146 147 typedef struct { 148 char a; 149 int b; 150 } same_member_type_struct; 151 152 typedef struct { 153 char c; 154 int d; 155 } same_member_type_struct_2; 156 157 RTEMS_STATIC_ASSERT( 158 RTEMS_HAVE_MEMBER_SAME_TYPE( 159 same_member_type_struct, 160 b, 161 same_member_type_struct_2, 162 d 163 ), 164 same_member_type_struct_eq 165 ); 166 167 RTEMS_STATIC_ASSERT( 168 !RTEMS_HAVE_MEMBER_SAME_TYPE( 169 same_member_type_struct, 170 b, 171 same_member_type_struct_2, 172 c 173 ), 174 same_member_type_struct_neq 175 ); 176 177 static int concat(void) 178 { 179 return 91; 180 } 181 182 #define CON con 183 184 #define CAT cat 185 186 #define STR ing 187 29 188 static void Init(rtems_task_argument arg) 30 189 { 31 190 TEST_BEGIN(); 191 rtems_test_assert(inline_func() == 7); 192 RTEMS_COMPILER_MEMORY_BARRIER(); 193 rtems_test_assert(noinline_func() == 14); 194 rtems_test_assert(pure_func() == 21); 195 rtems_test_assert(section_variable == 28); 196 rtems_test_assert(unused_arg_and_variable_func(49) == 42); 197 rtems_test_assert(sizeof(packed_struct) == 5); 198 rtems_test_assert(alias_func() == 14); 199 rtems_test_assert(weak_alias_func() == 14); 200 rtems_test_assert(((uintptr_t) &aligned_variable) % 64 == 0); 201 rtems_test_assert(offsetof(aligned_member_struct, aligned_member) % 64 == 0); 202 unreachable(); 203 rtems_test_assert(printflike_func("%i", 0) == 56); 204 rtems_test_assert(obfuscate_variable(63) == 63); 32 205 rtems_test_assert((uintptr_t)a_global_symbol == 0xabc); 206 rtems_test_assert(RTEMS_ARRAY_SIZE(array) == 3); 207 rtems_test_assert(sizeof(zero_length_array_struct) == 4); 208 container_of(); 209 rtems_test_assert(deconst() == 70); 210 rtems_test_assert(devolatile() == 77); 211 rtems_test_assert(dequalify() == 84); 212 rtems_test_assert( 213 RTEMS_HAVE_MEMBER_SAME_TYPE( 214 same_member_type_struct, 215 b, 216 same_member_type_struct_2, 217 d 218 ) 219 ); 220 rtems_test_assert( 221 !RTEMS_HAVE_MEMBER_SAME_TYPE( 222 same_member_type_struct, 223 b, 224 same_member_type_struct_2, 225 c 226 ) 227 ); 228 rtems_test_assert(RTEMS_CONCAT(con, cat)() == 91); 229 rtems_test_assert(RTEMS_XCONCAT(CON, CAT)() == 91); 230 rtems_test_assert(strcmp(RTEMS_STRING(str), "str") == 0); 231 rtems_test_assert(strcmp(RTEMS_XSTRING(STR), "ing") == 0); 33 232 TEST_END(); 34 233 rtems_test_exit(0);
Note: See TracChangeset
for help on using the changeset viewer.