1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#######################################################
#
# Test laterthan()
#
#######################################################
body common control
{
inputs => { "../../default.cf.sub" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}
#######################################################
bundle agent test
{
classes:
# On 32-bit systems, dates before 1901-12-13 aren't representable
"after_year_1902" expression => laterthan(1902,1,1,0,0,0),
scope => "namespace";
"after_year_1902_month" expression => laterthan(1902,12,1,0,0,0),
scope => "namespace";
"after_year_1902_day" expression => laterthan(1902,12,31,0,0,0),
scope => "namespace";
"after_year_1902_hour" expression => laterthan(1902,12,31,23,0,0),
scope => "namespace";
"after_year_1902_minute" expression => laterthan(1902,12,31,23,59,0),
scope => "namespace";
"after_year_1902_second" expression => laterthan(1902,12,31,23,59,59),
scope => "namespace";
# On 32-bit systems, dates after 2038-01-18 aren't representable
"after_year_2037" expression => laterthan(2037,1,1,0,0,0),
scope => "namespace";
"after_year_2037_month" expression => laterthan(2037,12,1,0,0,0),
scope => "namespace";
"after_year_2037_day" expression => laterthan(2037,12,31,0,0,0),
scope => "namespace";
"after_year_2037_hour" expression => laterthan(2037,12,31,23,0,0),
scope => "namespace";
"after_year_2037_minute" expression => laterthan(2037,12,31,23,59,0),
scope => "namespace";
"after_year_2037_second" expression => laterthan(2037,12,31,23,59,59),
scope => "namespace";
}
#######################################################
bundle agent check
{
vars:
DEBUG::
# The date and time now, in laterthan-compatible format:
"present" string => execresult("$(G.date) +(%Y,%m,%d,%H,%M,%S)", "noshell");
# NB: shell would try to sub-shell on this (...), hence noshell.
classes:
"check_after_year_1902" and => {
"after_year_1902",
"after_year_1902_month",
"after_year_1902_day",
"after_year_1902_hour",
"after_year_1902_minute",
"after_year_1902_second"
};
"check_after_year_2037" or => {
"after_year_2037",
"after_year_2037_month",
"after_year_2037_day",
"after_year_2037_hour",
"after_year_2037_minute",
"after_year_2037_second"
};
"ok" expression => "check_after_year_1902.!check_after_year_2037";
reports:
DEBUG.!after_year_1902::
"Failed laterthan(1902,1,1,0,0,0); year";
DEBUG.!after_year_1902_month::
"Failed laterthan(1902,12,1,0,0,0); month";
DEBUG.!after_year_1902_day::
"Failed laterthan(1902,12,31,0,0,0); day";
DEBUG.!after_year_1902_hour::
"Failed laterthan(1902,12,31,23,0,0); hour";
DEBUG.!after_year_1902_minute::
"Failed laterthan(1902,12,31,23,59,0); minute";
DEBUG.!after_year_1902_second::
"Failed laterthan(1902,12,31,23,59,59); second";
DEBUG.after_year_2037::
"Satisfied laterthan(2037,1,1,0,0,0); year";
DEBUG.after_year_2037_month::
"Satisfied laterthan(2037,12,1,0,0,0); month";
DEBUG.after_year_2037_day::
"Satisfied laterthan(2037,12,31,0,0,0); day";
DEBUG.after_year_2037_hour::
"Satisfied laterthan(2037,12,31,23,0,0); hour";
DEBUG.after_year_2037_minute::
"Satisfied laterthan(2037,12,31,23,59,0); minute";
DEBUG.after_year_2037_second::
"Satisfied laterthan(2037,12,31,23,59,59); second";
DEBUG.!ok::
"The time now is '$(present)'";
ok::
"$(this.promise_filename) Pass";
!ok::
"$(this.promise_filename) FAIL";
}
|