Fix copyright lines
[folly.git] / folly / experimental / symbolizer / test / SymbolizerTest.cpp
index 088ae1e7a332426d83bf64f0d042643f998e0f67..7d7330d8c63e74d528fb62d8c26da3a6efc095e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2013-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 #include <cstdlib>
 
-#include <gtest/gtest.h>
-
 #include <folly/Range.h>
 #include <folly/String.h>
+#include <folly/portability/GTest.h>
 
-namespace folly { namespace symbolizer { namespace test {
+namespace folly {
+namespace symbolizer {
+namespace test {
 
-void foo() {
-}
+void foo() {}
 
 TEST(Symbolizer, Single) {
   Symbolizer symbolizer;
@@ -34,13 +34,23 @@ TEST(Symbolizer, Single) {
   ASSERT_TRUE(symbolizer.symbolize(reinterpret_cast<uintptr_t>(foo), a));
   EXPECT_EQ("folly::symbolizer::test::foo()", a.demangledName());
 
-  auto path = a.location.file.toString();
-  folly::StringPiece basename(path);
-  auto pos = basename.rfind('/');
-  if (pos != folly::StringPiece::npos) {
-    basename.advance(pos + 1);
+  // The version of clang we use doesn't generate a `.debug_aranges` section,
+  // which the symbolizer needs to lookup the filename.
+  constexpr bool built_with_clang =
+#ifdef __clang__
+      true;
+#else
+      false;
+#endif
+  if (!built_with_clang) {
+    auto path = a.location.file.toString();
+    folly::StringPiece basename(path);
+    auto pos = basename.rfind('/');
+    if (pos != folly::StringPiece::npos) {
+      basename.advance(pos + 1);
+    }
+    EXPECT_EQ("SymbolizerTest.cpp", basename.str());
   }
-  EXPECT_EQ("SymbolizerTest.cpp", basename.str());
 }
 
 FrameArray<100> goldenFrames;
@@ -104,5 +114,13 @@ TEST_F(ElfCacheTest, SignalSafeElfCache) {
     runElfCacheTest(symbolizer);
   }
 }
-
-}}}  // namespaces
+} // namespace test
+} // namespace symbolizer
+} // namespace folly
+
+// Can't use initFacebookLight since that would install its own signal handlers
+// Can't use initFacebookNoSignals since we cannot depend on common
+int main(int argc, char** argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}