summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-09-12 16:42:13 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-09-13 07:45:35 +0200
commitd7a6e803984e5508c30aa9e3625c76460beb807b (patch)
tree19382632dfd4e54d4719774693fadc513a6368d4 /testsuites
parentscore: Fix RTEMS_DEFINE_GLOBAL_SYMBOL() (diff)
downloadrtems-d7a6e803984e5508c30aa9e3625c76460beb807b.tar.bz2
tests: Improve RTEMS_DEFINE_GLOBAL_SYMBOL() tests
Use a symbol value relative to an existing symbol address to make the test work on more code models. Update #4953.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/sptests/spmisc01/init.c11
-rw-r--r--testsuites/validation/tc-basedefs.c18
2 files changed, 24 insertions, 5 deletions
diff --git a/testsuites/sptests/spmisc01/init.c b/testsuites/sptests/spmisc01/init.c
index 62b2f69dbc..8c46245af9 100644
--- a/testsuites/sptests/spmisc01/init.c
+++ b/testsuites/sptests/spmisc01/init.c
@@ -122,9 +122,14 @@ static int obfuscate_variable(int i)
return i;
}
+static int global_symbol_base;
+
RTEMS_DECLARE_GLOBAL_SYMBOL(a_global_symbol);
-RTEMS_DEFINE_GLOBAL_SYMBOL(a_global_symbol, 0xabc);
+RTEMS_DEFINE_GLOBAL_SYMBOL(
+ a_global_symbol,
+ RTEMS_SYMBOL_NAME(global_symbol_base) + 0xabc
+);
RTEMS_STATIC_ASSERT(0 != 1, zero_neq_one);
@@ -243,7 +248,9 @@ static void Init(rtems_task_argument arg)
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(
+ (uintptr_t) a_global_symbol - (uintptr_t) &global_symbol_base == 0xabc
+ );
rtems_test_assert(RTEMS_ARRAY_SIZE(array) == 3);
rtems_test_assert(sizeof(zero_length_array_struct) == 4);
container_of();
diff --git a/testsuites/validation/tc-basedefs.c b/testsuites/validation/tc-basedefs.c
index 94600f5241..28c11af505 100644
--- a/testsuites/validation/tc-basedefs.c
+++ b/testsuites/validation/tc-basedefs.c
@@ -527,8 +527,12 @@ RTEMS_COMPILER_PURE_ATTRIBUTE static int compiler_pure_attribute_func( void )
return 21;
}
+static int global_symbol_base;
+
RTEMS_DEFINE_GLOBAL_SYMBOL(
- GLOBAL_SYMBOL, GLOBAL_SYMBOL_VALULE( abc ) );
+ GLOBAL_SYMBOL,
+ RTEMS_SYMBOL_NAME( global_symbol_base ) + GLOBAL_SYMBOL_VALULE( abc )
+);
static int deprecated_func( int i ) RTEMS_DEPRECATED;
static int deprecated_func( int i )
@@ -1055,7 +1059,11 @@ static void RtemsBasedefsValBasedefs_Action_18( void )
* which is defined in a file different from the file in which the gobal
* symbol is defined.
*/
- T_step_eq_int( 45, basedefs_get_global_symbol(), 0xabc );
+ T_step_eq_uptr(
+ 45,
+ basedefs_get_global_symbol() - (uintptr_t) &global_symbol_base,
+ 0xabc
+ );
}
/**
@@ -1089,7 +1097,11 @@ static void RtemsBasedefsValBasedefs_Action_20( void )
* Check that the RTEMS_DEFINE_GLOBAL_SYMBOL() macro defines a global symbol
* with the correct value.
*/
- T_step_eq_int( 49, (uintptr_t) global_symbol, 0xabc );
+ T_step_eq_uptr(
+ 49,
+ (uintptr_t) global_symbol - (uintptr_t) &global_symbol_base,
+ 0xabc
+ );
}
/**