47 static const char long_val[] =
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
52 const char *inputs[][3] = {
53 {
"family",
"key",
"value"},
54 {
"astdbtest",
"a",
"b"},
55 {
"astdbtest",
"a",
"a"},
56 {
"astdbtest",
"b",
"a"},
57 {
"astdbtest",
"b",
"b"},
58 {
"astdbtest",
"b",
"!@#$%^&*()|+-<>?"},
61 {
"astdbtest",
"!@#$%^&*()|+-<>?",
"b"},
68 info->name =
"put_get_del";
69 info->category =
"/main/astdb/";
70 info->summary =
"ast_db_(put|get|del) unit test";
72 "Ensures that the ast_db put, get, and del functions work";
86 }
else if (strcmp(
buf, inputs[x][VALUE])) {
90 if (
ast_db_del(inputs[x][FAMILY], inputs[x][KEY])) {
102 const char *inputs[][3] = {
103 #define BASE "astdbtest" 106 #define FAM1 BASE "/" SUB1 107 #define FAM2 BASE "/" SUB2 108 {
FAM1,
"one",
"blah"},
109 {
FAM1,
"two",
"bling"},
110 {
FAM1,
"three",
"blast"},
111 {
FAM2,
"one",
"blah"},
112 {
FAM2,
"two",
"bling"},
113 {
FAM2,
"three",
"blast"},
121 info->name =
"gettree_deltree";
122 info->category =
"/main/astdb/";
123 info->summary =
"ast_db_(gettree|deltree) unit test";
125 "Ensures that the ast_db gettree and deltree functions work";
131 for (x = 0; x <
ARRAY_LEN(inputs); x++) {
143 for (cur = dbes, x = 0; cur; cur = cur->
next, x++) {
146 for (z = 0; z <
ARRAY_LEN(inputs); z++) {
148 snprintf(buf,
sizeof(buf),
"/%s/%s", inputs[z][
FAMILY], inputs[z][
KEY]);
149 if (!strcmp(buf, cur->
key) && !strcmp(inputs[z][
VALUE], cur->
data)) {
171 for (cur = dbes, x = 0; cur; cur = cur->
next, x++) {
174 for (z = 0; z <
ARRAY_LEN(inputs); z++) {
176 snprintf(buf,
sizeof(buf),
"/%s/%s", inputs[z][
FAMILY], inputs[z][
KEY]);
177 if (!strcmp(buf, cur->
key) && !strcmp(inputs[z][
VALUE], cur->
data)) {
215 info->name =
"perftest";
216 info->category =
"/main/astdb/";
217 info->summary =
"astdb performance unit test";
219 "Measure astdb performance";
225 for (x = 0; x < 100000; x++) {
226 sprintf(buf,
"%zu", x);
240 #define STR_FILL_32 "abcdefghijklmnopqrstuvwxyz123456" 244 info->name =
"put_get_long";
245 info->category =
"/main/astdb/";
246 info->summary =
"ast_db_(put|get_allocated) unit test";
248 "Ensures that the ast_db_put and ast_db_get_allocated functions work";
258 for (i = 1024; i <= 1024 * 1024 * 8; i *= 2) {
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_db_freetree(struct ast_db_entry *entry)
Free structure created by ast_db_gettree()
#define AST_TEST_REGISTER(cb)
int ast_db_get_allocated(const char *family, const char *key, char **out)
Get key value specified by family/key as a heap allocated string.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
struct ast_db_entry * next
#define ast_test_status_update(a, b, c...)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
struct ast_db_entry * ast_db_gettree(const char *family, const char *keytree)
Get a list of values within the astdb tree.
#define AST_TEST_UNREGISTER(cb)
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_TEST_DEFINE(put_get_del)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
static int unload_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Persistant data storage (akin to *doze registry)
static int load_module(void)
int ast_db_deltree(const char *family, const char *keytree)
Delete one or more entries in astdb.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
static const char long_val[]