From 2fa0873993ada1a14deb2715a40bff2b205ee6d1 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Tue, 9 Jul 2019 00:51:30 -0400 Subject: [PATCH] [test-libc] refs #95 Rewrite `isU8Eq` to avoid random errors in the tests --- lib/cgo/tests/testutils/libsky_assert.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/cgo/tests/testutils/libsky_assert.c b/lib/cgo/tests/testutils/libsky_assert.c index aaa3ecca1..d41cc44c9 100644 --- a/lib/cgo/tests/testutils/libsky_assert.c +++ b/lib/cgo/tests/testutils/libsky_assert.c @@ -58,13 +58,14 @@ GoInt_ isSigEq(cipher__Sig *sig1, cipher__Sig *sig2) { return memcmp((void *)sig1, (void *)sig2, sizeof(cipher__Sig)) == 0; } -GoInt_ isU8Eq(unsigned char p1[], unsigned char p2[], size_t len) { - - if (strncmp(p1, p2, len) == 0) { - +GoInt_ isU8Eq(unsigned char p1[], unsigned char p2[], size_t len) +{ + for (GoInt i = 0; i < len; i++) { + if (p1[i] != p2[i]) { + return 0; + } + } return 1; - } - return 0; } GoInt_ isSHA256Eq(cipher__SHA256 *sh1, cipher__SHA256 *sh2) {