summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-11-09 01:39:13 -0500
committerCorey Farrell <git@cfware.com>2017-11-21 09:47:38 -0500
commit115f53a0fb19138f07ca0c03f06f4a557d663f1f (patch)
tree64f76356762f8da8752789e85ba1f739473007b7 /tests
parent0fd8db7ec24abfd84a4d9a87b7e677b06bf83e39 (diff)
CLI: Remove calls to ast_cli_generator.
The ability to add to localized storage cannot be supported by ast_cli_generator. The only calls to ast_cli_generator should be by functions that need to proxy the CLI generator, for example 'cli check permissions' or 'core show help'. * ast_cli_generatornummatches now retrieves the vector of matches and reports the number of elements (not including 'best' match). * test_substitution retrieves and iterates the vector. Change-Id: I8cd6b93905363cf7a33a2d2b0e2a8f8446d9f248
Diffstat (limited to 'tests')
-rw-r--r--tests/test_substitution.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/test_substitution.c b/tests/test_substitution.c
index 2635430a4..96ca29c74 100644
--- a/tests/test_substitution.c
+++ b/tests/test_substitution.c
@@ -45,6 +45,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/stringfields.h"
#include "asterisk/threadstorage.h"
#include "asterisk/test.h"
+#include "asterisk/vector.h"
static enum ast_test_result_state test_chan_integer(struct ast_test *test,
struct ast_channel *c, int *ifield, const char *expression)
@@ -227,6 +228,7 @@ AST_TEST_DEFINE(test_substitution)
struct ast_channel *c;
int i;
enum ast_test_result_state res = AST_TEST_PASS;
+ struct ast_vector_string *funcs;
switch (cmd) {
case TEST_INIT:
@@ -304,11 +306,12 @@ AST_TEST_DEFINE(test_substitution)
#undef TEST
/* For testing dialplan functions */
- for (i = 0; ; i++) {
- char *cmd = ast_cli_generator("core show function", "", i);
- if (cmd == NULL) {
- break;
- }
+ funcs = ast_cli_completion_vector("core show function", "");
+
+ /* Skip "best match" element 0 */
+ for (i = 1; funcs && i < AST_VECTOR_SIZE(funcs); i++) {
+ char *cmd = AST_VECTOR_GET(funcs, i);
+
if (strcmp(cmd, "CHANNEL") && strcmp(cmd, "CALLERID") && strncmp(cmd, "CURL", 4) &&
strncmp(cmd, "AES", 3) && strncmp(cmd, "BASE64", 6) &&
strcmp(cmd, "CDR") && strcmp(cmd, "ENV") && strcmp(cmd, "GLOBAL") &&
@@ -323,10 +326,14 @@ AST_TEST_DEFINE(test_substitution)
}
}
}
- ast_free(cmd);
}
+ if (funcs) {
+ AST_VECTOR_CALLBACK_VOID(funcs, ast_free);
+ AST_VECTOR_PTR_FREE(funcs);
+ }
ast_hangup(c);
+
return res;
}