71 int notify0_called = 0;
72 int notify1_called = 0;
73 int notify2_called = 0;
74 int notify3_called = 0;
78 info->name =
"astobj2_weak1";
79 info->category =
"/main/astobj2/";
80 info->summary =
"Test ao2 weak objects";
81 info->description =
"Test ao2 weak objects.";
104 if (!notify0_called) {
120 if (weakref1 != weakref2) {
149 if (weakref1 != weakref2) {
190 if (obj1 != strong1) {
203 if (
destructor_called != 1 || notify1_called != 1 || notify2_called != 2 || notify3_called != 0) {
226 "Expected -2 from ao2_t_weakproxy_ref_object against normal ao2 object.\n");
235 if (
ao2_t_ref(obj3, -1,
"balance weakref2 ref_object") != 3) {
279 if (!weak || !strong) {
290 if (!
ao2_link(weakcontainer, weak)) {
308#define ITERATOR_CHECK_NEXT(iter, var, expected) \
310 var = ao2_iterator_next(iter); \
311 ast_test_validate_cleanup(test, var == expected, ret, cleanup); \
315#define WEAKFIND_CHECK(c, key, var, expected) \
317 var = ao2_weakproxy_find(c, key, OBJ_SEARCH_KEY, ""); \
318 ast_test_validate_cleanup(test, var == expected, ret, cleanup); \
339 info->name =
"astobj2_weak_container";
340 info->category =
"/main/astobj2/";
341 info->summary =
"Test ao2 weak containers";
342 info->description =
"Test ao2 weak containers.";
349 weakproxy_str_hash_fn,
NULL, weakproxy_str_cmp_fn);
351 strong_str_sort_fn,
NULL);
353 if (!weakcontainer || !dupcontainer) {
357 strong1 =
alloc_str(weakcontainer,
"obj1");
358 strong2 =
alloc_str(weakcontainer,
"obj2");
359 strong3 =
alloc_str(weakcontainer,
"obj3");
361 if (!strong1 || !strong2 || !strong3) {
390 ast_test_validate_cleanup(
test,
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_weakproxy_set_object(weakproxy, obj, flags)
Associate weakproxy with obj.
#define ao2_t_weakproxy_get_object(weakproxy, flags, tag)
int ao2_weakproxy_unsubscribe(void *weakproxy, ao2_weakproxy_notification_cb cb, void *data, int flags)
Remove notification of real object destruction.
int ao2_weakproxy_subscribe(void *weakproxy, ao2_weakproxy_notification_cb cb, void *data, int flags)
Request notification when weakproxy points to NULL.
#define ao2_t_ref(o, delta, tag)
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
void ao2_iterator_cleanup(struct ao2_iterator *iter)
int ao2_container_dup_weakproxy_objs(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
Copy object references associated with src container weakproxies into the dest container.
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define ao2_t_get_weakproxy(obj, tag)
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_t_weakproxy_alloc(data_size, destructor_fn, tag)
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_t_weakproxy_ref_object(weakproxy, delta, flags, tag)
#define ao2_t_cleanup(obj, tag)
#define ao2_weakproxy_alloc(data_size, destructor_fn)
Allocate an ao2_weakproxy object.
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
#define ao2_weakproxy_ref_object(weakproxy, delta, flags)
Run ao2_t_ref on the object associated with weakproxy.
#define ao2_t_weakproxy_set_object(weakproxy, obj, flags, tag)
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
static void * cleanup(void *unused)
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
static void weakproxy_destructor(void *obj)
static int destructor_called
AO2_STRING_FIELD_HASH_FN(weakproxy_str, value)
static int weakproxydestroyed
AO2_STRING_FIELD_SORT_FN(strong_str, value)
static void test_obj_destroy_notify(void *obj, void *data)
AO2_STRING_FIELD_CMP_FN(weakproxy_str, value)
#define WEAKFIND_CHECK(c, key, var, expected)
static void test_obj_destructor(void *obj)
AST_TEST_DEFINE(astobj2_weak1)
static int load_module(void)
#define ITERATOR_CHECK_NEXT(iter, var, expected)
static int unload_module(void)
static struct strong_str * alloc_str(struct ao2_container *weakcontainer, const char *value)