osquery-1/osquery/filesystem/filesystem_tests.cpp
2014-08-04 11:06:45 -07:00

37 lines
785 B
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#include "osquery/filesystem.h"
#include <fstream>
#include <stdio.h>
#include <gtest/gtest.h>
#include <glog/logging.h>
namespace osquery { namespace fs {
class FilesystemTests : public testing::Test {};
TEST_F(FilesystemTests, test_plugin) {
std::ofstream test_file("/tmp/osquery-test-file");
test_file.write("test123", sizeof("test123"));
test_file.close();
std::string content;
auto s = readFile("/tmp/osquery-test-file", content);
EXPECT_TRUE(s.ok());
EXPECT_EQ(s.toString(), "OK");
EXPECT_EQ(content, "test123");
remove("/tmp/osquery-test-file");
}
}}
int main(int argc, char* argv[]) {
testing::InitGoogleTest(&argc, argv);
google::InitGoogleLogging(argv[0]);
return RUN_ALL_TESTS();
}