mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-08 10:23:54 +00:00
37 lines
785 B
C++
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();
|
|
}
|