Skip to content

Commit b3c696f

Browse files
committed
[libc] Add debug messages to bcmp and memcmp tests
1 parent 1e4891e commit b3c696f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

libc/test/src/string/bcmp_test.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "memory_utils/memory_check_utils.h"
1010
#include "src/string/bcmp.h"
1111
#include "test/UnitTest/Test.h"
12+
#include "test/UnitTest/TestLogger.h"
1213

1314
namespace __llvm_libc {
1415

@@ -51,7 +52,10 @@ TEST(LlvmLibcBcmpTest, SizeSweep) {
5152
for (size_t size = 0; size < kMaxSize; ++size) {
5253
auto span1 = Buffer1.span().subspan(0, size);
5354
auto span2 = Buffer2.span().subspan(0, size);
54-
ASSERT_TRUE((CheckBcmp<Impl>(span1, span2, size)));
55+
const bool OK = CheckBcmp<Impl>(span1, span2, size);
56+
if (!OK)
57+
testing::tlog << "Failed at size=" << size << '\n';
58+
ASSERT_TRUE(OK);
5559
}
5660
}
5761

libc/test/src/string/memcmp_test.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "memory_utils/memory_check_utils.h"
1010
#include "src/string/memcmp.h"
1111
#include "test/UnitTest/Test.h"
12+
#include "test/UnitTest/TestLogger.h"
1213

1314
namespace __llvm_libc {
1415

@@ -51,7 +52,10 @@ TEST(LlvmLibcMemcmpTest, SizeSweep) {
5152
for (size_t size = 0; size < kMaxSize; ++size) {
5253
auto span1 = Buffer1.span().subspan(0, size);
5354
auto span2 = Buffer2.span().subspan(0, size);
54-
ASSERT_TRUE((CheckMemcmp<Impl>(span1, span2, size)));
55+
const bool OK = CheckMemcmp<Impl>(span1, span2, size);
56+
if (!OK)
57+
testing::tlog << "Failed at size=" << size << '\n';
58+
ASSERT_TRUE(OK);
5559
}
5660
}
5761

utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ libc_test(
150150
"//libc:memmove",
151151
],
152152
deps = [
153+
":memory_check_utils",
153154
"//libc:__support_cpp_span",
154155
"//libc/test/UnitTest:memory_matcher",
155-
":memory_check_utils",
156156
],
157157
)
158158

@@ -163,9 +163,9 @@ libc_test(
163163
"//libc:bcopy",
164164
],
165165
deps = [
166+
":memory_check_utils",
166167
"//libc:__support_cpp_span",
167168
"//libc/test/UnitTest:memory_matcher",
168-
":memory_check_utils",
169169
],
170170
)
171171

@@ -175,7 +175,10 @@ libc_test(
175175
libc_function_deps = [
176176
"//libc:memcmp",
177177
],
178-
deps = [":memory_check_utils"],
178+
deps = [
179+
":memory_check_utils",
180+
"//libc/test/UnitTest:test_logger",
181+
],
179182
)
180183

181184
libc_test(
@@ -184,7 +187,10 @@ libc_test(
184187
libc_function_deps = [
185188
"//libc:bcmp",
186189
],
187-
deps = [":memory_check_utils"],
190+
deps = [
191+
":memory_check_utils",
192+
"//libc/test/UnitTest:test_logger",
193+
],
188194
)
189195

190196
libc_test(

0 commit comments

Comments
 (0)