Bug in exclude timeperiods code? (t-tap/test_timeperiods.c)

Ethan Galstad egalstad at nagios.org
Thu Aug 5 01:50:58 CEST 2010


nap 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 "exclude" functionality was discovered to have some bugs that
returned an incorrect result as is currently a known issue.  A fix looks
to be difficult.  If you figure out a patch, let us know.  Thanks!

- Ethan

------------------------------------------------------------------------------
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://p.sf.net/sfu/dev2dev-palm




More information about the Developers mailing list