X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fexperimental%2Fsymbolizer%2Ftest%2FSignalHandlerTest.cpp;h=1a8fae6b18bc56955e60684c8fef5335c5d48b21;hp=45912ef7ae9afbc653d99e1bb6196375f3e2a7d0;hb=f19e2b86e49ad30f2279262a672be852283644d2;hpb=275ca94d04e44f28cfa411668eb1c1dd8db90b80 diff --git a/folly/experimental/symbolizer/test/SignalHandlerTest.cpp b/folly/experimental/symbolizer/test/SignalHandlerTest.cpp index 45912ef7..1a8fae6b 100644 --- a/folly/experimental/symbolizer/test/SignalHandlerTest.cpp +++ b/folly/experimental/symbolizer/test/SignalHandlerTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,14 @@ #include #include -#include - +#include #include #include -#include +#include -namespace folly { namespace symbolizer { namespace test { +namespace folly { +namespace symbolizer { +namespace test { namespace { @@ -31,7 +32,6 @@ void print(StringPiece sp) { writeFull(STDERR_FILENO, sp.data(), sp.size()); } - void callback1() { print("Callback1\n"); } @@ -40,7 +40,7 @@ void callback2() { print("Callback2\n"); } -} // namespace +} // namespace TEST(SignalHandler, Simple) { addFatalSignalCallback(callback1); @@ -48,31 +48,32 @@ TEST(SignalHandler, Simple) { installFatalSignalHandler(); installFatalSignalCallbacks(); -#ifdef FOLLY_SANITIZE_ADDRESS - EXPECT_DEATH( - failHard(), - // Testing an ASAN-enabled binary evokes a different diagnostic. - // Use a regexp that requires only the first line of that output: - "^ASAN:SIGSEGV\n.*"); -#else EXPECT_DEATH( failHard(), "^\\*\\*\\* Aborted at [0-9]+ \\(Unix time, try 'date -d @[0-9]+'\\) " "\\*\\*\\*\n" "\\*\\*\\* Signal 11 \\(SIGSEGV\\) \\(0x2a\\) received by PID [0-9]+ " - "\\(pthread TID 0x[0-9a-f]+\\) \\(linux TID [0-9]+\\), " + "\\(pthread TID 0x[0-9a-f]+\\) \\(linux TID [0-9]+\\) " + "\\(maybe from PID [0-9]+, UID [0-9]+\\) " + "\\(code: address not mapped to object\\), " "stack trace: \\*\\*\\*\n" ".*\n" - " @ [0-9a-f]+ folly::symbolizer::test::SignalHandler_Simple_Test" - "::TestBody\\(\\)\n" + ".* @ [0-9a-f]+.* folly::symbolizer::test::SignalHandler_Simple_Test" + "::TestBody\\(\\).*\n" ".*\n" - " @ [0-9a-f]+ main\n" + ".* @ [0-9a-f]+.* main.*\n" ".*\n" "Callback1\n" "Callback2\n" - ); -#endif + ".*"); } +} // namespace test +} // namespace symbolizer +} // namespace folly - -}}} // namespaces +// 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(); +}