[Nagios-devel] [PATCH 2/2] Macro tests: Make test for macro

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] [PATCH 2/2] Macro tests: Make test for macro

Post by Guest »

From: Max Sikström

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
---
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






This post was automatically imported from historical nagios-devel mailing list archives
Original poster: msikstrom@op5.com
Locked