47static 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])) {
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]);
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]);
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);
241#define STR_FILL_32 "abcdefghijklmnopqrstuvwxyz123456"
245 info->name =
"put_get_long";
246 info->category =
"/main/astdb/";
247 info->summary =
"ast_db_(put|get_allocated) unit test";
249 "Ensures that the ast_db_put and ast_db_get_allocated functions work with log key and long data";
263 for (j = 0; j < 512; j +=
sizeof(
STR_FILL_32) - 1) {
267 for (i = 1024; i <= 1024 * 1024 * 8; i *= 2) {
Persistent data storage (akin to *doze registry)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
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_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
struct ast_db_entry * ast_db_gettree(const char *family, const char *keytree)
Get a list of values within the astdb tree.
int ast_db_deltree(const char *family, const char *keytree)
Delete one or more entries in astdb.
void ast_db_freetree(struct ast_db_entry *entry)
Free structure created by ast_db_gettree()
Asterisk main include file. File version handling, generic pbx functions.
Support for logging to various files, console and syslog Configuration in file logger....
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
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
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_str_create(init_len)
Create a malloc'ed dynamic length string.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
struct ast_db_entry * next
Support for dynamic strings.
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
AST_TEST_DEFINE(put_get_del)
static const char long_val[]
static int load_module(void)
static int unload_module(void)