[asterisk-commits] Unit tests: Use AST TEST DEFINE in conditional code only. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 20 11:31:52 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: Unit tests: Use AST_TEST_DEFINE in conditional code only.
......................................................................


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
---
M apps/app_voicemail.c
M channels/sip/config_parser.c
M channels/sip/reqresp_parser.c
M funcs/func_curl.c
M res/res_pjsip.c
5 files changed, 33 insertions(+), 3 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 6607f52..894038b 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -12307,6 +12307,7 @@
 	return 0;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(test_voicemail_vmuser)
 {
 	int res = 0;
@@ -12494,6 +12495,7 @@
 	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 56d04b2..036f7f7 100644
--- a/channels/sip/config_parser.c
+++ b/channels/sip/config_parser.c
@@ -274,6 +274,7 @@
 	return 0;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(sip_parse_register_line_test)
 {
 	int res = AST_TEST_PASS;
@@ -643,6 +644,7 @@
 	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 @@
 	return 0;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(sip_parse_host_line_test)
 {
 	int res = AST_TEST_PASS;
@@ -787,6 +790,7 @@
 	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 @@
 	}
 }
 
+#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 @@
 
 	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 298b8cb..358d6e5 100644
--- a/channels/sip/reqresp_parser.c
+++ b/channels/sip/reqresp_parser.c
@@ -258,7 +258,7 @@
 	return error;
 }
 
-
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(sip_parse_uri_full_test)
 {
 	int res = AST_TEST_PASS;
@@ -514,7 +514,7 @@
 
 	return res;
 }
-
+#endif
 
 int parse_uri(char *uri, const char *scheme, char **user, char **pass,
 	      char **hostport, char **transport) {
@@ -530,6 +530,7 @@
 	return ret;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(sip_parse_uri_test)
 {
 	int res = AST_TEST_PASS;
@@ -687,6 +688,7 @@
 
 	return res;
 }
+#endif
 
 /*! \brief  Get caller id name from SIP headers, copy into output buffer
  *
@@ -817,6 +819,7 @@
 	return input;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(get_calleridname_test)
 {
 	int res = AST_TEST_PASS;
@@ -899,6 +902,7 @@
 
 	return res;
 }
+#endif
 
 int get_name_and_number(const char *hdr, char **name, char **number)
 {
@@ -940,6 +944,7 @@
 	return 0;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(get_name_and_number_test)
 {
 	int res = AST_TEST_PASS;
@@ -1044,6 +1049,7 @@
 
 	return res;
 }
+#endif
 
 int get_in_brackets_const(const char *src,const char **start,int *length)
 {
@@ -1176,6 +1182,7 @@
 	return out;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(get_in_brackets_test)
 {
 	int res = AST_TEST_PASS;
@@ -1252,7 +1259,7 @@
 
 	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 @@
 	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 @@
 
 	return res;
 }
+#endif
 
 int get_comma(char *in, char **out)
 {
@@ -1523,6 +1532,7 @@
 	return last;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(parse_contact_header_test)
 {
 	int res = AST_TEST_PASS;
@@ -1668,6 +1678,7 @@
 
 	return res;
 }
+#endif
 
 /*!
  * \brief Parse supported header in incoming packet
@@ -1755,6 +1766,7 @@
 	return profile;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(sip_parse_options_test)
 {
 	int res = AST_TEST_PASS;
@@ -1892,6 +1904,7 @@
 
 	return res;
 }
+#endif
 
 /*! \brief helper routine for sip_uri_cmp to compare URI parameters
  *
@@ -2246,6 +2259,7 @@
 #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 @@
 
 	return test_res;
 }
+#endif
 
 void free_via(struct sip_via *v)
 {
@@ -2448,6 +2463,7 @@
 	return v;
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(parse_via_test)
 {
 	int res = AST_TEST_PASS;
@@ -2625,6 +2641,7 @@
 	}
 	return res;
 }
+#endif
 
 void sip_request_parser_register_tests(void)
 {
diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index 6a8c367..8ec1032 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -856,6 +856,7 @@
 	.write = acf_curlopt_write,
 };
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(vulnerable_url)
 {
 	const char *bad_urls [] = {
@@ -903,6 +904,7 @@
 
 	return res;
 }
+#endif
 
 static int unload_module(void)
 {
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index af2f937..882f578 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -4154,6 +4154,7 @@
 	return ast_threadpool_queue_size(sip_threadpool);
 }
 
+#ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(xml_sanitization_end_null)
 {
 	char sanitized[8];
@@ -4204,6 +4205,7 @@
 
 	return AST_TEST_PASS;
 }
+#endif
 
 /*!
  * \internal

-- 
To view, visit https://gerrit.asterisk.org/3227
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8ef83ee11cbc991b07b7a37ecb41433e8c734686
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list