45 char *object_id =
NULL;
61 char *object_id =
NULL;
134 .
name =
"sorcery_realtime_test",
179 realtime_objects =
NULL;
190 info->name =
"object_create";
191 info->category =
"/res/sorcery_realtime/";
192 info->summary =
"sorcery realtime object creation unit test";
194 "Test object creation in sorcery using realtime wizard";
225 info->name =
"object_retrieve_id";
226 info->category =
"/res/sorcery_realtime/";
227 info->summary =
"sorcery object retrieval using id unit test";
229 "Test object retrieval using id in sorcery with realtime wizard";
283 info->name =
"object_retrieve_field";
284 info->category =
"/res/sorcery_realtime/";
285 info->summary =
"sorcery object retrieval using a specific field unit test";
287 "Test object retrieval using a specific field in sorcery with realtime wizard";
346 info->name =
"object_retrieve_multiple_all";
347 info->category =
"/res/sorcery_realtime/";
348 info->summary =
"sorcery multiple object retrieval unit test";
350 "Test multiple object retrieval in sorcery using realtime wizard";
402 info->name =
"object_retrieve_multiple_all_nofetch";
403 info->category =
"/res/sorcery_realtime/";
404 info->summary =
"sorcery multiple object retrieval unit test";
406 "Test multiple object retrieval in sorcery using realtime wizard";
460 info->name =
"object_retrieve_multiple_field";
461 info->category =
"/res/sorcery_realtime/";
462 info->summary =
"sorcery multiple object retrieval unit test";
464 "Test multiple object retrieval in sorcery using fields using realtime wizard";
525 info->name =
"object_retrieve_regex";
526 info->category =
"/res/sorcery_realtime/";
527 info->summary =
"sorcery multiple object retrieval using regex unit test";
529 "Test multiple object retrieval in sorcery using regular expression for matching using realtime wizard";
593 info->name =
"object_retrieve_regex_nofetch";
594 info->category =
"/res/sorcery_realtime/";
595 info->summary =
"sorcery multiple object retrieval using regex unit test";
597 "Test multiple object retrieval in sorcery using regular expression for matching using realtime wizard";
661 info->name =
"object_update";
662 info->category =
"/res/sorcery_realtime/";
663 info->summary =
"sorcery object update unit test";
665 "Test object updating in sorcery using realtime wizard";
704 }
else if ((obj->bob != obj2->bob) || (obj->joe != obj2->joe)) {
719 info->name =
"object_delete";
720 info->category =
"/res/sorcery_realtime/";
721 info->summary =
"sorcery object deletion unit test";
723 "Test object deletion in sorcery using realtime wizard";
766 info->name =
"object_delete_uncreated";
767 info->category =
"/res/sorcery_realtime/";
768 info->summary =
"sorcery object deletion unit test";
770 "Test object deletion of an uncreated object in sorcery using realtime wizard";
802 info->name =
"object_allocate_on_retrieval";
803 info->category =
"/res/sorcery_realtime/";
804 info->summary =
"sorcery object allocation upon retrieval unit test";
806 "This test creates data in a realtime backend, not through sorcery. Sorcery is then\n" 807 "instructed to retrieve an object with the id of the object that was created in the\n" 808 "realtime backend. Sorcery should be able to allocate the object appropriately";
830 if (obj->bob != 42) {
834 }
else if (obj->joe != 93) {
852 info->name =
"object_filter";
853 info->category =
"/res/sorcery_realtime/";
854 info->summary =
"sorcery object field filter unit test";
856 "This test creates data in a realtime backend, not through sorcery. In addition to\n" 857 "the object fields that have been registered with sorcery, there is data in the\n" 858 "realtime backend that is unknown to sorcery. When sorcery attempts to retrieve\n" 859 "the object from the realtime backend, the data unknown to sorcery should be\n" 860 "filtered out of the returned objectset, and the object should be successfully\n" 861 "allocated by sorcery";
884 if (obj->bob != 42) {
888 }
else if (obj->joe != 93) {
struct ast_category * ast_category_new(const char *name, const char *in_file, int lineno)
Create a category.
static struct ast_variable * realtime_sorcery(const char *database, const char *table, const struct ast_variable *fields)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ast_sorcery_object_field_register_nodoc(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object without documentation.
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.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_category * ast_category_delete(struct ast_config *cfg, struct ast_category *category)
Delete a category.
static int unload_module(void)
Structure for variables, used for configurations and for channel variables.
Perform no matching, return all objects.
static struct ast_sorcery * alloc_and_initialize_sorcery(char *table)
#define AST_TEST_REGISTER(cb)
int ast_category_exist(const struct ast_config *config, const char *category_name, const char *filter)
Check for category duplicates.
Full structure for sorcery.
int ast_config_engine_deregister(struct ast_config_engine *del)
Deregister config engine.
int ast_config_engine_register(struct ast_config_engine *newconfig)
Register config engine.
Return all matching objects.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
struct ao2_container * ast_sorcery_retrieve_by_regex(const struct ast_sorcery *sorcery, const char *type, const char *regex)
Retrieve multiple objects using a regular expression on their id.
Configuration engine structure, used to define realtime drivers.
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
struct ast_variable * ast_category_root(struct ast_config *config, char *cat)
returns the root ast_variable of a config
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
static int load_module(void)
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Type for default option handler for unsigned integers.
#define ast_test_status_update(a, b, c...)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
#define ast_variable_new(name, value, filename)
struct ast_config_engine sorcery_config_engine
struct ast_config * ast_config_new(void)
Create a new base configuration structure.
int ast_realtime_append_mapping(const char *name, const char *driver, const char *database, const char *table, int priority)
Add an explicit mapping for a family.
static int realtime_sorcery_destroy(const char *database, const char *table, const char *keyfield, const char *entity, const struct ast_variable *fields)
int ast_sorcery_delete(const struct ast_sorcery *sorcery, void *object)
Delete an object.
static struct ast_config * realtime_sorcery_multi(const char *database, const char *table, const struct ast_variable *fields)
#define ast_sorcery_internal_object_register(sorcery, type, alloc, transform, apply)
Register an internal, hidden object type.
#define AST_TEST_UNREGISTER(cb)
#define ast_sorcery_apply_default(sorcery, type, name, data)
static void * test_sorcery_object_alloc(const char *id)
Internal function to allocate a test object.
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Support for logging to various files, console and syslog Configuration in file logger.conf.
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
void ast_category_append(struct ast_config *config, struct ast_category *cat)
Appends a category to a config.
static struct ast_config * realtime_objects
Configuration structure which contains all stored objects.
static struct ast_sorcery * sorcery
int ast_variable_lists_match(const struct ast_variable *left, const struct ast_variable *right, int exact_match)
Tests 2 variable lists to see if they match.
void * ast_sorcery_copy(const struct ast_sorcery *sorcery, const void *object)
Create a copy of an object.
const struct ast_variable * ast_variable_find_variable_in_list(const struct ast_variable *list, const char *variable_name)
Gets a variable from a variable list by name.
#define ast_sorcery_open()
static int realtime_sorcery_update(const char *database, const char *table, const char *keyfield, const char *entity, const struct ast_variable *fields)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Persistant data storage (akin to *doze registry)
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
AST_TEST_DEFINE(object_create)
static void deinitialize_sorcery(struct ast_sorcery *sorcery)
Sorcery Data Access Layer API.
int ast_sorcery_update(const struct ast_sorcery *sorcery, void *object)
Update an object.
static int realtime_sorcery_store(const char *database, const char *table, const struct ast_variable *fields)