7 run_one_test(
const char *t,
const char *x,
int expected) {
23 any_time_satisfies_empty_spec(
void) {
32 time_satisfies_year_spec(
void) {
33 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2020'/>",
pcmk_rc_ok);
37 time_after_year_spec(
void) {
42 time_satisfies_year_range(
void) {
43 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2010-2030'/>",
pcmk_rc_ok);
47 time_before_year_range(
void) {
52 time_after_year_range(
void) {
53 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2010-2015'/>",
pcmk_rc_after_range);
57 range_without_start_year_passes(
void) {
58 run_one_test(
"2010-01-01",
"<date_spec id='spec' years='-2020'/>",
pcmk_rc_ok);
62 range_without_end_year_passes(
void) {
63 run_one_test(
"2010-01-01",
"<date_spec id='spec' years='2000-'/>",
pcmk_rc_ok);
64 run_one_test(
"2000-10-01",
"<date_spec id='spec' years='2000-'/>",
pcmk_rc_ok);
68 yeardays_satisfies(
void) {
69 run_one_test(
"2020-01-30",
"<date_spec id='spec' yeardays='30'/>",
pcmk_rc_ok);
73 time_after_yeardays_spec(
void) {
78 yeardays_feb_29_satisfies(
void) {
79 run_one_test(
"2016-02-29",
"<date_spec id='spec' yeardays='60'/>",
pcmk_rc_ok);
83 exact_ymd_satisfies(
void) {
84 run_one_test(
"2001-12-31",
"<date_spec id='spec' years='2001' months='12' monthdays='31'/>",
pcmk_rc_ok);
88 range_in_month_satisfies(
void) {
89 run_one_test(
"2001-06-10",
"<date_spec id='spec' years='2001' months='6' monthdays='1-10'/>",
pcmk_rc_ok);
93 exact_ymd_after_range(
void) {
94 run_one_test(
"2001-12-31",
"<date_spec id='spec' years='2001' months='12' monthdays='30'/>",
pcmk_rc_after_range);
98 time_after_monthdays_range(
void) {
99 run_one_test(
"2001-06-10",
"<date_spec id='spec' years='2001' months='6' monthdays='11-15'/>",
pcmk_rc_before_range);
102 int main(
int argc,
char **argv) {
103 g_test_init(&argc, &argv, NULL);
105 g_test_add_func(
"/pengine/rules/cron_range/no_time_given", no_time_given);
106 g_test_add_func(
"/pengine/rules/cron_range/empty_spec", any_time_satisfies_empty_spec);
107 g_test_add_func(
"/pengine/rules/cron_range/year/time_satisfies", time_satisfies_year_spec);
108 g_test_add_func(
"/pengine/rules/cron_range/year/time_after", time_after_year_spec);
109 g_test_add_func(
"/pengine/rules/cron_range/range/time_satisfies_year", time_satisfies_year_range);
110 g_test_add_func(
"/pengine/rules/cron_range/range/time_before_year", time_before_year_range);
111 g_test_add_func(
"/pengine/rules/cron_range/range/time_after_year", time_after_year_range);
112 g_test_add_func(
"/pengine/rules/cron_range/range/no_start_year_passes", range_without_start_year_passes);
113 g_test_add_func(
"/pengine/rules/cron_range/range/no_end_year_passes", range_without_end_year_passes);
115 g_test_add_func(
"/pengine/rules/cron_range/yeardays/satisfies", yeardays_satisfies);
116 g_test_add_func(
"/pengine/rules/cron_range/yeardays/time_after", time_after_yeardays_spec);
117 g_test_add_func(
"/pengine/rules/cron_range/yeardays/feb_29_sasitfies", yeardays_feb_29_satisfies);
119 g_test_add_func(
"/pengine/rules/cron_range/exact/ymd_satisfies", exact_ymd_satisfies);
120 g_test_add_func(
"/pengine/rules/cron_range/range/in_month_satisfies", range_in_month_satisfies);
121 g_test_add_func(
"/pengine/rules/cron_range/exact/ymd_after_range", exact_ymd_after_range);
122 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
xmlNode * string2xml(const char *input)
Wrappers for and extensions to libxml2.
int main(int argc, char **argv)
crm_time_t * crm_time_new(const char *string)
void crm_time_free(crm_time_t *dt)