MACRO(ADD_VIST_CLIENT_LIBRARY TARGET)
ADD_LIBRARY(${TARGET} OBJECT ${ARGN})
LIST(APPEND ${TARGET_VIST_CLIENT_LIB}_SRCS $<TARGET_OBJECTS:${TARGET}>)
- SET(${TARGET_VIST_LIB}_SRCS ${${TARGET_VIST_CLIENT_LIB}_SRCS} PARENT_SCOPE)
+ SET(${TARGET_VIST_CLIENT_LIB}_SRCS ${${TARGET_VIST_CLIENT_LIB}_SRCS} PARENT_SCOPE)
ENDMACRO(ADD_VIST_CLIENT_LIBRARY)
+MACRO(ADD_VIST_COMMON_LIBRARY TARGET)
+ ADD_LIBRARY(${TARGET} OBJECT ${ARGN})
+ LIST(APPEND ${TARGET_VIST_COMMON_LIB}_SRCS $<TARGET_OBJECTS:${TARGET}>)
+ SET(${TARGET_VIST_COMMON_LIB}_SRCS ${${TARGET_VIST_COMMON_LIB}_SRCS} PARENT_SCOPE)
+ENDMACRO(ADD_VIST_COMMON_LIBRARY)
+
MACRO(ADD_VIST_POLICY_LIBRARY TARGET)
ADD_LIBRARY(${TARGET} OBJECT ${ARGN})
LIST(APPEND ${TARGET_VIST_POLICY_LIB}_SRCS $<TARGET_OBJECTS:${TARGET}>)
SET(TARGET_OSQUERY_LIB osquery)
SET(TARGET_VIST_CLIENT_LIB vist-client)
+SET(TARGET_VIST_COMMON_LIB vist-common)
SET(TARGET_VIST_LIB vist)
SET(TARGET_VIST_POLICY_LIB vist-policy)
SET(${TARGET_VIST_LIB}_SRCS "")
SET(${TARGET_VIST_LIB}_TESTS "")
+SET(${TARGET_VIST_COMMON_LIB}_SRCS "")
SET(DEPENDENCY klay dlog gflags)
-DSCRIPT_INSTALL_DIR="${SCRIPT_INSTALL_DIR}")
ADD_SUBDIRECTORY(client)
+ADD_SUBDIRECTORY(common)
+ADD_SUBDIRECTORY(ipc)
ADD_SUBDIRECTORY(notification)
ADD_SUBDIRECTORY(policy)
ADD_SUBDIRECTORY(sdk)
WORLD_READ
WORLD_EXECUTE)
-FILE(GLOB COMMON_TESTS "tests/*.cpp")
-ADD_VIST_TEST(${COMMON_TESTS})
-
ADD_EXECUTABLE(${TARGET_VIST_TEST} main/tests.cpp
${${TARGET_VIST_LIB}_TESTS})
TARGET_LINK_LIBRARIES(${TARGET_VIST_TEST} ${TARGET_VIST_LIB}
+ ${TARGET_VIST_CLIENT_LIB}
+ ${TARGET_VIST_COMMON_LIB}
gtest)
TARGET_LINK_WHOLE(${TARGET_VIST_TEST} ${TARGET_OSQUERY_LIB})
ADD_TEST(${TARGET_VIST_TEST} ${TARGET_VIST_TEST})
--- /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
+
+PKG_CHECK_MODULES(VIST_COMMON_DEPS REQUIRED gflags klay dlog)
+
+INCLUDE_DIRECTORIES(SYSTEM . ${VIST_COMMON_DEPS_INCLUDE_DIRS})
+
+ADD_VIST_COMMON_LIBRARY(vist_common common.cpp)
+
+FILE(GLOB COMMON_TESTS "tests/*.cpp")
+ADD_VIST_TEST(${COMMON_TESTS})
+
+ADD_LIBRARY(${TARGET_VIST_COMMON_LIB} STATIC ${${TARGET_VIST_COMMON_LIB}_SRCS})
+TARGET_LINK_LIBRARIES(${TARGET_VIST_COMMON_LIB} ${VIST_COMMON_DEPS_LIBRARIES}
+ pthread)
--- /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
+ */
+
+#include <vist/exception.hpp>
+#include <vist/logger.hpp>
+#include <vist/result.hpp>
--- /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
+ */
+
+#include <gtest/gtest.h>
+
+#include <vist/exception.hpp>
+
+enum class ErrCode {
+ InvalidArgument = 1,
+ DominError,
+ LogicError,
+ RuntimeError,
+ None
+};
+
+class ExceptionTests : public testing::Test {};
+
+TEST_F(ExceptionTests, exception)
+{
+ bool raised = false;
+ ErrCode ec = ErrCode::None;
+ std::string msg;
+
+ try {
+ THROW(ErrCode::InvalidArgument);
+ } catch (const vist::Exception<ErrCode>& e) {
+ raised = true;
+ ec = e.get();
+ msg = e.what();
+ }
+
+ EXPECT_TRUE(raised);
+ EXPECT_EQ(ec, ErrCode::InvalidArgument);
+ EXPECT_NE(std::string::npos, msg.find("ErrCode"));
+}
+
+TEST_F(ExceptionTests, exception_msg)
+{
+ bool raised = false;
+ ErrCode ec = ErrCode::None;
+ std::string msg;
+
+ try {
+ THROW(ErrCode::RuntimeError) << "Additional error message";
+ } catch (const vist::Exception<ErrCode>& e) {
+ raised = true;
+ ec = e.get();
+ msg = e.what();
+ }
+
+ EXPECT_TRUE(raised);
+ EXPECT_EQ(ec, ErrCode::RuntimeError);
+ EXPECT_NE(std::string::npos, msg.find("Additional"));
+}
--- /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
+ */
+
+#include <gtest/gtest.h>
+
+#include <vist/logger.hpp>
+
+class LoggerTests : public testing::Test {};
+
+TEST_F(LoggerTests, logging)
+{
+ INFO(VIST) << "Info message" << 1;
+ DEBUG(VIST) << "Debug message" << 2 << 'a';
+ WARN(VIST) << "Warn message" << 3 << 'b' << true;
+ ERROR(VIST) << "Error message" << 4 << 'c' << false << 0.0f;
+}
--- /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
+ */
+
+#include <gtest/gtest.h>
+
+#include <vist/result.hpp>
+
+#include <string>
+#include <vector>
+
+class ResultTests : public testing::Test {};
+
+using namespace vist;
+
+enum class FileErr {
+ InvalidArgument,
+ NotFound
+};
+
+Result<std::string, FileErr> readSuccess()
+{
+ return std::string("File contents");
+}
+
+Result<std::string, FileErr> readFail()
+{
+ return FileErr::NotFound;
+}
+
+Result<std::vector<int>, FileErr> readVector()
+{
+ std::vector<int> v{1, 2, 3};
+ return v;
+}
+
+TEST_F(ResultTests, success)
+{
+ EXPECT_TRUE(readSuccess().ok());
+ EXPECT_TRUE(!readSuccess().err());
+ EXPECT_NE(std::string::npos, readSuccess().get().find("File"));
+}
+
+TEST_F(ResultTests, fail)
+{
+ EXPECT_TRUE(readFail().err());
+ EXPECT_TRUE(!readFail().ok());
+ EXPECT_EQ(FileErr::NotFound, readFail().getErrCode());
+}
+
+TEST_F(ResultTests, vector)
+{
+ EXPECT_TRUE(readVector().ok());
+ EXPECT_TRUE(!readVector().err());
+ EXPECT_EQ(3, readVector().get().size());
+}
--- /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.
+#
+
+ADD_VIST_COMMON_LIBRARY(vist_ipc ipc.cpp)
--- /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
+ */
+
+#include <vist/ipc/client.hpp>
+#include <vist/ipc/server.hpp>
# See the License for the specific language governing permissions and
# limitations under the License
+ADD_VIST_COMMON_LIBRARY(vist_query_builder query-builder.cpp)
+
/// TSQB: Type Safe Query Builder
FILE(GLOB TSQB_TESTS "tests/*.cpp")
ADD_VIST_TEST(${TSQB_TESTS})
--- /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
+ */
+
+#include <vist/query-builder.hpp>
# limitations under the License.
#
+ADD_VIST_COMMON_LIBRARY(vist_sdk sdk.cpp)
+
FILE(GLOB POLICY_SDK_TESTS "tests/*.cpp")
ADD_VIST_TEST(${POLICY_SDK_TESTS})
--- /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
+ */
+
+#include <vist/sdk/policy-model.hpp>
+#include <vist/sdk/policy-provider.hpp>
+#include <vist/sdk/policy-value.hpp>
+++ /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
- */
-
-#include <gtest/gtest.h>
-
-#include <vist/exception.hpp>
-
-enum class ErrCode {
- InvalidArgument = 1,
- DominError,
- LogicError,
- RuntimeError,
- None
-};
-
-class ExceptionTests : public testing::Test {};
-
-TEST_F(ExceptionTests, exception)
-{
- bool raised = false;
- ErrCode ec = ErrCode::None;
- std::string msg;
-
- try {
- THROW(ErrCode::InvalidArgument);
- } catch (const vist::Exception<ErrCode>& e) {
- raised = true;
- ec = e.get();
- msg = e.what();
- }
-
- EXPECT_TRUE(raised);
- EXPECT_EQ(ec, ErrCode::InvalidArgument);
- EXPECT_NE(std::string::npos, msg.find("ErrCode"));
-}
-
-TEST_F(ExceptionTests, exception_msg)
-{
- bool raised = false;
- ErrCode ec = ErrCode::None;
- std::string msg;
-
- try {
- THROW(ErrCode::RuntimeError) << "Additional error message";
- } catch (const vist::Exception<ErrCode>& e) {
- raised = true;
- ec = e.get();
- msg = e.what();
- }
-
- EXPECT_TRUE(raised);
- EXPECT_EQ(ec, ErrCode::RuntimeError);
- EXPECT_NE(std::string::npos, msg.find("Additional"));
-}
+++ /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
- */
-
-#include <gtest/gtest.h>
-
-#include <vist/logger.hpp>
-
-class LoggerTests : public testing::Test {};
-
-TEST_F(LoggerTests, logging)
-{
- INFO(VIST) << "Info message" << 1;
- DEBUG(VIST) << "Debug message" << 2 << 'a';
- WARN(VIST) << "Warn message" << 3 << 'b' << true;
- ERROR(VIST) << "Error message" << 4 << 'c' << false << 0.0f;
-}
+++ /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
- */
-
-#include <gtest/gtest.h>
-
-#include <vist/result.hpp>
-
-#include <string>
-#include <vector>
-
-class ResultTests : public testing::Test {};
-
-using namespace vist;
-
-enum class FileErr {
- InvalidArgument,
- NotFound
-};
-
-Result<std::string, FileErr> readSuccess()
-{
- return std::string("File contents");
-}
-
-Result<std::string, FileErr> readFail()
-{
- return FileErr::NotFound;
-}
-
-Result<std::vector<int>, FileErr> readVector()
-{
- std::vector<int> v{1, 2, 3};
- return v;
-}
-
-TEST_F(ResultTests, success)
-{
- EXPECT_TRUE(readSuccess().ok());
- EXPECT_TRUE(!readSuccess().err());
- EXPECT_NE(std::string::npos, readSuccess().get().find("File"));
-}
-
-TEST_F(ResultTests, fail)
-{
- EXPECT_TRUE(readFail().err());
- EXPECT_TRUE(!readFail().ok());
- EXPECT_EQ(FileErr::NotFound, readFail().getErrCode());
-}
-
-TEST_F(ResultTests, vector)
-{
- EXPECT_TRUE(readVector().ok());
- EXPECT_TRUE(!readVector().err());
- EXPECT_EQ(3, readVector().get().size());
-}