[libc] Add debug messages to bcmp and memcmp tests
authorGuillaume Chatelet <gchatelet@google.com>
Tue, 18 Apr 2023 13:35:18 +0000 (13:35 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Tue, 18 Apr 2023 13:35:34 +0000 (13:35 +0000)
libc/test/src/string/bcmp_test.cpp
libc/test/src/string/memcmp_test.cpp
utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel

index a7f463c..0559ab0 100644 (file)
@@ -9,6 +9,7 @@
 #include "memory_utils/memory_check_utils.h"
 #include "src/string/bcmp.h"
 #include "test/UnitTest/Test.h"
+#include "test/UnitTest/TestLogger.h"
 
 namespace __llvm_libc {
 
@@ -51,7 +52,10 @@ TEST(LlvmLibcBcmpTest, SizeSweep) {
   for (size_t size = 0; size < kMaxSize; ++size) {
     auto span1 = Buffer1.span().subspan(0, size);
     auto span2 = Buffer2.span().subspan(0, size);
-    ASSERT_TRUE((CheckBcmp<Impl>(span1, span2, size)));
+    const bool OK = CheckBcmp<Impl>(span1, span2, size);
+    if (!OK)
+      testing::tlog << "Failed at size=" << size << '\n';
+    ASSERT_TRUE(OK);
   }
 }
 
index 1e412a3..24434a9 100644 (file)
@@ -9,6 +9,7 @@
 #include "memory_utils/memory_check_utils.h"
 #include "src/string/memcmp.h"
 #include "test/UnitTest/Test.h"
+#include "test/UnitTest/TestLogger.h"
 
 namespace __llvm_libc {
 
@@ -51,7 +52,10 @@ TEST(LlvmLibcMemcmpTest, SizeSweep) {
   for (size_t size = 0; size < kMaxSize; ++size) {
     auto span1 = Buffer1.span().subspan(0, size);
     auto span2 = Buffer2.span().subspan(0, size);
-    ASSERT_TRUE((CheckMemcmp<Impl>(span1, span2, size)));
+    const bool OK = CheckMemcmp<Impl>(span1, span2, size);
+    if (!OK)
+      testing::tlog << "Failed at size=" << size << '\n';
+    ASSERT_TRUE(OK);
   }
 }
 
index 90ae8bb..1c99cae 100644 (file)
@@ -150,9 +150,9 @@ libc_test(
         "//libc:memmove",
     ],
     deps = [
+        ":memory_check_utils",
         "//libc:__support_cpp_span",
         "//libc/test/UnitTest:memory_matcher",
-        ":memory_check_utils",
     ],
 )
 
@@ -163,9 +163,9 @@ libc_test(
         "//libc:bcopy",
     ],
     deps = [
+        ":memory_check_utils",
         "//libc:__support_cpp_span",
         "//libc/test/UnitTest:memory_matcher",
-        ":memory_check_utils",
     ],
 )
 
@@ -175,7 +175,10 @@ libc_test(
     libc_function_deps = [
         "//libc:memcmp",
     ],
-    deps = [":memory_check_utils"],
+    deps = [
+        ":memory_check_utils",
+        "//libc/test/UnitTest:test_logger",
+    ],
 )
 
 libc_test(
@@ -184,7 +187,10 @@ libc_test(
     libc_function_deps = [
         "//libc:bcmp",
     ],
-    deps = [":memory_check_utils"],
+    deps = [
+        ":memory_check_utils",
+        "//libc/test/UnitTest:test_logger",
+    ],
 )
 
 libc_test(