Merge upstream-1.4.5 [experimental]
authorSangwan Kwon <sangwan.kwon@samsung.com>
Wed, 10 Jul 2019 03:31:01 +0000 (12:31 +0900)
committerSangwan Kwon <sangwan.kwon@samsung.com>
Wed, 10 Jul 2019 03:31:01 +0000 (12:31 +0900)
Known issues
  - extension tests failed
  - virtual table tests failed (passed only when it runs as standalone)

Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
osquery/main/tests.cpp
osquery/manager/CMakeLists.txt
osquery/manager/manager_impl.cpp
osquery/manager/tests/manager_tests.cpp [moved from osquery/manager/manager_tests.cpp with 95% similarity]
osquery/notification/CMakeLists.txt
osquery/notification/tests/notification_tests.cpp [moved from osquery/notification/notification_tests.cpp with 95% similarity]
osquery/property/CMakeLists.txt
osquery/property/tests/property_tests.cpp [moved from osquery/property/property_tests.cpp with 97% similarity]
tsqb/CMakeLists.txt
tsqb/tests/tsqb-tests.cpp [moved from tsqb/tsqb-tests.cpp with 98% similarity]

index 0f92e74..e2ac45c 100644 (file)
@@ -26,6 +26,7 @@ DECLARE_string(extensions_socket);
 DECLARE_string(modules_autoload);
 DECLARE_string(extensions_autoload);
 DECLARE_bool(disable_logging);
+DECLARE_bool(verbose);
 
 void initTesting() {
   // Seed the random number generator, some tests generate temporary files
@@ -44,6 +45,7 @@ void initTesting() {
   FLAGS_extensions_autoload = kTestWorkingDirectory + "unittests-ext.load";
   FLAGS_modules_autoload = kTestWorkingDirectory + "unittests-mod.load";
   FLAGS_disable_logging = true;
+  FLAGS_verbose = true;
 
   // Create a default DBHandle instance before unittests.
   (void)DBHandle::getInstance();
index d961b47..4570e91 100644 (file)
@@ -15,4 +15,5 @@
 ADD_OSQUERY_LIBRARY(TRUE osquery_manager manager.cpp
                                                                                 manager_impl.cpp)
 
-ADD_OSQUERY_TEST(TRUE osquery_manager_tests manager_tests.cpp)
+FILE(GLOB OSQUERY_MANAGER_TESTS "tests/*.cpp")
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_MANAGER_TESTS})
index bb9db71..01a9c24 100644 (file)
 
 #include <boost/filesystem/operations.hpp>
 
+#include <functional>
 #include <sstream>
 
 namespace osquery {
 
 ManagerImpl::ManagerImpl()
 {
-       auto logDir = Flag::get().getValue("osquery_log_dir");
+       auto logDir = Flag::getValue("osquery_log_dir");
        if (!logDir.empty() && !(pathExists(logDir).ok()))
                boost::filesystem::create_directories(logDir);
 
-       // TODO(Sangwan): Get debug mode at build time
-       Flag::updateValue("verbose_debug", "true");
-
-       const char* cargv[] = {"tizen-osquery"};
-       osquery::initOsquery(1, const_cast<char**>(cargv));
-
        LOG(INFO) << "Initalize osquery manager. ";
 }
 
 ManagerImpl::~ManagerImpl() noexcept
 {
        LOG(INFO) << "Shutdown osquery manager.";
-       osquery::shutdownOsquery();
 }
 
 ManagerImpl& ManagerImpl::instance()
similarity index 95%
rename from osquery/manager/manager_tests.cpp
rename to osquery/manager/tests/manager_tests.cpp
index de72711..048cfcc 100644 (file)
@@ -76,8 +76,3 @@ TEST_F(ManagerTests, test_manager_columns) {
        for (const auto& c : columns)
                VLOG(1) << "\t" << c;
 }
-
-int main(int argc, char* argv[]) {
-       testing::InitGoogleTest(&argc, argv);
-       return RUN_ALL_TESTS();
-}
index 956f83c..4083340 100644 (file)
@@ -14,4 +14,5 @@
 
 ADD_OSQUERY_LIBRARY(TRUE osquery_notification notification.cpp)
 
-ADD_OSQUERY_TEST(TRUE osquery_notification_tests notification_tests.cpp)
+FILE(GLOB OSQUERY_NOTIFICATION_TESTS "tests/*.cpp")
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_NOTIFICATION_TESTS})
@@ -70,8 +70,3 @@ TEST_F(NotificationTests, test_emit_positive) {
        EXPECT_TRUE(s.ok());
        EXPECT_EQ(called, 1);
 }
-
-int main(int argc, char* argv[]) {
-       testing::InitGoogleTest(&argc, argv);
-       return RUN_ALL_TESTS();
-}
index 4e8fe1e..d4082a6 100644 (file)
@@ -14,4 +14,5 @@
 
 ADD_OSQUERY_LIBRARY(TRUE osquery_property property.cpp)
 
-ADD_OSQUERY_TEST(TRUE osquery_property_tests property_tests.cpp)
+FILE(GLOB OSQUERY_PROPERTY_TESTS "tests/*.cpp")
+ADD_OSQUERY_TEST(TRUE ${OSQUERY_PROPERTY_TESTS})
similarity index 97%
rename from osquery/property/property_tests.cpp
rename to osquery/property/tests/property_tests.cpp
index c1bb9a5..55657db 100644 (file)
@@ -132,8 +132,3 @@ TEST_F(PropertyTests, properties) {
 
 //     EXPECT_NE(result.hour, -1);
 }
-
-int main(int argc, char* argv[]) {
-       testing::InitGoogleTest(&argc, argv);
-       return RUN_ALL_TESTS();
-}
index 4c77699..d4874e6 100644 (file)
@@ -12,4 +12,5 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License
 
-ADD_OSQUERY_TEST(FALSE tsqb_tests tsqb-tests.cpp)
+FILE(GLOB TSQB_TESTS "tests/*.cpp")
+ADD_OSQUERY_TEST(TRUE ${TSQB_TESTS})
similarity index 98%
rename from tsqb/tsqb-tests.cpp
rename to tsqb/tests/tsqb-tests.cpp
index aac1e7d..7770140 100644 (file)
@@ -195,8 +195,3 @@ TEST_F(TsqbTests, JOIN)
                                         "INNER JOIN admin ON managed_policy.aid = admin.id "
                                         "WHERE managed_policy.pid = ?");
 }
-
-int main(int argc, char* argv[]) {
-  testing::InitGoogleTest(&argc, argv);
-  return RUN_ALL_TESTS();
-}