[PATCH 6/6] test_timeperiods: Add new test that exercises get_next_invalid

Robin Sonefors robin.sonefors at op5.com
Mon May 6 18:04:33 CEST 2013


In particular, that exercises its error path.

Signed-off-by: Robin Sonefors <robin.sonefors at op5.com>
---
 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


------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1




More information about the Developers mailing list