aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-14 20:48:59 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-14 20:48:59 +0000
commit943f6b879d4c525c0b87c62d7cd3caa2916896a9 (patch)
tree2b34378f0a47d89598b41b610afdfbe6643fad16 /tests
parentbc8a8e4c642f07e8c5bf6adcf5a47d3073ff50b6 (diff)
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: http://svn.digium.com/svn/asterisk/trunk@276490 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'tests')
-rw-r--r--tests/test_utils.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/test_utils.c b/tests/test_utils.c
index 3f2718ff6..454b97fff 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -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;
}