[PATCH v4 next 03/23] selftests/nolibc: Return correct value when printf test fails

david.laight.linux@gmail.com posted 23 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH v4 next 03/23] selftests/nolibc: Return correct value when printf test fails
Posted by david.laight.linux@gmail.com 1 month, 1 week ago
From: David Laight <david.laight.linux@gmail.com>

Correctly return 1 (the number of errors) when strcmp()
fails rather than the return value from strncmp() which is the
signed difference between the mismatching characters.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
---

New patch for v4.
Corrects the error reporting for test failures.
But is really replaced by the next patch.

 tools/testing/selftests/nolibc/nolibc-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 0e8b3b9a86ef..9787e493523c 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -1683,7 +1683,7 @@ static int expect_vfprintf(int llen, int c, const char *expected, const char *fm
 	}
 
 	llen += printf(" \"%s\" = \"%s\"", expected, buf);
-	ret = strncmp(expected, buf, c);
+	ret = strncmp(expected, buf, c) != 0;
 
 	result(llen, ret ? FAIL : OK);
 	return ret;
-- 
2.39.5