From b29168a7b7cdcd57508586be0e5985c5852fb3be Mon Sep 17 00:00:00 2001 From: Teddy Reed Date: Wed, 4 Nov 2015 10:39:40 -0800 Subject: [PATCH] Use a null DB for the run test binary --- osquery/CMakeLists.txt | 1 - osquery/main/run.cpp | 3 +++ tools/tests/utils.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/osquery/CMakeLists.txt b/osquery/CMakeLists.txt index 5abbbec6..d2bc3485 100644 --- a/osquery/CMakeLists.txt +++ b/osquery/CMakeLists.txt @@ -78,7 +78,6 @@ endif() # Construct a set of all object files, starting with third-party and all # of the osquery core objects (sources from ADD_CORE_LIBRARY macros). set(OSQUERY_OBJECTS $) -add_compile_options(-Werror) # Add subdirectories add_subdirectory(config) diff --git a/osquery/main/run.cpp b/osquery/main/run.cpp index e1c5c33e..596e90e2 100644 --- a/osquery/main/run.cpp +++ b/osquery/main/run.cpp @@ -15,6 +15,7 @@ #include #include +#include "osquery/database/db_handle.h" #include "osquery/sql/sqlite_util.h" DEFINE_string(query, "", "query to execute"); @@ -40,6 +41,8 @@ int main(int argc, char* argv[]) { return 1; } + osquery::DBHandle::setAllowOpen(true); + osquery::FLAGS_database_path = "/dev/null"; osquery::Registry::setUp(); osquery::FLAGS_disable_events = true; osquery::FLAGS_registry_exceptions = true; diff --git a/tools/tests/utils.py b/tools/tests/utils.py index 32d0107b..ceae622d 100644 --- a/tools/tests/utils.py +++ b/tools/tests/utils.py @@ -140,7 +140,6 @@ def profile_cmd(cmd, proc=None, shell=False, timeout=0, count=1): shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - p = psutil.Process(pid=proc.pid) delay = 0 @@ -170,6 +169,8 @@ def profile_cmd(cmd, proc=None, shell=False, timeout=0, count=1): else: avg_utilization = sum(utilization) / len(utilization) + if len(stats.keys()) == 0: + raise Exception("No stats recorded, perhaps binary returns -1?") return { "utilization": avg_utilization, "duration": duration,