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
changes/27/3227/1
Corey Farrell 9 years ago
parent 943bb48b59
commit cf1188a1be

@ -12307,6 +12307,7 @@ static int append_mailbox(const char *context, const char *box, const char *data
return 0; return 0;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(test_voicemail_vmuser) AST_TEST_DEFINE(test_voicemail_vmuser)
{ {
int res = 0; int res = 0;
@ -12494,6 +12495,7 @@ AST_TEST_DEFINE(test_voicemail_vmuser)
free_user(vmu); free_user(vmu);
return res ? AST_TEST_FAIL : AST_TEST_PASS; return res ? AST_TEST_FAIL : AST_TEST_PASS;
} }
#endif
static int vm_box_exists(struct ast_channel *chan, const char *data) static int vm_box_exists(struct ast_channel *chan, const char *data)
{ {

@ -274,6 +274,7 @@ int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const
return 0; return 0;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_register_line_test) AST_TEST_DEFINE(sip_parse_register_line_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -643,6 +644,7 @@ alloc_fail:
ast_test_status_update(test, "Out of memory. \n"); ast_test_status_update(test, "Out of memory. \n");
return res; return res;
} }
#endif
int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum ast_transport *transport) 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; return 0;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_host_line_test) AST_TEST_DEFINE(sip_parse_host_line_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -787,6 +790,7 @@ AST_TEST_DEFINE(sip_parse_host_line_test)
return res; return res;
} }
#endif
/*! \brief Parse the comma-separated nat= option values */ /*! \brief Parse the comma-separated nat= option values */
void sip_parse_nat_option(const char *value, struct ast_flags *mask, struct ast_flags *flags) 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_FORCE_RPORT 1 << 0
#define TEST_COMEDIA 1 << 1 #define TEST_COMEDIA 1 << 1
#define TEST_AUTO_FORCE_RPORT 1 << 2 #define TEST_AUTO_FORCE_RPORT 1 << 2
@ -904,6 +909,8 @@ AST_TEST_DEFINE(sip_parse_nat_test)
return res; return res;
} }
#endif
/*! \brief SIP test registration */ /*! \brief SIP test registration */
void sip_config_parser_register_tests(void) void sip_config_parser_register_tests(void)
{ {

@ -258,7 +258,7 @@ int parse_uri_full(char *uri, const char *scheme, char **user, char **pass,
return error; return error;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_uri_full_test) AST_TEST_DEFINE(sip_parse_uri_full_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -514,7 +514,7 @@ AST_TEST_DEFINE(sip_parse_uri_full_test)
return res; return res;
} }
#endif
int parse_uri(char *uri, const char *scheme, char **user, char **pass, int parse_uri(char *uri, const char *scheme, char **user, char **pass,
char **hostport, char **transport) { char **hostport, char **transport) {
@ -530,6 +530,7 @@ int parse_uri(char *uri, const char *scheme, char **user, char **pass,
return ret; return ret;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_uri_test) AST_TEST_DEFINE(sip_parse_uri_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -687,6 +688,7 @@ AST_TEST_DEFINE(sip_parse_uri_test)
return res; return res;
} }
#endif
/*! \brief Get caller id name from SIP headers, copy into output buffer /*! \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; return input;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(get_calleridname_test) AST_TEST_DEFINE(get_calleridname_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -899,6 +902,7 @@ AST_TEST_DEFINE(get_calleridname_test)
return res; return res;
} }
#endif
int get_name_and_number(const char *hdr, char **name, char **number) 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; return 0;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(get_name_and_number_test) AST_TEST_DEFINE(get_name_and_number_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -1044,6 +1049,7 @@ AST_TEST_DEFINE(get_name_and_number_test)
return res; return res;
} }
#endif
int get_in_brackets_const(const char *src,const char **start,int *length) 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; return out;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(get_in_brackets_test) AST_TEST_DEFINE(get_in_brackets_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -1252,7 +1259,7 @@ AST_TEST_DEFINE(get_in_brackets_test)
return res; return res;
} }
#endif
int parse_name_andor_addr(char *uri, const char *scheme, char **name, int parse_name_andor_addr(char *uri, const char *scheme, char **name,
char **user, char **pass, char **hostport, 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); return parse_uri_full(uri, scheme, user, pass, hostport, params, headers, residue2);
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(parse_name_andor_addr_test) AST_TEST_DEFINE(parse_name_andor_addr_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -1427,6 +1435,7 @@ AST_TEST_DEFINE(parse_name_andor_addr_test)
return res; return res;
} }
#endif
int get_comma(char *in, char **out) int get_comma(char *in, char **out)
{ {
@ -1523,6 +1532,7 @@ int parse_contact_header(char *contactheader, struct contactliststruct *contactl
return last; return last;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(parse_contact_header_test) AST_TEST_DEFINE(parse_contact_header_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -1668,6 +1678,7 @@ AST_TEST_DEFINE(parse_contact_header_test)
return res; return res;
} }
#endif
/*! /*!
* \brief Parse supported header in incoming packet * \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; return profile;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_options_test) AST_TEST_DEFINE(sip_parse_options_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -1892,6 +1904,7 @@ AST_TEST_DEFINE(sip_parse_options_test)
return res; return res;
} }
#endif
/*! \brief helper routine for sip_uri_cmp to compare URI parameters /*! \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_MATCH 0
#define URI_CMP_NOMATCH 1 #define URI_CMP_NOMATCH 1
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_uri_cmp_test) AST_TEST_DEFINE(sip_uri_cmp_test)
{ {
static const struct { static const struct {
@ -2362,6 +2376,7 @@ AST_TEST_DEFINE(sip_uri_cmp_test)
return test_res; return test_res;
} }
#endif
void free_via(struct sip_via *v) void free_via(struct sip_via *v)
{ {
@ -2448,6 +2463,7 @@ struct sip_via *parse_via(const char *header)
return v; return v;
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(parse_via_test) AST_TEST_DEFINE(parse_via_test)
{ {
int res = AST_TEST_PASS; int res = AST_TEST_PASS;
@ -2625,6 +2641,7 @@ AST_TEST_DEFINE(parse_via_test)
} }
return res; return res;
} }
#endif
void sip_request_parser_register_tests(void) void sip_request_parser_register_tests(void)
{ {

@ -856,6 +856,7 @@ static struct ast_custom_function acf_curlopt = {
.write = acf_curlopt_write, .write = acf_curlopt_write,
}; };
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(vulnerable_url) AST_TEST_DEFINE(vulnerable_url)
{ {
const char *bad_urls [] = { const char *bad_urls [] = {
@ -903,6 +904,7 @@ AST_TEST_DEFINE(vulnerable_url)
return res; return res;
} }
#endif
static int unload_module(void) static int unload_module(void)
{ {

@ -4154,6 +4154,7 @@ long ast_sip_threadpool_queue_size(void)
return ast_threadpool_queue_size(sip_threadpool); return ast_threadpool_queue_size(sip_threadpool);
} }
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(xml_sanitization_end_null) AST_TEST_DEFINE(xml_sanitization_end_null)
{ {
char sanitized[8]; char sanitized[8];
@ -4204,6 +4205,7 @@ AST_TEST_DEFINE(xml_sanitization_exceeds_buffer)
return AST_TEST_PASS; return AST_TEST_PASS;
} }
#endif
/*! /*!
* \internal * \internal

Loading…
Cancel
Save