Remove the old stub files, preferring the optional_api method.

(closes issue #17475)
 Reported by: tilghman
 
Review: https://reviewboard.asterisk.org/r/695/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@276490 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2010-07-14 20:48:59 +00:00
parent 8e7d01d484
commit 832d1296c6
14 changed files with 525 additions and 497 deletions

View File

@@ -35,6 +35,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
#include "asterisk/utils.h"
#include "asterisk/test.h"
#include "asterisk/crypto.h"
#include "asterisk/adsi.h"
#include "asterisk/agi.h"
#include "asterisk/channel.h"
#include "asterisk/module.h"
AST_TEST_DEFINE(uri_encode_decode_test)
@@ -236,6 +240,99 @@ AST_TEST_DEFINE(base64_test)
return res;
}
AST_TEST_DEFINE(crypto_loaded_test)
{
switch (cmd) {
case TEST_INIT:
info->name = "crypto_loaded_test";
info->category = "/res/crypto/";
info->summary = "Crypto loaded into memory";
info->description = "Verifies whether the crypto functions overrode the stubs";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
}
ast_test_status_update(test,
"address of __stub__ast_crypto_loaded is %p\n",
__stub__ast_crypto_loaded);
ast_test_status_update(test,
"address of __ref__ast_crypto_loaded is %p\n",
__ref__ast_crypto_loaded);
ast_test_status_update(test,
"pointer to ast_crypto_loaded is %p\n",
ast_crypto_loaded);
return ast_crypto_loaded() ? AST_TEST_PASS : AST_TEST_FAIL;
}
AST_TEST_DEFINE(adsi_loaded_test)
{
struct ast_channel c = { .adsicpe = AST_ADSI_AVAILABLE, };
switch (cmd) {
case TEST_INIT:
info->name = "adsi_loaded_test";
info->category = "/res/adsi/";
info->summary = "ADSI loaded into memory";
info->description = "Verifies whether the adsi functions overrode the stubs";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
}
return ast_adsi_available(&c) ? AST_TEST_PASS : AST_TEST_FAIL;
}
static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, const char * const argv[])
{
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
AST_TEST_DEFINE(agi_loaded_test)
{
int res = AST_TEST_PASS;
struct agi_command noop_command =
{ { "testnoop", NULL }, handle_noop, NULL, NULL, 0 };
switch (cmd) {
case TEST_INIT:
info->name = "agi_loaded_test";
info->category = "/res/agi/";
info->summary = "AGI loaded into memory";
info->description = "Verifies whether the agi functions overrode the stubs";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
}
ast_test_status_update(test,
"address of __stub__ast_agi_register is %p\n",
__stub__ast_agi_register);
ast_test_status_update(test,
"address of __ref__ast_agi_register is %p\n",
__ref__ast_agi_register);
ast_test_status_update(test,
"pointer to ast_agi_register is %p\n",
ast_agi_register);
if (ast_agi_register(ast_module_info->self, &noop_command) == AST_OPTIONAL_API_UNAVAILABLE) {
return AST_TEST_FAIL;
}
#ifndef HAVE_NULLSAFE_PRINTF
/* Test for condition without actually crashing Asterisk */
if (noop_command.usage == NULL) {
res = AST_TEST_FAIL;
}
if (noop_command.syntax == NULL) {
res = AST_TEST_FAIL;
}
#endif
ast_agi_unregister(ast_module_info->self, &noop_command);
return res;
}
static int unload_module(void)
{
@@ -243,6 +340,9 @@ static int unload_module(void)
AST_TEST_UNREGISTER(md5_test);
AST_TEST_UNREGISTER(sha1_test);
AST_TEST_UNREGISTER(base64_test);
AST_TEST_UNREGISTER(crypto_loaded_test);
AST_TEST_UNREGISTER(adsi_loaded_test);
AST_TEST_UNREGISTER(agi_loaded_test);
return 0;
}
@@ -252,6 +352,9 @@ static int load_module(void)
AST_TEST_REGISTER(md5_test);
AST_TEST_REGISTER(sha1_test);
AST_TEST_REGISTER(base64_test);
AST_TEST_REGISTER(crypto_loaded_test);
AST_TEST_REGISTER(adsi_loaded_test);
AST_TEST_REGISTER(agi_loaded_test);
return AST_MODULE_LOAD_SUCCESS;
}