22 run_one_test(
const char *t,
const char *x,
int expected) {
33 no_time_given(
void **state) {
38 any_time_satisfies_empty_spec(
void **state) {
47 time_satisfies_year_spec(
void **state) {
48 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2020'/>",
pcmk_rc_ok);
52 time_after_year_spec(
void **state) {
57 time_satisfies_year_range(
void **state) {
58 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2010-2030'/>",
pcmk_rc_ok);
62 time_before_year_range(
void **state) {
67 time_after_year_range(
void **state) {
68 run_one_test(
"2020-01-01",
"<date_spec id='spec' years='2010-2015'/>",
pcmk_rc_after_range);
72 range_without_start_year_passes(
void **state) {
73 run_one_test(
"2010-01-01",
"<date_spec id='spec' years='-2020'/>",
pcmk_rc_ok);
77 range_without_end_year_passes(
void **state) {
78 run_one_test(
"2010-01-01",
"<date_spec id='spec' years='2000-'/>",
pcmk_rc_ok);
79 run_one_test(
"2000-10-01",
"<date_spec id='spec' years='2000-'/>",
pcmk_rc_ok);
83 yeardays_satisfies(
void **state) {
84 run_one_test(
"2020-01-30",
"<date_spec id='spec' yeardays='30'/>",
pcmk_rc_ok);
88 time_after_yeardays_spec(
void **state) {
93 yeardays_feb_29_satisfies(
void **state) {
94 run_one_test(
"2016-02-29",
"<date_spec id='spec' yeardays='60'/>",
pcmk_rc_ok);
98 exact_ymd_satisfies(
void **state) {
99 run_one_test(
"2001-12-31",
"<date_spec id='spec' years='2001' months='12' monthdays='31'/>",
pcmk_rc_ok);
103 range_in_month_satisfies(
void **state) {
104 run_one_test(
"2001-06-10",
"<date_spec id='spec' years='2001' months='6' monthdays='1-10'/>",
pcmk_rc_ok);
108 exact_ymd_after_range(
void **state) {
109 run_one_test(
"2001-12-31",
"<date_spec id='spec' years='2001' months='12' monthdays='30'/>",
pcmk_rc_after_range);
113 time_after_monthdays_range(
void **state) {
114 run_one_test(
"2001-06-10",
"<date_spec id='spec' years='2001' months='6' monthdays='11-15'/>",
pcmk_rc_before_range);
117 int main(
int argc,
char **argv) {
118 const struct CMUnitTest tests[] = {
119 cmocka_unit_test(no_time_given),
120 cmocka_unit_test(any_time_satisfies_empty_spec),
121 cmocka_unit_test(time_satisfies_year_spec),
122 cmocka_unit_test(time_after_year_spec),
123 cmocka_unit_test(time_satisfies_year_range),
124 cmocka_unit_test(time_before_year_range),
125 cmocka_unit_test(time_after_year_range),
126 cmocka_unit_test(range_without_start_year_passes),
127 cmocka_unit_test(range_without_end_year_passes),
129 cmocka_unit_test(yeardays_satisfies),
130 cmocka_unit_test(time_after_yeardays_spec),
131 cmocka_unit_test(yeardays_feb_29_satisfies),
133 cmocka_unit_test(exact_ymd_satisfies),
134 cmocka_unit_test(range_in_month_satisfies),
135 cmocka_unit_test(exact_ymd_after_range),
136 cmocka_unit_test(time_after_monthdays_range),
139 cmocka_set_message_output(CM_OUTPUT_TAP);
140 return cmocka_run_group_tests(tests, NULL, NULL);
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.
void free_xml(xmlNode *child)
int main(int argc, char **argv)
crm_time_t * crm_time_new(const char *string)
void crm_time_free(crm_time_t *dt)