2014-07-31 00:35:19 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#include "osquery/logger.h"
|
|
|
|
#include "osquery/logger/plugin.h"
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <glog/logging.h>
|
|
|
|
|
2014-08-21 21:35:51 +00:00
|
|
|
#include "osquery/core.h"
|
|
|
|
|
2014-08-05 23:13:55 +00:00
|
|
|
using osquery::Status;
|
2014-07-31 00:35:19 +00:00
|
|
|
|
2014-08-15 07:25:30 +00:00
|
|
|
namespace osquery {
|
2014-07-31 00:35:19 +00:00
|
|
|
|
|
|
|
class LoggerTests : public testing::Test {
|
2014-08-15 07:25:30 +00:00
|
|
|
public:
|
|
|
|
LoggerTests() { osquery::InitRegistry::get().run(); }
|
2014-07-31 00:35:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestLoggerPlugin : public LoggerPlugin {
|
2014-08-15 07:25:30 +00:00
|
|
|
public:
|
2014-07-31 00:35:19 +00:00
|
|
|
TestLoggerPlugin() {}
|
|
|
|
|
2014-08-15 07:25:30 +00:00
|
|
|
Status logString(const std::string& s) { return Status(0, s); }
|
2014-07-31 00:35:19 +00:00
|
|
|
|
|
|
|
virtual ~TestLoggerPlugin() {}
|
|
|
|
};
|
|
|
|
|
2014-09-16 07:36:49 +00:00
|
|
|
REGISTER_LOGGER_PLUGIN("test", std::make_shared<osquery::TestLoggerPlugin>());
|
2014-07-31 00:35:19 +00:00
|
|
|
|
|
|
|
TEST_F(LoggerTests, test_plugin) {
|
|
|
|
auto s = REGISTERED_LOGGER_PLUGINS.at("test")->logString("foobar");
|
|
|
|
EXPECT_EQ(s.ok(), true);
|
|
|
|
EXPECT_EQ(s.toString(), "foobar");
|
|
|
|
}
|
2014-08-15 07:25:30 +00:00
|
|
|
}
|
2014-07-31 00:35:19 +00:00
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
testing::InitGoogleTest(&argc, argv);
|
2014-09-13 21:28:45 +00:00
|
|
|
osquery::initOsquery(argc, argv);
|
2014-07-31 00:35:19 +00:00
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|