Change ATF_REQUIRE_MSG calls to ATF_CHECK_MSG to get as many errors as possible

t_strptime:common..
- Expect the testcase body as a whole to fail. Multiple PRs will be filed to
track the issues (there are 18 check failures)

t_strptime:day..
- %EA and %OA seem to be case insensitive on FreeBSD
This commit is contained in:
Enji Cooper 2014-10-13 03:55:47 +00:00
parent 13727fa5e8
commit e58fb51fc7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273025

View File

@ -49,6 +49,17 @@ h_pass(const char *buf, const char *fmt, int len,
exp = buf + len;
ret = strptime(buf, fmt, &tm);
#if defined(__FreeBSD__)
ATF_CHECK_MSG(ret == exp,
"strptime(\"%s\", \"%s\", tm): incorrect return code: "
"expected: %p, got: %p", buf, fmt, exp, ret);
#define H_REQUIRE_FIELD(field) \
ATF_CHECK_MSG(tm.field == field, \
"strptime(\"%s\", \"%s\", tm): incorrect %s: " \
"expected: %d, but got: %d", buf, fmt, \
___STRING(field), field, tm.field)
#else
ATF_REQUIRE_MSG(ret == exp,
"strptime(\"%s\", \"%s\", tm): incorrect return code: "
"expected: %p, got: %p", buf, fmt, exp, ret);
@ -58,6 +69,7 @@ h_pass(const char *buf, const char *fmt, int len,
"strptime(\"%s\", \"%s\", tm): incorrect %s: " \
"expected: %d, but got: %d", buf, fmt, \
___STRING(field), field, tm.field)
#endif
H_REQUIRE_FIELD(tm_sec);
H_REQUIRE_FIELD(tm_min);
@ -76,8 +88,13 @@ h_fail(const char *buf, const char *fmt)
{
struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
#if defined(__FreeBSD__)
ATF_CHECK_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", "
"\"%s\", &tm) should fail, but it didn't", buf, fmt);
#else
ATF_REQUIRE_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", "
"\"%s\", &tm) should fail, but it didn't", buf, fmt);
#endif
}
ATF_TC(common);
@ -91,6 +108,10 @@ ATF_TC_HEAD(common, tc)
ATF_TC_BODY(common, tc)
{
#if defined(__FreeBSD__)
atf_tc_expect_fail("There are various issues with strptime on FreeBSD");
#endif
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
24, 46, 27, 23, 20, 0, 98, 2, -1);
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
@ -168,9 +189,17 @@ ATF_TC_BODY(day, tc)
h_pass("mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
h_pass("tueSDay", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
h_pass("sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
#if defined(__NetBSD__)
h_fail("sunday", "%EA");
#else
h_pass("Sunday", "%EA", 6, -1, -1, -1, -1, -1, -1, 0, -1);
#endif
h_pass("SaturDay", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
#if defined(__NetBSD__)
h_fail("SaturDay", "%OA");
#else
h_pass("SaturDay", "%OA", 8, -1, -1, -1, -1, -1, -1, 6, -1);
#endif
}
ATF_TC(month);