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.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Enji Cooper 2017-02-07 04:25:21 +00:00
parent 87e886953f
commit 1eca9a9a49
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=313378

View File

@ -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);
}