Bug in exclude timeperiods code? (t-tap/test_timeperiods.c)
nap
naparuba at gmail.com
Mon Jul 26 09:13:53 CEST 2010
Hi,
I see in the Changelog that the correction was for hour change, not
for exclude (http://nagios.org/development/history/core-3x "Don't use
these for now - we'll get this fixed for 3.4"). So it's ok, I'll find
another way.
Jean
On Fri, Jul 23, 2010 at 4:56 PM, nap <naparuba at gmail.com> wrote:
> Hi,
>
> If I'm not wrong the exclude timeperiod feature now working in the
> HEAD since the last stable version. I try to add a test case with it
> in test_timeperiods.c but I don't think I've got the good result :
>
> I add in t-tap/smallconfig/minimal.cfg theses timeperiods :
> define timeperiod{
> timeperiod_name Test_exclude
> alias Test for exclude timeperiod
> tuesday -1 - monday 1 16:30-24:00
> exclude myexclude
> }
>
>
> define timeperiod{
> timeperiod_name myexclude
> alias myexclude
> april 1 - august 16 00:00-24:00
> saturday -1 - monday 1 16:00-24:00
> }
>
>
> And in the file t-tap/test_timeperiods.c line 404:
>
> /* Tests around clock change going back for TZ=Europe/London.
> 1256511661 = Sun Oct
> 25 23:01:01 2009 */
> /* A little trip to Paris*/
> putenv("TZ=Europe/Paris");
> tzset();
> temp_timeperiod = find_timeperiod("Test_exclude");
> ok(temp_timeperiod!=NULL, "ME: Testing Exclude timeperiod");
> test_time=1278939600;
> /* printf("Testing at time %s", ctime(&test_time)); */
> is_valid_time = check_time_against_period(test_time, temp_timeperiod);
> ok( is_valid_time==ERROR, "ME: 12 Jul 2010 15:00:00 - false" );
> _get_next_valid_time(test_time, test_time, &chosen_valid_time,
> temp_timeperiod);
> /* printf("ME: Got chosent time at %s", ctime(&chosen_valid_time)); */
> ok( chosen_valid_time==1288103400, "ME: Next valid time=Tue
> Oct 26 16:30:00 2010 -> Bug in exclude?");
>
> /* printf("ME Got ask %lu and get %lu\n", test_time,
> chosen_valid_time); */
>
> /* Back to New york */
> putenv("TZ=America/New_York");
> tzset();
>
>
> The good result should be Tue Oct 26 16:30:00 2010.
>
> We are checking the next valid time for Monday 12 Jul 2010 15:00:00.
> It's not valid (it's july tuesday -1 is Tue Jul 27 16:30:00 2010 the
> first time available without exclude).
> So by months:
> *july 27 is not possible because we got nothing until 16 august.
> *august : it's the Tues Aug 31, but it's inside "saturday -1 -
> monday 1" because saturday -1 is the 28 august, so no.
> *september : can be the 28, but saturday -1 is the 25, so still no
> *october : now tuesday -1 is 26 and saturday -1 is 30. So ok, it's this one :)
>
> Is is my test false or a bug in the get next valid time with exclude?
>
> Maybe we can try with a less hard case (but I need to run take baby
> from the babysitter, so it will be the next week ;) )
>
> Thanks,
>
>
> Jean
>
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
More information about the Developers
mailing list