--- /dev/null
+# cscope/ctag data
+/cscope.files
+/cscope.out
+/tags
+
+# Temporary files
+*.swp
+*~
+
+# Build
+/build
--- /dev/null
+# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(OSQUERY)
+
+INCLUDE(FindPkgConfig)
+INCLUDE(GNUInstallDirs)
+
+IF(NOT CMAKE_BUILD_TYPE)
+ SET(CMAKE_BUILD_TYPE "RELEASE")
+ENDIF(NOT CMAKE_BUILD_TYPE)
+
+SET(CMAKE_CXX_FLAGS_DEBUG "-g -std=c++11 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
+SET(CMAKE_CXX_FLAGS_RELEASE "-g -std=c++11 -O2 -DNDEBUG")
+
+SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_DEFINITIONS("-fPIC")
+ADD_DEFINITIONS("-Werror")
+ADD_DEFINITIONS("-Wall")
+ADD_DEFINITIONS("-Wextra")
+ADD_DEFINITIONS("-pedantic")
+ADD_DEFINITIONS("-pedantic-errors")
+
+INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}")
+INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
+
+ENABLE_TESTING()
+
+ADD_SUBDIRECTORY(osquery)
--- /dev/null
+all:
+ mkdir -p build
+ cd build && cmake .. && make --no-print-directory $(MAKEFLAGS)
+
+clean:
+ rm -rf build
+
+docker_run:
+ docker build --network=host --tag tizen-osquery ./docker
+ docker run --rm -it --net=host -v $(shell pwd):/usr/src tizen-osquery
+
+%::
+ mkdir -p build
+ cd build && cmake .. && make --no-print-directory $@
--- /dev/null
+FROM ubuntu:16.04
+MAINTAINER sangwan.kwon@samsung.com
+
+RUN apt-get update && \
+ apt-get install -qq build-essential git cmake automake
+
+RUN cd /usr/src && \
+ git clone https://github.com/google/googletest.git
+
+RUN cd /usr/src/googletest && \
+ cmake . && make && make install
--- /dev/null
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+#pragma once
+
+#include <string>
+
+namespace osquery {
+
+/**
+ * @brief A utility class which is used to express the state of operations.
+ *
+ * @code{.cpp}
+ * osquery::Status foobar() {
+ * auto na = doSomeWork();
+ * if (na->itWorked()) {
+ * return osquery::Status(0, "OK");
+ * } else {
+ * return osquery::Status(1, na->getErrorString());
+ * }
+ * }
+ * @endcode
+ */
+class Status {
+ public:
+ /**
+ * @brief Default constructor
+ *
+ * Note that the default constructor initialized an osquery::Status instance
+ * to a state such that a successful operation is indicated.
+ */
+ Status() : code_(0), message_("OK") {}
+
+ /**
+ * @brief A constructor which can be used to concisely express the status of
+ * an operation.
+ *
+ * @param c a status code. The idiom is that a zero status code indicates a
+ * successful operation and a non-zero status code indicates a failed
+ * operation.
+ * @param m a message indicating some extra detail regarding the operation.
+ * If all operations were successful, this message should be "OK".
+ * Otherwise, it doesn't matter what the string is, as long as both the
+ * setter and caller agree.
+ */
+ Status(int c, std::string m) : code_(c), message_(m) {}
+
+ public:
+ /**
+ * @brief A getter for the status code property
+ *
+ * @return an integer representing the status code of the operation.
+ */
+ int getCode() const { return code_; }
+
+ /**
+ * @brief A getter for the message property
+ *
+ * @return a string representing arbitrary additional information about the
+ * success or failure of an operation. On successful operations, the idiom
+ * is for the message to be "OK"
+ */
+ std::string getMessage() const { return message_; }
+
+ /**
+ * @brief A convenience method to check if the return code is 0
+ *
+ * @code{.cpp}
+ * auto s = doSomething();
+ * if (s.ok()) {
+ * LOG(INFO) << "doing work";
+ * } else {
+ * LOG(ERROR) << s.toString();
+ * }
+ * @endcode
+ *
+ * @return a boolean which is true if the status code is 0, false otherwise.
+ */
+ bool ok() const { return getCode() == 0; }
+
+ /**
+ * @brief A synonym for osquery::Status::getMessage()
+ *
+ * @see getMessage()
+ */
+ std::string toString() const { return getMessage(); }
+
+ private:
+ /// the internal storage of the status code
+ int code_;
+
+ /// the internal storage of the status message
+ std::string message_;
+};
+}
--- /dev/null
+# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+SET(${TARGET_OSQUERY_LIB} osquery)
+
+PKG_CHECK_MODULES(${TARGET_TANCHOR_LIB} REQUIRED gtest pthread)
+
+INCLUDE_DIRECTORIES(SYSTEM ${TARGET_OSQUERY_LIB}_INCLUDE_DIRS)
+
+MACRO(ADD_OSQUERY_TEST TEST_NAME SOURCE)
+ ADD_EXECUTABLE(${TEST_NAME} ${SOURCE})
+ TARGET_LINK_LIBRARIES(${TEST_NAME} gtest pthread)
+ ADD_TEST(${TEST_NAME} ${TEST_NAME})
+ENDMACRO(ADD_OSQUERY_TEST)
+
+ADD_SUBDIRECTORY(core)
--- /dev/null
+# ADD_OSQUERY_LIBRARY(osquery_core init_osquery.cpp)
+
+ADD_OSQUERY_TEST(status_test status_tests.cpp)
--- /dev/null
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+#include "osquery/status.h"
+
+#include <gtest/gtest.h>
+
+namespace osquery {
+
+class StatusTests : public testing::Test {};
+
+TEST_F(StatusTests, test_constructor) {
+ auto s = Status(5, "message");
+ EXPECT_EQ(s.getCode(), 5);
+ EXPECT_EQ(s.getMessage(), "message");
+}
+
+TEST_F(StatusTests, test_constructor_2) {
+ Status s;
+ EXPECT_EQ(s.getCode(), 0);
+ EXPECT_EQ(s.getMessage(), "OK");
+}
+
+TEST_F(StatusTests, test_ok) {
+ auto s1 = Status(5, "message");
+ EXPECT_FALSE(s1.ok());
+ auto s2 = Status(0, "message");
+ EXPECT_TRUE(s2.ok());
+}
+
+TEST_F(StatusTests, test_to_string) {
+ auto s = Status(0, "foobar");
+ EXPECT_EQ(s.toString(), "foobar");
+}
+}
+
+int main(int argc, char* argv[]) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}