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) {
283 strcpy(weak->
value, value);
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,
#define ao2_t_ref(o, delta, tag)
Reference/unreference an object and return the old refcount.
static void test_obj_destructor(void *obj)
static int weakproxydestroyed
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ao2_t_cleanup(obj, tag)
#define ao2_weakproxy_set_object(weakproxy, obj, flags)
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_weakproxy_ref_object(weakproxy, delta, flags)
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
int ao2_weakproxy_unsubscribe(void *weakproxy, ao2_weakproxy_notification_cb cb, void *data, int flags)
Remove notification of real object destruction.
AST_TEST_DEFINE(astobj2_weak1)
AO2_STRING_FIELD_CMP_FN(weakproxy_str, value)
#define ao2_callback(c, flags, cb_fn, arg)
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_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
#define ao2_t_get_weakproxy(obj, tag)
#define AST_TEST_REGISTER(cb)
int ao2_weakproxy_subscribe(void *weakproxy, ao2_weakproxy_notification_cb cb, void *data, int flags)
Request notification when weakproxy points to NULL.
static int unload_module(void)
#define WEAKFIND_CHECK(c, key, var, expected)
#define ast_test_status_update(a, b, c...)
AO2_STRING_FIELD_SORT_FN(strong_str, value)
#define ao2_weakproxy_alloc(data_size, destructor_fn)
static void weakproxy_destructor(void *obj)
#define ao2_ref(o, delta)
static int load_module(void)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
static int destructor_called
#define AST_TEST_UNREGISTER(cb)
#define ao2_t_weakproxy_set_object(weakproxy, obj, flags, tag)
static void * cleanup(void *unused)
#define ao2_t_weakproxy_get_object(weakproxy, flags, tag)
static struct strong_str * alloc_str(struct ao2_container *weakcontainer, const char *value)
#define ao2_t_weakproxy_ref_object(weakproxy, delta, flags, tag)
#define ao2_replace(dst, src)
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
#define ao2_t_weakproxy_alloc(data_size, destructor_fn, tag)
#define ITERATOR_CHECK_NEXT(iter, var, expected)
static void test_obj_destroy_notify(void *obj, void *data)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
AO2_STRING_FIELD_HASH_FN(weakproxy_str, value)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_link(container, obj)