summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-02-14 04:49:24 +0000
committerngie <ngie@FreeBSD.org>2017-02-14 04:49:24 +0000
commitad0ecc0d7e6ae464befdc0ad2954a0eb5182b0d4 (patch)
tree417d0e354dd783d59dc47912084cf7f204352701
parent44e806ba3aa0d53f31bdef57fb11f38ffdd6d447 (diff)
downloadFreeBSD-src-ad0ecc0d7e6ae464befdc0ad2954a0eb5182b0d4.zip
FreeBSD-src-ad0ecc0d7e6ae464befdc0ad2954a0eb5182b0d4.tar.gz
MFC r313378,r313379:
r313378: Wrap strcmp/wcscmp calls with ATF_CHECK_MSG and drop atf_tc_fail use The reasoning here was the same as what was done in r313376: - Gather as many results as possible instead of failing early and not testing the rest of the cases. - Simplify logic when checking test inputs vs outputs and printing test result. r313379: Expect :int_within_limits to fail when ptrdiff_t/*intmax_t differ in base type The %t{d,u} (ptrdiff_t) tests fail for the following reasons: - ptrdiff_t is by definition int32_t on !LP64 architectures and int64_t on LP64 architectures. - intmax_t is by definition fixed to int64_t on all architectures. - Some of the code in lib/libc/stdio/... is promoting ptrdiff_t to *intmax_t when parsing/representing the value. PR: 191674
-rw-r--r--lib/libc/tests/stdio/printbasic_test.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/libc/tests/stdio/printbasic_test.c b/lib/libc/tests/stdio/printbasic_test.c
index 7f7c6cb..322e747 100644
--- a/lib/libc/tests/stdio/printbasic_test.c
+++ b/lib/libc/tests/stdio/printbasic_test.c
@@ -78,22 +78,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...)
va_copy(ap2, ap);
smash_stack();
vsnprintf(s, sizeof(s), fmt, ap);
- if (strcmp(result, s) != 0) {
- atf_tc_fail(
- "printf(\"%s\", %s) ==> [%s], expected [%s]",
- fmt, argstr, s, result);
- }
+ ATF_CHECK_MSG(strcmp(result, s) == 0,
+ "printf(\"%s\", %s) ==> [%s], expected [%s]",
+ fmt, argstr, s, result);
smash_stack();
mbstowcs(ws, s, BUF - 1);
mbstowcs(wfmt, fmt, BUF - 1);
mbstowcs(wresult, result, BUF - 1);
vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2);
- if (wcscmp(wresult, ws) != 0) {
- atf_tc_fail(
- "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
- wfmt, argstr, ws, wresult);
- }
+ ATF_CHECK_MSG(wcscmp(wresult, ws) == 0,
+ "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
+ wfmt, argstr, ws, wresult);
+
va_end(ap);
va_end(ap2);
}
@@ -114,6 +111,11 @@ ATF_TC_BODY(int_within_limits, tc)
testfmt("-1", "%jd", (intmax_t)-1);
testfmt(S_UINT64MAX, "%ju", UINT64_MAX);
+ if (sizeof(ptrdiff_t) != sizeof(uintmax_t))
+ atf_tc_expect_fail("the %%t qualifier is broken on 32-bit "
+ "platforms where there's a mismatch between ptrdiff_t and "
+ "uintmax_t's type width; bug # 191674");
+
testfmt("-1", "%td", (ptrdiff_t)-1);
testfmt(S_SIZEMAX, "%tu", (size_t)-1);
OpenPOWER on IntegriCloud