Skip to content

Commit 2f32b98

Browse files
committed
Test: libcrmcommon: Fix another iso8601 test for alpine linux.
Alpine uses musl by default, which handles bare percent signs in strftime() differently. On that platform, a bare percent sign (or an unknown specifier) results in an empty string. We need to check for that and handle it in our test cases.
1 parent 1762da0 commit 2f32b98

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

lib/common/tests/iso8601/pcmk__time_format_hr_test.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,43 @@ no_specifiers(void **state)
8585
* as "%%".
8686
*/
8787
assert_hr_format("this has a literal % in it",
88+
#ifdef HAVE_STRFTIME_EMPTY_SPEC_FAILS
89+
NULL, NULL, 0);
90+
#else
8891
"this has a literal % in it",
8992
// *BSD strftime() strips single %
9093
"this has a literal in it", 0);
94+
#endif
95+
9196
assert_hr_format("this has a literal %01 in it",
97+
#ifdef HAVE_STRFTIME_EMPTY_SPEC_FAILS
98+
NULL, NULL, 0);
99+
#else
92100
"this has a literal %01 in it",
93101
// *BSD strftime() strips %0
94102
"this has a literal 1 in it", 0);
103+
#endif
104+
95105
assert_hr_format("%2 this starts and ends with %",
106+
#ifdef HAVE_STRFTIME_EMPTY_SPEC_FAILS
107+
NULL, NULL, 0);
108+
#else
96109
"%2 this starts and ends with %",
97110
// *BSD strftime() strips % in front of nonzero number
98111
"2 this starts and ends with %", 0);
112+
#endif
99113

100114
/* strftime() treats % with a number (and no specifier) as a literal string
101115
* to be formatted with a field width (undocumented and probably a bug ...)
102116
*/
103-
assert_hr_format("this ends with %10", "this ends with %10",
117+
assert_hr_format("this ends with %10",
118+
#ifdef HAVE_STRFTIME_EMPTY_SPEC_FAILS
119+
NULL, NULL, 0);
120+
#else
121+
"this ends with %10",
104122
// *BSD strftime() strips % in front of nonzero number
105123
"this ends with 10", 0);
124+
#endif
106125
}
107126

108127
static void

0 commit comments

Comments
 (0)