[rtems-central commit] spec: Improve RTEMS_DEFINE_GLOBAL_SYMBOL() tests

Sebastian Huber sebh at rtems.org
Wed Sep 13 08:43:43 UTC 2023


Module:    rtems-central
Branch:    master
Commit:    1c53643205669ef1471e5cdb7650dedc14a759ce
Changeset: http://git.rtems.org/rtems-central/commit/?id=1c53643205669ef1471e5cdb7650dedc14a759ce

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Sep 12 17:53:35 2023 +0200

spec: 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.

---

 spec/rtems/basedefs/val/basedefs.yml | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/spec/rtems/basedefs/val/basedefs.yml b/spec/rtems/basedefs/val/basedefs.yml
index 36aefc6f..a0732956 100644
--- a/spec/rtems/basedefs/val/basedefs.yml
+++ b/spec/rtems/basedefs/val/basedefs.yml
@@ -438,7 +438,11 @@ test-actions:
       basedefs_get_global_symbol() which is defined in a file
       different from the file in which the gobal symbol is defined.
     code: |
-      T_step_eq_int( ${.:/step}, basedefs_get_global_symbol(), 0xabc );
+      T_step_eq_uptr(
+        ${.:/step},
+        basedefs_get_global_symbol() - (uintptr_t) &global_symbol_base,
+        0xabc
+      );
     links:
     - role: validation
       uid: ../req/declare-global-symbol-0
@@ -472,7 +476,11 @@ test-actions:
       Check that the ${../if/define-global-symbol:/name}
       macro defines a global symbol with the correct value.
     code: |
-      T_step_eq_int( ${.:/step}, (uintptr_t) global_symbol, 0xabc );
+      T_step_eq_uptr(
+        ${.:/step},
+        (uintptr_t) global_symbol - (uintptr_t) &global_symbol_base,
+        0xabc
+      );
     links:
     - role: validation
       uid: ../req/define-global-symbol-0
@@ -1454,8 +1462,12 @@ test-support: |
     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 )



More information about the vc mailing list