Restore AugeasTests test

PR: osquery/osquery#5629
This commit is contained in:
Stefano Bonicatti 2019-07-07 22:27:47 +02:00 committed by Stefano Bonicatti
parent c56020cac3
commit 9cf33c84f8
4 changed files with 58 additions and 1 deletions

View File

@ -304,6 +304,11 @@ function(generateOsqueryTablesSystemSystemtable)
add_test(NAME osquery_tables_system_tests_shellhistorytests-test COMMAND osquery_tables_system_tests_shellhistorytests-test)
add_test(NAME osquery_tables_system_tests_sudoerstests-test COMMAND osquery_tables_system_tests_sudoerstests-test)
add_test(NAME osquery_tables_system_tests_yumsourcestests-test COMMAND osquery_tables_system_tests_yumsourcestests-test)
add_test(NAME osquery_tables_system_tests_augeastests-test COMMAND osquery_tables_system_tests_augeastests-test)
set_tests_properties(
osquery_tables_system_tests_augeastests-test
PROPERTIES ENVIRONMENT "TEST_CONF_FILES_DIR=${TEST_CONFIGS_DIR}"
)
endif()
if(DEFINED PLATFORM_LINUX)

View File

@ -17,6 +17,7 @@ function(osqueryTablesSystemTestsMain)
generateOsqueryTablesSystemTestsShellhistorytestsTest()
generateOsqueryTablesSystemTestsSudoerstestsTest()
generateOsqueryTablesSystemTestsYumsourcestestsTest()
generateOsqueryTablesSystemTestsAugeasTestsTest()
endif()
generateOsqueryTablesSystemTestsSystemtablestestsTest()
@ -444,4 +445,34 @@ function(generateOsqueryTablesSystemTestsRegistrytestsTest)
)
endfunction()
function(generateOsqueryTablesSystemTestsAugeasTestsTest)
add_osquery_executable(osquery_tables_system_tests_augeastests-test posix/augeas_tests.cpp)
target_link_libraries(osquery_tables_system_tests_augeastests-test PRIVATE
global_cxx_settings
osquery_config_tests_testutils
osquery_dispatcher
osquery_events
osquery_extensions
osquery_extensions_implthrift
osquery_headers
osquery_registry
osquery_remote_enroll_tlsenroll
osquery_sql
osquery_tables_events_eventstable
plugins_database_ephemeral
specs_tables
thirdparty_googletest
)
add_custom_target(osquery_tables_system_tests_augeaslenses
COMMAND "${CMAKE_COMMAND}" -E make_directory "${TEST_CONFIGS_DIR}/augeas/lenses"
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_PROPERTY:thirdparty_augeas,INTERFACE_BINARY_DIR>/share/augeas/lenses/dist/*.aug" "${TEST_CONFIGS_DIR}/augeas/lenses")
add_dependencies(osquery_tables_system_tests_augeastests-test osquery_tables_system_tests_augeaslenses)
add_dependencies(osquery_tables_system_tests_augeaslenses thirdparty_augeas)
add_dependencies(osquery_tables_system_tests_augeaslenses osquery_tools_tests_testconfigsfolder)
endfunction()
osqueryTablesSystemTestsMain()

View File

@ -8,12 +8,32 @@
#include <gtest/gtest.h>
#include <osquery/config/tests/test_utils.h>
#include <osquery/database.h>
#include <osquery/registry_factory.h>
#include <osquery/sql.h>
#include <osquery/system.h>
namespace osquery {
DECLARE_bool(disable_database);
DECLARE_string(augeas_lenses);
namespace tables {
class AugeasTests : public testing::Test {};
class AugeasTests : public testing::Test {
protected:
void SetUp() override {
Initializer::platformSetup();
registryAndPluginInit();
// Force registry to use ephemeral database plugin
FLAGS_disable_database = true;
FLAGS_augeas_lenses =
(osquery::getTestConfigDirectory() / "augeas/lenses").string();
DatabasePlugin::setAllowOpen(true);
DatabasePlugin::initPlugin();
}
};
TEST_F(AugeasTests, select_hosts_by_path_expression) {
auto results =

View File

@ -5,6 +5,7 @@
# the LICENSE file found in the root directory of this source tree.
function(osqueryToolsTestsMain)
add_custom_target(osquery_tools_tests_testconfigsfolder COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_BINARY_DIR}/test_configs")
generateCopyFileTarget("osquery_tools_tests_conffiles" "REGEX" "*.conf" "${TEST_CONFIGS_DIR}")
generateCopyFileTarget("osquery_tools_tests_configfiles" "REGEX" "*.config" "${TEST_CONFIGS_DIR}")
generateCopyFileTarget("osquery_tools_tests_plistfiles" "REGEX" "*.plist" "${TEST_CONFIGS_DIR}")