16 run_one_test(
const char *t,
const char *x,
int expected) {
32 any_time_satisfies_empty_spec(
void) {
41 time_satisfies_year_spec(
void) {
42 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2020'/>",
pcmk_rc_ok);
46 time_after_year_spec(
void) {
51 time_satisfies_year_range(
void) {
52 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2010-2030'/>",
pcmk_rc_ok);
56 time_before_year_range(
void) {
61 time_after_year_range(
void) {
62 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2010-2015'/>",
pcmk_rc_after_range);
66 range_without_start_year_passes(
void) {
67 run_one_test(
"2010-01-01",
"<date_spec id='spec' years='-2020'/>",
pcmk_rc_ok);
71 range_without_end_year_passes(
void) {
72 run_one_test(
"2010-01-01",
"<date_spec id='spec' years='2000-'/>",
pcmk_rc_ok);
73 run_one_test(
"2000-10-01",
"<date_spec id='spec' years='2000-'/>",
pcmk_rc_ok);
77 yeardays_satisfies(
void) {
78 run_one_test(
"2020-01-30",
"<date_spec id='spec' yeardays='30'/>",
pcmk_rc_ok);
82 time_after_yeardays_spec(
void) {
87 yeardays_feb_29_satisfies(
void) {
88 run_one_test(
"2016-02-29",
"<date_spec id='spec' yeardays='60'/>",
pcmk_rc_ok);
92 exact_ymd_satisfies(
void) {
93 run_one_test(
"2001-12-31",
"<date_spec id='spec' years='2001' months='12' monthdays='31'/>",
pcmk_rc_ok);
97 range_in_month_satisfies(
void) {
98 run_one_test(
"2001-06-10",
"<date_spec id='spec' years='2001' months='6' monthdays='1-10'/>",
pcmk_rc_ok);
102 exact_ymd_after_range(
void) {
103 run_one_test(
"2001-12-31",
"<date_spec id='spec' years='2001' months='12' monthdays='30'/>",
pcmk_rc_after_range);
107 time_after_monthdays_range(
void) {
108 run_one_test(
"2001-06-10",
"<date_spec id='spec' years='2001' months='6' monthdays='11-15'/>",
pcmk_rc_before_range);
111 int main(
int argc,
char **argv) {
112 g_test_init(&argc, &argv, NULL);
114 g_test_add_func(
"/pengine/rules/cron_range/no_time_given", no_time_given);
115 g_test_add_func(
"/pengine/rules/cron_range/empty_spec", any_time_satisfies_empty_spec);
116 g_test_add_func(
"/pengine/rules/cron_range/year/time_satisfies", time_satisfies_year_spec);
117 g_test_add_func(
"/pengine/rules/cron_range/year/time_after", time_after_year_spec);
118 g_test_add_func(
"/pengine/rules/cron_range/range/time_satisfies_year", time_satisfies_year_range);
119 g_test_add_func(
"/pengine/rules/cron_range/range/time_before_year", time_before_year_range);
120 g_test_add_func(
"/pengine/rules/cron_range/range/time_after_year", time_after_year_range);
121 g_test_add_func(
"/pengine/rules/cron_range/range/no_start_year_passes", range_without_start_year_passes);
122 g_test_add_func(
"/pengine/rules/cron_range/range/no_end_year_passes", range_without_end_year_passes);
124 g_test_add_func(
"/pengine/rules/cron_range/yeardays/satisfies", yeardays_satisfies);
125 g_test_add_func(
"/pengine/rules/cron_range/yeardays/time_after", time_after_yeardays_spec);
126 g_test_add_func(
"/pengine/rules/cron_range/yeardays/feb_29_sasitfies", yeardays_feb_29_satisfies);
128 g_test_add_func(
"/pengine/rules/cron_range/exact/ymd_satisfies", exact_ymd_satisfies);
129 g_test_add_func(
"/pengine/rules/cron_range/range/in_month_satisfies", range_in_month_satisfies);
130 g_test_add_func(
"/pengine/rules/cron_range/exact/ymd_after_range", exact_ymd_after_range);
131 g_test_add_func(
"/pengine/rules/cron_range/range/in_month_after", time_after_monthdays_range);
int pe_cron_range_satisfied(crm_time_t *now, xmlNode *cron_spec)
struct crm_time_s crm_time_t
int main(int argc, char **argv)
xmlNode * string2xml(const char *input)
Wrappers for and extensions to libxml2.
void free_xml(xmlNode *child)
crm_time_t * crm_time_new(const char *string)
void crm_time_free(crm_time_t *dt)