Skip to content

Commit

Permalink
[Table sanity check] Integration test for the table (osquery#5147)
Browse files Browse the repository at this point in the history
  • Loading branch information
akindyakov authored Aug 31, 2018
1 parent 831becc commit dad4507
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions osquery/tests/integration/tables/system_controls.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
Expand All @@ -15,29 +14,29 @@
#include <osquery/tests/integration/tables/helper.h>

namespace osquery {
namespace {

class systemControls : public IntegrationTableTest {};
class SystemControlsTest : public IntegrationTableTest {};

TEST_F(systemControls, test_sanity) {
// 1. Query data
// QueryData data = execute_query("select * from system_controls");
// 2. Check size before validation
// ASSERT_GE(data.size(), 0ul);
// ASSERT_EQ(data.size(), 1ul);
// ASSERT_EQ(data.size(), 0ul);
// 3. Build validation map
// See IntegrationTableTest.cpp for avaialbe flags
// Or use custom DataCheck object
// ValidatatioMap row_map = {
// {"name", NormalType}
// {"oid", NormalType}
// {"subsystem", NormalType}
// {"current_value", NormalType}
// {"config_value", NormalType}
// {"type", NormalType}
//}
// 4. Perform validation
// validate_rows(data, row_map);
TEST_F(SystemControlsTest, sanity) {
auto const rows = execute_query("select * from system_controls");
auto const row_map = ValidatatioMap{
{"name", NonEmptyString},
{"oid", NonEmptyString},
{"subsystem",
SpecificValuesCheck{
"", "kern", "vm", "vfs", "net", "debug", "hw", "machdep", "user"}},
{"current_value", NormalType},
{"config_value", NormalType},
{"type",
SpecificValuesCheck{
"", "node", "int", "string", "quad", "opaque", "struct"}},
#ifdef __APPLE__
{"field_name", NormalType},
#endif
};
validate_rows(rows, row_map);
}

} // namespace
} // namespace osquery

0 comments on commit dad4507

Please sign in to comment.