Improve unit test output and logging to diagnose build breaks
authorChip Turner <chip@fb.com>
Wed, 31 Dec 2014 03:03:54 +0000 (19:03 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:03 +0000 (11:01 -0800)
Summary:
I can't repro the very frequent breakage we get from the unit
test framework, and it would be helpful to get the proper error messages
from it, so this adjusts the logging and changes a CHECK to an EXPECT to
get more data when the failure occurs.

Test Plan: runtests

Reviewed By: hans@fb.com

Subscribers: lins, anca, folly-diffs@

FB internal diff: D1761800

Tasks: 5870141

Signature: t1:1761800:1420226753:27a66fb0ce47cd57529e5fd0518550fb649c9eb5

folly/experimental/symbolizer/test/StackTraceTest.cpp

index 29f8fb1edfae7c767e1d123aa604c72e5d86e188..6e2745d3668da2430f9249515949db4a1d501dfd 100644 (file)
@@ -52,9 +52,9 @@ void verifyStackTraces() {
   // Other than the top 2 frames (this one and getStackTrace /
   // getStackTraceSafe), the stack traces should be identical
   for (size_t i = 2; i < fa.frameCount; ++i) {
-    VLOG(1) << "i=" << i << " " << std::hex << fa.addresses[i] << " "
-            << faSafe.addresses[i];
-    CHECK_EQ(fa.addresses[i], faSafe.addresses[i]);
+    LOG(INFO) << "i=" << i << " " << std::hex << "0x" << fa.addresses[i]
+              << " 0x" << faSafe.addresses[i];
+    EXPECT_EQ(fa.addresses[i], faSafe.addresses[i]);
   }
 }
 
@@ -85,11 +85,12 @@ TEST(StackTraceTest, Signal) {
   sa.sa_flags = SA_RESETHAND | SA_SIGINFO;
   CHECK_ERR(sigaction(SIGUSR1, &sa, nullptr));
   raise(SIGUSR1);
-  CHECK(handled);
+  EXPECT_TRUE(handled);
 }
 
 int main(int argc, char *argv[]) {
   testing::InitGoogleTest(&argc, argv);
   gflags::ParseCommandLineFlags(&argc, &argv, true);
+  google::InitGoogleLogging(argv[0]);
   return RUN_ALL_TESTS();
 }