]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Unit tests: Use AST_TEST_DEFINE in conditional code only. 26/3226/1
authorCorey Farrell <git@cfware.com>
Mon, 18 Jul 2016 23:39:39 +0000 (19:39 -0400)
committerCorey Farrell <git@cfware.com>
Mon, 18 Jul 2016 23:39:39 +0000 (19:39 -0400)
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

apps/app_voicemail.c
channels/sip/config_parser.c
channels/sip/reqresp_parser.c
funcs/func_curl.c
res/res_pjsip.c

index e88d7069cf45b6d832f9b035cf3d64c4a1475953..321e5c9c01cf48df54059b798e1749ae3a66cb97 100644 (file)
@@ -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) 
 {
index 50495427ed8c65769f0b85befbc94a728aaed850..0feb24655cfa9698ce9e2e43be8233c4986b9f45 100644 (file)
@@ -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)
 {
index 31832a33ad4d7cd87dfc1b683172b138eac0c5ef..ecfb79d0e771790c5cd7bd6b0d0148d1237652e1 100644 (file)
@@ -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)
 {
index 61b05900b1114878d978d510ec6812b6c0acc4c9..c7a1c6e42ed6fbf17ec21dcd354613b1b3342f7a 100644 (file)
@@ -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)
 {
index de8eb3e8a4da844788072c548aaefbaa14da7039..40916684af3eebeebf96b5abb062e1437c0f8b99 100644 (file)
@@ -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