82 int len = strlen(expect);
92 if (len != strlen(str)) {
95 for (idx = 0; idx <
len; ++idx) {
96 if (expect[idx] != str[len - idx - 1]) {
103 #define MATCH_OR_FAIL(list, val, retbuf) \ 104 if (list_expect(list, val, &retbuf)) { \ 105 ast_test_status_update(test, "Expected: %s, Got: %s\n", val, ast_str_buffer(retbuf)); \ 106 return AST_TEST_FAIL; \ 109 #define MATCH_OR_FAIL_DBL(list, val, retbuf) \ 110 if (dbl_list_expect_forward(list, val, &retbuf)) { \ 111 ast_test_status_update(test, "Expected: %s, Got: %s\n", val, ast_str_buffer(retbuf)); \ 112 return AST_TEST_FAIL; \ 114 if (dbl_list_expect_reverse(list, val, &retbuf)) { \ 115 ast_test_status_update(test, "Expected reverse of: %s, Got: %s\n", val, ast_str_buffer(retbuf)); \ 116 return AST_TEST_FAIL; \ 119 #define ELEM_OR_FAIL(x,y) \ 121 ast_test_status_update(test, "Expected: %s, Got: %s\n", (x)->name, (y)->name); \ 122 return AST_TEST_FAIL; \ 134 info->name =
"ll_tests";
135 info->category =
"/main/linkedlists/";
136 info->summary =
"single linked list unit test";
138 "Test the single linked list API";
211 ast_test_status_update(
test,
"AST_LIST_REMOVE should safely return NULL asked to remove a NULL pointer from an empty list\n");
345 info->name =
"double_ll_tests";
346 info->category =
"/main/linkedlists/";
347 info->summary =
"double linked list unit test";
349 "Test the double linked list API";
420 ast_test_status_update(
test,
"AST_DLLIST_REMOVE_VERIFY should safely return NULL asked to remove a NULL pointer from an empty list\n");
#define AST_DLLIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
static int dbl_list_expect_forward(struct test_dbl_llist *test_list, const char *expect, struct ast_str **buf)
#define AST_LIST_INSERT_LIST_AFTER(head, list, elm, field)
Inserts a whole list after a specific entry in a list.
#define AST_DLLIST_TRAVERSE_BACKWARDS(head, var, field)
Loops over (traverses) the entries in a list in reverse order, starting at the end.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
#define AST_DLLIST_INSERT_BEFORE(head, listelm, elm, field)
Inserts a list entry before a given entry.
String manipulation functions.
#define AST_DLLIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define AST_DLLIST_REMOVE_VERIFY(head, elm, field)
Removes a specific node from a list if it is in the list.
struct test_val::@513 dbl_list
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
#define AST_DLLIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_DLLIST_INSERT_AFTER(head, listelm, elm, field)
Inserts a list entry after a given entry.
#define AST_TEST_REGISTER(cb)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
static int load_module(void)
#define AST_DLLIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_DLLIST_INSERT_AFTER_CURRENT(elm, field)
Inserts a list node after the current node during a traversal.
#define AST_LIST_INSERT_AFTER(head, listelm, elm, field)
Inserts a list entry after a given entry.
#define AST_DLLIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_DLLIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
A set of macros to manage doubly-linked lists.
#define AST_DLLIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
static int dbl_list_expect_reverse(struct test_dbl_llist *test_list, const char *expect, struct ast_str **buf)
#define AST_DLLIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_test_status_update(a, b, c...)
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
static int list_expect(struct test_llist *test_list, const char *expect, struct ast_str **buf)
A set of macros to manage forward-linked lists.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
#define AST_DLLIST_INSERT_BEFORE_CURRENT(elm, field)
Inserts a list node before the current node during a traversal.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define AST_DLLIST_APPEND_DLLIST(head, list, field)
Appends a whole list to the tail of a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
#define AST_TEST_UNREGISTER(cb)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
static int unload_module(void)
#define AST_DLLIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define MATCH_OR_FAIL_DBL(list, val, retbuf)
#define AST_DLLIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define ELEM_OR_FAIL(x, y)
Support for logging to various files, console and syslog Configuration in file logger.conf.
#define MATCH_OR_FAIL(list, val, retbuf)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END
Closes a safe loop traversal block.
#define AST_DLLIST_PREV(elm, field)
Returns the previous entry in the list before the given entry.
struct test_val::@512 list
#define AST_DLLIST_REMOVE_TAIL(head, field)
Removes and returns the tail node from a list.
#define AST_DLLIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_INSERT_BEFORE_CURRENT(elm, field)
Inserts a list entry before the current entry during a traversal.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DLLIST_FIRST(head)
Returns the first entry contained in a list.
#define AST_DLLIST_LAST(head)
Returns the last entry contained in a list.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define AST_DLLIST_ENTRY(type)
Declare previous/forward links inside a list entry.
#define AST_LIST_APPEND_LIST(head, list, field)
Appends a whole list to the tail of a list.
AST_TEST_DEFINE(single_ll_tests)