[PATCH 2/2] Macro tests: Make test for macro generation match updates in macro code

Max Sikstrom max.sikstrom at op5.com
Mon Aug 5 14:12:31 CEST 2013


From: Max Sikström <msikstrom at op5.com>

Earlier macro code broke conisitancy with the documentation. Previous commit
fixed that inconsitancy, so lets patch the tests to match

Signed-off-by: Max Sikström <msikstrom at op5.com>
---
 t-tap/test_macros.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/t-tap/test_macros.c b/t-tap/test_macros.c
index ebc6a03..87edd02 100644
--- a/t-tap/test_macros.c
+++ b/t-tap/test_macros.c
@@ -109,7 +109,7 @@ int handle_async_host_check_result(host *temp_host,
 
 host test_host = { .name = "name'&%", .address = "address'&%", .notes_url =
 		"notes_url'&%($HOSTNOTES$)", .notes = "notes'&%($HOSTACTIONURL$)",
-		.action_url = "action_url'&%" };
+		.action_url = "action_url'&%", .plugin_output = "name'&%" };
 
 /*****************************************************************************/
 /*                             Helper functions                              */
@@ -152,16 +152,19 @@ void test_escaping(nagios_macros *mac) {
 	/* Nothing should be changed... options == 0 */
 	RUN_MACRO_TEST( "$HOSTNAME$ '&%", "name'&% '&%", 0);
 
+	/* Nothing should be changed... HOSTNAME doesn't accept STRIP_ILLEGAL_MACRO_CHARS */
+	RUN_MACRO_TEST( "$HOSTNAME$ '&%", "name'&% '&%", STRIP_ILLEGAL_MACRO_CHARS);
+
 	/* ' and & should be stripped from the macro, according to
 	 * init_environment(), but not from the initial string
 	 */
-	RUN_MACRO_TEST( "$HOSTNAME$ '&%", "name% '&%", STRIP_ILLEGAL_MACRO_CHARS);
+	RUN_MACRO_TEST( "$HOSTOUTPUT$ '&%", "name% '&%", STRIP_ILLEGAL_MACRO_CHARS);
 
 	/* ESCAPE_MACRO_CHARS doesn't seem to do anything... exist always in pair
 	 * with STRIP_ILLEGAL_MACRO_CHARS
 	 */
-	RUN_MACRO_TEST( "$HOSTNAME$ '&%", "name'&% '&%", ESCAPE_MACRO_CHARS);
-	RUN_MACRO_TEST( "$HOSTNAME$ '&%", "name% '&%",
+	RUN_MACRO_TEST( "$HOSTOUTPUT$ '&%", "name'&% '&%", ESCAPE_MACRO_CHARS);
+	RUN_MACRO_TEST( "$HOSTOUTPUT$ '&%", "name% '&%",
 			STRIP_ILLEGAL_MACRO_CHARS | ESCAPE_MACRO_CHARS);
 
 	/* $HOSTNAME$ should be url-encoded, but not the tailing chars */
@@ -174,12 +177,13 @@ void test_escaping(nagios_macros *mac) {
 	RUN_MACRO_TEST( "$HOSTNOTESURL$ '&%",
 			"notes_url'&%(notes%27%26%25%28action_url%27%26%25%29) '&%", 0);
 
-	/* '& in the source string should be removed, as in the url. the macros
+	/* '& in the source string shouldn't be removed, because HOSTNOTESURL
+	 * doesn't accept STRIP_ILLEGAL_MACRO_CHARS, as in the url. the macros
 	 * included in the string should be url-encoded, and therefore not contain &
 	 * and '
 	 */
 	RUN_MACRO_TEST( "$HOSTNOTESURL$ '&%",
-			"notes_url%(notes%27%26%25%28action_url%27%26%25%29) '&%",
+			"notes_url'&%(notes%27%26%25%28action_url%27%26%25%29) '&%",
 			STRIP_ILLEGAL_MACRO_CHARS);
 
 	/* This should double-encode some chars ($HOSTNOTESURL$ should contain
-- 
1.7.1


------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list