---
 cpukit/include/rtems/test.h        |  5 +++
 cpukit/libtest/t-test-rtems-objs.c | 54 ++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h
index b42bf5f058..10ff665107 100644
--- a/cpukit/include/rtems/test.h
+++ b/cpukit/include/rtems/test.h
@@ -36,6 +36,7 @@
 
 #ifdef __rtems__
 #include <rtems/score/cpu.h>
+#include <rtems/rtems/status.h>
 #endif
 
 #ifdef __cplusplus
@@ -2512,6 +2513,10 @@ typedef enum {
 } T_thread_timer_state;
 
 T_thread_timer_state T_get_thread_timer_state(uint32_t);
+
+void *T_seize_objects(rtems_status_code (*)(void *, uint32_t *), void *);
+
+void T_surrender_objects(void **, rtems_status_code (*)(uint32_t));
 #endif /* __rtems__ */
 
 /**
diff --git a/cpukit/libtest/t-test-rtems-objs.c 
b/cpukit/libtest/t-test-rtems-objs.c
index ad8d153154..6548848c49 100644
--- a/cpukit/libtest/t-test-rtems-objs.c
+++ b/cpukit/libtest/t-test-rtems-objs.c
@@ -410,3 +410,57 @@ T_check_rtems_timers(T_event event, const char *name)
                break;
        };
 }
+
+void *
+T_seize_objects(rtems_status_code (*create)(void *, uint32_t *), void *arg)
+{
+       void *objects;
+
+       objects = NULL;
+
+       while (true) {
+               rtems_status_code sc;
+               rtems_id id;
+
+               id = 0;
+               sc = (*create)(arg, &id);
+
+               if (sc == RTEMS_SUCCESSFUL) {
+                       const Objects_Information *info;
+                       Objects_Control *obj;
+
+                       info = _Objects_Get_information_id(id);
+                       T_quiet_assert_not_null(info);
+                       obj = _Objects_Get_no_protection(id, info);
+                       T_quiet_assert_not_null(obj);
+                       obj->Node.next = objects;
+                       objects = obj;
+               } else {
+                       T_quiet_rsc(sc, RTEMS_TOO_MANY);
+                       break;
+               }
+       }
+
+       return objects;
+}
+
+void
+T_surrender_objects(void **objects_p, rtems_status_code (*delete)(uint32_t))
+{
+       void *objects;
+
+       objects = *objects_p;
+       *objects_p = NULL;
+
+       while (objects != NULL) {
+               Objects_Control *obj;
+               rtems_status_code sc;
+
+               obj = objects;
+               objects = _Chain_Next(&obj->Node);
+               _Chain_Set_off_chain(&obj->Node);
+
+               sc = (*delete)(obj->id);
+               T_quiet_rsc_success(sc);
+       }
+}
-- 
2.26.2

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to