diff options
author | Jonathan Rose <jrose@digium.com> | 2013-08-05 16:00:01 +0000 |
---|---|---|
committer | Jonathan Rose <jrose@digium.com> | 2013-08-05 16:00:01 +0000 |
commit | 98b02d98f389d922da568882cd3f350fe28b473d (patch) | |
tree | 57611025b10e29a395a353c86327c7bdf370f46b /res/res_parking.c | |
parent | 357b275239d2e461cd2a3dbaf4d091932824abd4 (diff) |
res_parking: Unit tests
Adds the following unit tests:
* create_lot: tests adding and removal of a new parking lot (baseline)
* park_extensions: creates a parking lot that registers extensions and
then confirms that all of the expected extensions exist
* extensions_conflicts: creates numerous parking lots to test that
extension conflicts in parking lots result in parking lot
creation failing
* dynamic_parking_variables: Tests that the creation of dynamic
parking lots respects the related channel variables set on the
channel that requests them.
* park_call: Tests adding a channel to a parking lot's holding bridge
by standard parking functions.
* retrieve_call: Tests pulling a channel out of a parking lot's
holding bridge via parked call retrieval functions.
(closes issue ASTERISK-22138)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2714/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396175 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_parking.c')
-rw-r--r-- | res/res_parking.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/res/res_parking.c b/res/res_parking.c index f0381821d..668ed63a4 100644 --- a/res/res_parking.c +++ b/res/res_parking.c @@ -432,6 +432,13 @@ static void *parking_lot_cfg_alloc(const char *cat) return lot_cfg; } +#if defined(TEST_FRAMEWORK) +struct parking_lot_cfg *parking_lot_cfg_create(const char *cat) +{ + return parking_lot_cfg_alloc(cat); +} +#endif + /*! * XXX This is actually incredibly generic and might be better placed in something like astobj2 if there isn't already an equivalent * \brief find an item in a container by its name @@ -928,7 +935,7 @@ static struct parking_lot_cfg *clone_parkinglot_cfg(struct parking_lot_cfg *sour return cfg; } -struct parking_lot *parking_create_dynamic_lot(const char *name, struct ast_channel *chan) +static struct parking_lot *create_dynamic_lot_full(const char *name, struct ast_channel *chan, int forced) { RAII_VAR(struct parking_lot_cfg *, cfg, NULL, ao2_cleanup); RAII_VAR(struct parking_lot *, template_lot, NULL, ao2_cleanup); @@ -942,7 +949,7 @@ struct parking_lot *parking_create_dynamic_lot(const char *name, struct ast_chan int dyn_start; int dyn_end; - if (!parking_dynamic_lots_enabled()) { + if (!forced && !parking_dynamic_lots_enabled()) { return NULL; } @@ -1017,6 +1024,16 @@ struct parking_lot *parking_create_dynamic_lot(const char *name, struct ast_chan return lot; } +struct parking_lot *parking_create_dynamic_lot(const char *name, struct ast_channel *chan){ + return create_dynamic_lot_full(name, chan, 0); +} + +#if defined(TEST_FRAMEWORK) +struct parking_lot *parking_create_dynamic_lot_forced(const char *name, struct ast_channel *chan) { + return create_dynamic_lot_full(name, chan, 1); +} +#endif + /* Preapply */ static int verify_default_parking_lot(void) @@ -1208,9 +1225,14 @@ static int load_module(void) goto error; } + if (load_parking_tests()) { + goto error; + } + return AST_MODULE_LOAD_SUCCESS; error: + /* XXX errored loads don't currently do a good job of cleaning up after themselves */ ao2_cleanup(parking_lot_container); aco_info_destroy(&cfg_info); return AST_MODULE_LOAD_DECLINE; @@ -1240,6 +1262,7 @@ static int unload_module(void) * destroy existing parking lots * uninstall parking related bridge features * remove extensions owned by the parking registrar + * unload currently loaded unit tests, CLI/AMI commands, etc. */ } |