proxygen
InitTest.cpp File Reference

Go to the source code of this file.

Namespaces

 folly
 —— Concurrent Priority Queue Implementation ——
 

Functions

const char * folly::getBaseLoggingConfig ()
 
 TEST (Init, checkConfig)
 
int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 83 of file InitTest.cpp.

References testing::InitGoogleTest(), and RUN_ALL_TESTS().

83  {
85  gflags::ParseCommandLineFlags(&argc, &argv, /* remove_flags = */ true);
86 
87  return RUN_ALL_TESTS();
88 }
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: gtest.h:2232
char ** argv
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: gtest.cc:5370
TEST ( Init  ,
checkConfig   
)

Definition at line 44 of file InitTest.cpp.

References EXPECT_EQ, EXPECT_THROW_RE, folly::LoggerDB::get(), folly::LoggerDB::getConfig(), folly::initLogging(), and folly::parseLogConfig().

44  {
45  // Before we call initLogging(), the LoggerDB will have the default
46  // configuration provided by initializeLoggerDB().
47  auto initialConfig = folly::LoggerDB::get().getConfig();
48  EXPECT_EQ(0, getBaseLoggingConfigCalled);
49  EXPECT_EQ(
50  parseLogConfig(".:=INFO:default; "
51  "default=stream:stream=stderr,async=false"),
52  LoggerDB::get().getConfig());
53 
54  // Call initLogging()
55  // Make sure it merges the supplied config argument with our custom
56  // base configuration.
57  initLogging(".=ERROR,folly.logging=DBG7");
58  EXPECT_EQ(1, getBaseLoggingConfigCalled);
59  EXPECT_EQ(
60  parseLogConfig(".:=ERROR:default,folly=INFO:,folly.logging=DBG7:; "
61  "default=stream:stream=stdout,async=false"),
62  LoggerDB::get().getConfig());
63 
64  // Test calling initLogging() with bad configuration strings, and
65  // configured such that it should throw an exception on error rather than
66  // exiting.
67  //
68  // Note that it is okay to call initLogging() multiple times (we already
69  // called it successfully once above), but this isn't really something to
70  // expect most callers to want to do.
72  initLogging(".=BOGUSLEVEL"),
74  R"(invalid log level "BOGUSLEVEL")");
76  initLogging(".=ERR:undefined_handler"),
77  std::invalid_argument,
78  R"(unknown log handler "undefined_handler")");
79 }
#define EXPECT_THROW_RE(statement, exceptionType, pattern)
Definition: TestUtils.h:119
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
LogConfig getConfig() const
Definition: LoggerDB.cpp:158
LogConfig parseLogConfig(StringPiece value)
void initLogging(StringPiece configString)
Definition: Init.cpp:25
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
Definition: submit.h:391
static LoggerDB & get()
Definition: LoggerDB.cpp:112