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
This commit is contained in:
Jonathan Rose
2013-08-05 16:00:01 +00:00
parent 357b275239
commit 98b02d98f3
4 changed files with 922 additions and 4 deletions

View File

@@ -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.
*/
}