From 327ee770028d0e28e51958eb0c635342407b6b06 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Mon, 27 Nov 2017 22:18:54 -0800 Subject: [PATCH] Remove some custom test main()'s in folly/experimental/symbolizer/ Summary: [Folly] Remove some custom test `main()`'s in `folly/experimental/symbolizer/`. In one of the two cases, we need to do some extra work to give `ElfFile` knowledge of the program path. Reviewed By: ot, Orvid, philippv, luciang Differential Revision: D6420517 fbshipit-source-id: 11c694a8342abb6fff05c368f3cda2e6287ccb4b --- .../experimental/symbolizer/test/ElfTests.cpp | 18 +----------------- .../symbolizer/test/StackTraceTest.cpp | 7 ------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/folly/experimental/symbolizer/test/ElfTests.cpp b/folly/experimental/symbolizer/test/ElfTests.cpp index 51d8531d..b81f52e4 100644 --- a/folly/experimental/symbolizer/test/ElfTests.cpp +++ b/folly/experimental/symbolizer/test/ElfTests.cpp @@ -25,19 +25,10 @@ uint64_t kIntegerValue = 1234567890UL; const char* kStringValue = "coconuts"; class ElfTest : public ::testing::Test { - public: - // Path to the test binary itself; set by main() - static std::string binaryPath; - - ElfTest() : elfFile_(binaryPath.c_str()) {} - ~ElfTest() override {} - protected: - ElfFile elfFile_; + ElfFile elfFile_{"/proc/self/exe"}; }; -std::string ElfTest::binaryPath; - TEST_F(ElfTest, IntegerValue) { auto sym = elfFile_.getSymbolByName("kIntegerValue"); EXPECT_NE(nullptr, sym.first) << "Failed to look up symbol kIntegerValue"; @@ -58,10 +49,3 @@ TEST_F(ElfTest, iterateProgramHeaders) { EXPECT_NE(nullptr, phdr); EXPECT_GE(phdr->p_filesz, 0); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - ElfTest::binaryPath = argv[0]; - return RUN_ALL_TESTS(); -} diff --git a/folly/experimental/symbolizer/test/StackTraceTest.cpp b/folly/experimental/symbolizer/test/StackTraceTest.cpp index 99e8c322..bc609d7c 100644 --- a/folly/experimental/symbolizer/test/StackTraceTest.cpp +++ b/folly/experimental/symbolizer/test/StackTraceTest.cpp @@ -88,10 +88,3 @@ TEST(StackTraceTest, Signal) { raise(SIGUSR1); 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(); -} -- 2.34.1