Go to the source code of this file.
|
void | checkAsyncWriter (const LogWriter *writer, const char *expectedPath, size_t expectedMaxBufferSize) |
|
void | checkAsyncWriter (const LogWriter *writer, int expectedFD, size_t expectedMaxBufferSize) |
|
| TEST (FileHandlerFactory, pathOnly) |
|
| TEST (StreamHandlerFactory, stderrStream) |
|
| TEST (StreamHandlerFactory, stdoutWithMaxBuffer) |
|
| TEST (FileHandlerFactory, pathWithMaxBufferSize) |
|
| TEST (StreamHandlerFactory, nonAsyncStderr) |
|
| TEST (FileHandlerFactory, errors) |
|
| TEST (StreamHandlerFactory, errors) |
|
void checkAsyncWriter |
( |
const LogWriter * |
writer, |
|
|
const char * |
expectedPath, |
|
|
size_t |
expectedMaxBufferSize |
|
) |
| |
Definition at line 32 of file FileHandlerFactoryTest.cpp.
References ASSERT_TRUE, folly::checkUnixError(), and EXPECT_EQ.
Referenced by TEST().
38 <<
"handler factory should have created an AsyncFileWriter";
39 EXPECT_EQ(expectedMaxBufferSize, asyncWriter->getMaxBufferSize());
42 struct stat expectedStatInfo;
43 checkUnixError(stat(expectedPath, &expectedStatInfo),
"stat failed");
44 struct stat actualStatInfo;
46 fstat(asyncWriter->getFile().fd(), &actualStatInfo),
"fstat failed");
47 EXPECT_EQ(expectedStatInfo.st_dev, actualStatInfo.st_dev);
48 EXPECT_EQ(expectedStatInfo.st_ino, actualStatInfo.st_ino);
#define EXPECT_EQ(val1, val2)
void checkUnixError(ssize_t ret, Args &&...args)
#define ASSERT_TRUE(condition)
void checkAsyncWriter |
( |
const LogWriter * |
writer, |
|
|
int |
expectedFD, |
|
|
size_t |
expectedMaxBufferSize |
|
) |
| |
Definition at line 51 of file FileHandlerFactoryTest.cpp.
References ASSERT_TRUE, and EXPECT_EQ.
57 <<
"handler factory should have created an AsyncFileWriter";
58 EXPECT_EQ(expectedMaxBufferSize, asyncWriter->getMaxBufferSize());
59 EXPECT_EQ(expectedFD, asyncWriter->getFile().fd());
#define EXPECT_EQ(val1, val2)
#define ASSERT_TRUE(condition)
Definition at line 62 of file FileHandlerFactoryTest.cpp.
References ASSERT_TRUE, checkAsyncWriter(), folly::FileHandlerFactory::createHandler(), EXPECT_TRUE, handler(), and folly::AsyncFileWriter::kDefaultMaxBufferSize.
67 make_pair(
"path", tmpFile.path().string()),
77 <<
"handler factory should have created a GlogStyleFormatter";
80 stdHandler->getWriter().get(),
81 tmpFile.path().string().c_str(),
82 AsyncFileWriter::kDefaultMaxBufferSize);
void handler(int, siginfo_t *, void *)
std::shared_ptr< LogHandler > createHandler(const Options &options) override
#define EXPECT_TRUE(condition)
void checkAsyncWriter(const LogWriter *writer, const char *expectedPath, size_t expectedMaxBufferSize)
std::unordered_map< std::string, std::string > Options
#define ASSERT_TRUE(condition)
Definition at line 85 of file FileHandlerFactoryTest.cpp.
References ASSERT_TRUE, checkAsyncWriter(), folly::StreamHandlerFactory::createHandler(), EXPECT_TRUE, handler(), and folly::AsyncFileWriter::kDefaultMaxBufferSize.
89 auto options = StreamHandlerFactory::Options{
90 make_pair(
"stream",
"stderr"),
100 <<
"handler factory should have created a GlogStyleFormatter";
103 stdHandler->getWriter().get(),
105 AsyncFileWriter::kDefaultMaxBufferSize);
std::shared_ptr< LogHandler > createHandler(const Options &options) override
void handler(int, siginfo_t *, void *)
#define EXPECT_TRUE(condition)
void checkAsyncWriter(const LogWriter *writer, const char *expectedPath, size_t expectedMaxBufferSize)
#define ASSERT_TRUE(condition)
Definition at line 108 of file FileHandlerFactoryTest.cpp.
References ASSERT_TRUE, checkAsyncWriter(), folly::StreamHandlerFactory::createHandler(), EXPECT_TRUE, and handler().
112 auto options = StreamHandlerFactory::Options{
113 make_pair(
"stream",
"stdout"),
114 make_pair(
"max_buffer_size",
"4096"),
124 <<
"handler factory should have created a GlogStyleFormatter";
std::shared_ptr< LogHandler > createHandler(const Options &options) override
void handler(int, siginfo_t *, void *)
#define EXPECT_TRUE(condition)
void checkAsyncWriter(const LogWriter *writer, const char *expectedPath, size_t expectedMaxBufferSize)
#define ASSERT_TRUE(condition)
Definition at line 129 of file FileHandlerFactoryTest.cpp.
References ASSERT_TRUE, checkAsyncWriter(), folly::FileHandlerFactory::createHandler(), EXPECT_TRUE, and handler().
134 make_pair(
"path", tmpFile.path().string()),
135 make_pair(
"max_buffer_size",
"4096000"),
145 <<
"handler factory should have created a GlogStyleFormatter";
148 stdHandler->getWriter().get(), tmpFile.path().string().c_str(), 4096000);
void handler(int, siginfo_t *, void *)
std::shared_ptr< LogHandler > createHandler(const Options &options) override
#define EXPECT_TRUE(condition)
void checkAsyncWriter(const LogWriter *writer, const char *expectedPath, size_t expectedMaxBufferSize)
std::unordered_map< std::string, std::string > Options
#define ASSERT_TRUE(condition)
Definition at line 151 of file FileHandlerFactoryTest.cpp.
References ASSERT_TRUE, folly::StreamHandlerFactory::createHandler(), EXPECT_EQ, EXPECT_TRUE, and handler().
156 make_pair(
"stream",
"stderr"),
157 make_pair(
"async",
"no"),
167 <<
"handler factory should have created a GlogStyleFormatter";
172 EXPECT_EQ(STDERR_FILENO, writer->getFile().fd());
#define EXPECT_EQ(val1, val2)
std::shared_ptr< LogHandler > createHandler(const Options &options) override
void handler(int, siginfo_t *, void *)
#define EXPECT_TRUE(condition)
std::unordered_map< std::string, std::string > Options
#define ASSERT_TRUE(condition)
Definition at line 175 of file FileHandlerFactoryTest.cpp.
References folly::FileHandlerFactory::createHandler(), and EXPECT_THROW_RE.
181 auto options = Options{};
184 std::invalid_argument,
185 "no path specified for file handler");
189 auto options = Options{
190 {
"path", tmpFile.path().string()},
191 {
"stream",
"stderr"},
195 std::invalid_argument,
196 "unknown option \"stream\"");
200 auto options = Options{
201 {
"stream",
"nonstdout"},
205 std::invalid_argument,
206 "unknown option \"stream\"");
210 auto options = Options{
211 {
"path", tmpFile.path().string()},
216 std::invalid_argument,
217 "^error processing option \"async\": Invalid value for bool: \"xyz\"$");
221 auto options = Options{
222 {
"path", tmpFile.path().string()},
224 {
"max_buffer_size",
"1234"},
228 std::invalid_argument,
229 "the \"max_buffer_size\" option is only valid for async file handlers");
233 auto options = Options{
234 {
"path", tmpFile.path().string()},
235 {
"max_buffer_size",
"hello"},
239 std::invalid_argument,
240 "^error processing option \"max_buffer_size\": " 241 "Non-digit character found: \"hello\"$");
245 auto options = Options{
246 {
"path", tmpFile.path().string()},
247 {
"max_buffer_size",
"0"},
251 std::invalid_argument,
252 "^error processing option \"max_buffer_size\": " 253 "must be a positive integer$");
257 auto options = Options{
258 {
"path", tmpFile.path().string()},
263 std::invalid_argument,
264 "^unknown option \"foo\"$");
#define EXPECT_THROW_RE(statement, exceptionType, pattern)
std::shared_ptr< LogHandler > createHandler(const Options &options) override
std::unordered_map< std::string, std::string > Options
Definition at line 268 of file FileHandlerFactoryTest.cpp.
References folly::StreamHandlerFactory::createHandler(), and EXPECT_THROW_RE.
273 auto options = Options{};
276 std::invalid_argument,
277 "no stream name specified for stream handler");
281 auto options = Options{
282 {
"path",
"/tmp/log.txt"},
283 {
"stream",
"stderr"},
287 std::invalid_argument,
288 "unknown option \"path\"");
292 auto options = Options{
293 {
"stream",
"nonstdout"},
297 std::invalid_argument,
298 "unknown stream \"nonstdout\": expected one of stdout or stderr");
302 auto options = Options{
303 {
"stream",
"stderr"},
308 std::invalid_argument,
309 "^error processing option \"async\": Invalid value for bool: \"xyz\"$");
313 auto options = Options{
314 {
"stream",
"stderr"},
316 {
"max_buffer_size",
"1234"},
320 std::invalid_argument,
321 "^the \"max_buffer_size\" option is only valid for " 322 "async file handlers$");
326 auto options = Options{
327 {
"stream",
"stderr"},
328 {
"max_buffer_size",
"hello"},
332 std::invalid_argument,
333 "^error processing option \"max_buffer_size\": " 334 "Non-digit character found: \"hello\"$");
338 auto options = Options{
339 {
"stream",
"stderr"},
340 {
"max_buffer_size",
"0"},
344 std::invalid_argument,
345 "^error processing option \"max_buffer_size\": " 346 "must be a positive integer$");
350 auto options = Options{
351 make_pair(
"stream",
"stderr"),
352 make_pair(
"foo",
"bar"),
356 std::invalid_argument,
357 "unknown option \"foo\"");
#define EXPECT_THROW_RE(statement, exceptionType, pattern)
std::shared_ptr< LogHandler > createHandler(const Options &options) override
std::unordered_map< std::string, std::string > Options