Page 1 of 1

[Nagios-devel] [PATCH 6/6] test_timeperiods: Add new test that

Posted: Mon May 06, 2013 3:21 pm
by Guest
In particular, that exercises its error path.

Signed-off-by: Robin Sonefors
---
t-tap/smallconfig/minimal.cfg | 6 ++++++
t-tap/test_timeperiods.c | 10 ++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/t-tap/smallconfig/minimal.cfg b/t-tap/smallconfig/minimal.cfg
index 0615efa..010e584 100644
--- a/t-tap/smallconfig/minimal.cfg
+++ b/t-tap/smallconfig/minimal.cfg
@@ -192,6 +192,12 @@ define timeperiod{
}


+define timeperiod{
+ timeperiod_name exclude_always
+ alias exclude_always
+ monday 00:00-24:00
+ exclude 24x7
+}

define contact {
contact_name nagiosadmin
diff --git a/t-tap/test_timeperiods.c b/t-tap/test_timeperiods.c
index 6aa292f..bf35514 100644
--- a/t-tap/test_timeperiods.c
+++ b/t-tap/test_timeperiods.c
@@ -95,7 +95,7 @@ int main(int argc, char **argv) {
int is_valid_time = 0;
int iterations = 1000;

- plan_tests(6043);
+ plan_tests(6046);

/* reset program variables */
reset_variables();
@@ -230,7 +230,13 @@ int main(int argc, char **argv) {
_get_next_valid_time(test_time, &chosen_valid_time, temp_timeperiod);
ok(chosen_valid_time == 1283265000, "Next valid time should be Tue Aug 31 16:30:00 2010, was %s", ctime(&chosen_valid_time));

-
+ temp_timeperiod = find_timeperiod("exclude_always");
+ ok(temp_timeperiod != NULL, "Testing exclude always");
+ test_time = 1278939600; //mon jul 12 15:00:00
+ is_valid_time = check_time_against_period(test_time, temp_timeperiod);
+ ok(is_valid_time == ERROR, "12 Jul 2010 15:00:00 should not be valid");
+ _get_next_valid_time(test_time, &chosen_valid_time, temp_timeperiod);
+ ok(chosen_valid_time == test_time, "There should be no next valid time, was %s", ctime(&chosen_valid_time));


/* Back to New york */
--
1.7.11.7






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