summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2016-07-18 19:39:39 -0400
committerCorey Farrell <git@cfware.com>2016-07-18 19:39:39 -0400
commitc8e41d14a1478b46a6c986a4c30ba2c8bdf86cd5 (patch)
tree1a40f381d57d0155665fc63aad6855507337836c
parent962c7ef5d91c546794313e01b4c264efdf3d1ead (diff)
Unit tests: Use AST_TEST_DEFINE in conditional code only.
If AST_TEST_DEFINE is not conditional to TEST_FRAMEWORK it produces dead code. This places all existing unit tests into a conditional block if they weren't already. ASTERISK-26211 #close Change-Id: I8ef83ee11cbc991b07b7a37ecb41433e8c734686
-rw-r--r--apps/app_voicemail.c2
-rw-r--r--channels/sip/config_parser.c7
-rw-r--r--channels/sip/reqresp_parser.c23
-rw-r--r--funcs/func_curl.c2
-rw-r--r--res/res_pjsip.c2
5 files changed, 33 insertions, 3 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index e88d7069c..321e5c9c0 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -12228,6 +12228,7 @@ static int append_mailbox(const char *context, const char *box, const char *data
return 0;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(test_voicemail_vmuser)
{
int res = 0;
@@ -12415,6 +12416,7 @@ AST_TEST_DEFINE(test_voicemail_vmuser)
free_user(vmu);
return res ? AST_TEST_FAIL : AST_TEST_PASS;
}
+#endif
static int vm_box_exists(struct ast_channel *chan, const char *data)
{
diff --git a/channels/sip/config_parser.c b/channels/sip/config_parser.c
index 50495427e..0feb24655 100644
--- a/channels/sip/config_parser.c
+++ b/channels/sip/config_parser.c
@@ -274,6 +274,7 @@ int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const
return 0;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_register_line_test)
{
int res = AST_TEST_PASS;
@@ -643,6 +644,7 @@ alloc_fail:
ast_test_status_update(test, "Out of memory. \n");
return res;
}
+#endif
int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum ast_transport *transport)
{
@@ -708,6 +710,7 @@ int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum a
return 0;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_host_line_test)
{
int res = AST_TEST_PASS;
@@ -787,6 +790,7 @@ AST_TEST_DEFINE(sip_parse_host_line_test)
return res;
}
+#endif
/*! \brief Parse the comma-separated nat= option values */
void sip_parse_nat_option(const char *value, struct ast_flags *mask, struct ast_flags *flags)
@@ -834,6 +838,7 @@ void sip_parse_nat_option(const char *value, struct ast_flags *mask, struct ast_
}
}
+#ifdef TEST_FRAMEWORK
#define TEST_FORCE_RPORT 1 << 0
#define TEST_COMEDIA 1 << 1
#define TEST_AUTO_FORCE_RPORT 1 << 2
@@ -904,6 +909,8 @@ AST_TEST_DEFINE(sip_parse_nat_test)
return res;
}
+#endif
+
/*! \brief SIP test registration */
void sip_config_parser_register_tests(void)
{
diff --git a/channels/sip/reqresp_parser.c b/channels/sip/reqresp_parser.c
index 31832a33a..ecfb79d0e 100644
--- a/channels/sip/reqresp_parser.c
+++ b/channels/sip/reqresp_parser.c
@@ -258,7 +258,7 @@ int parse_uri_full(char *uri, const char *scheme, char **user, char **pass,
return error;
}
-
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_uri_full_test)
{
int res = AST_TEST_PASS;
@@ -514,7 +514,7 @@ AST_TEST_DEFINE(sip_parse_uri_full_test)
return res;
}
-
+#endif
int parse_uri(char *uri, const char *scheme, char **user, char **pass,
char **hostport, char **transport) {
@@ -530,6 +530,7 @@ int parse_uri(char *uri, const char *scheme, char **user, char **pass,
return ret;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_uri_test)
{
int res = AST_TEST_PASS;
@@ -687,6 +688,7 @@ AST_TEST_DEFINE(sip_parse_uri_test)
return res;
}
+#endif
/*! \brief Get caller id name from SIP headers, copy into output buffer
*
@@ -817,6 +819,7 @@ const char *get_calleridname(const char *input, char *output, size_t outputsize)
return input;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(get_calleridname_test)
{
int res = AST_TEST_PASS;
@@ -899,6 +902,7 @@ AST_TEST_DEFINE(get_calleridname_test)
return res;
}
+#endif
int get_name_and_number(const char *hdr, char **name, char **number)
{
@@ -940,6 +944,7 @@ int get_name_and_number(const char *hdr, char **name, char **number)
return 0;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(get_name_and_number_test)
{
int res = AST_TEST_PASS;
@@ -1044,6 +1049,7 @@ AST_TEST_DEFINE(get_name_and_number_test)
return res;
}
+#endif
int get_in_brackets_const(const char *src,const char **start,int *length)
{
@@ -1176,6 +1182,7 @@ char *get_in_brackets(char *tmp)
return out;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(get_in_brackets_test)
{
int res = AST_TEST_PASS;
@@ -1252,7 +1259,7 @@ AST_TEST_DEFINE(get_in_brackets_test)
return res;
}
-
+#endif
int parse_name_andor_addr(char *uri, const char *scheme, char **name,
char **user, char **pass, char **hostport,
@@ -1298,6 +1305,7 @@ int parse_name_andor_addr(char *uri, const char *scheme, char **name,
return parse_uri_full(uri, scheme, user, pass, hostport, params, headers, residue2);
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(parse_name_andor_addr_test)
{
int res = AST_TEST_PASS;
@@ -1427,6 +1435,7 @@ AST_TEST_DEFINE(parse_name_andor_addr_test)
return res;
}
+#endif
int get_comma(char *in, char **out)
{
@@ -1523,6 +1532,7 @@ int parse_contact_header(char *contactheader, struct contactliststruct *contactl
return last;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(parse_contact_header_test)
{
int res = AST_TEST_PASS;
@@ -1668,6 +1678,7 @@ AST_TEST_DEFINE(parse_contact_header_test)
return res;
}
+#endif
/*!
* \brief Parse supported header in incoming packet
@@ -1755,6 +1766,7 @@ unsigned int parse_sip_options(const char *options, char *unsupported, size_t un
return profile;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_options_test)
{
int res = AST_TEST_PASS;
@@ -1892,6 +1904,7 @@ AST_TEST_DEFINE(sip_parse_options_test)
return res;
}
+#endif
/*! \brief helper routine for sip_uri_cmp to compare URI parameters
*
@@ -2246,6 +2259,7 @@ int sip_uri_cmp(const char *input1, const char *input2)
#define URI_CMP_MATCH 0
#define URI_CMP_NOMATCH 1
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_uri_cmp_test)
{
static const struct {
@@ -2362,6 +2376,7 @@ AST_TEST_DEFINE(sip_uri_cmp_test)
return test_res;
}
+#endif
void free_via(struct sip_via *v)
{
@@ -2448,6 +2463,7 @@ struct sip_via *parse_via(const char *header)
return v;
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(parse_via_test)
{
int res = AST_TEST_PASS;
@@ -2625,6 +2641,7 @@ AST_TEST_DEFINE(parse_via_test)
}
return res;
}
+#endif
void sip_request_parser_register_tests(void)
{
diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index 61b05900b..c7a1c6e42 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -794,6 +794,7 @@ static struct ast_custom_function acf_curlopt = {
.write = acf_curlopt_write,
};
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(vulnerable_url)
{
const char *bad_urls [] = {
@@ -841,6 +842,7 @@ AST_TEST_DEFINE(vulnerable_url)
return res;
}
+#endif
static int unload_module(void)
{
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index de8eb3e8a..40916684a 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -4118,6 +4118,7 @@ long ast_sip_threadpool_queue_size(void)
return ast_threadpool_queue_size(sip_threadpool);
}
+#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(xml_sanitization_end_null)
{
char sanitized[8];
@@ -4168,6 +4169,7 @@ AST_TEST_DEFINE(xml_sanitization_exceeds_buffer)
return AST_TEST_PASS;
}
+#endif
/*!
* \internal