Move unit test main code 98/262198/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 4 Aug 2021 05:08:15 +0000 (14:08 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 4 Aug 2021 05:08:15 +0000 (14:08 +0900)
Extract main code for upper directory hierachy to used by other unit tests.

Change-Id: I313b299931183ecc62446d14cd0becd0e3e82348
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
tests/unit_tests/CMakeLists.txt
tests/unit_tests/pkg_upgrade/CMakeLists.txt [deleted file]
tests/unit_tests/test_main.cc [moved from tests/unit_tests/pkg_upgrade/src/test_main.cc with 100% similarity]

index caa6d7d..5dd2f83 100644 (file)
@@ -1 +1,49 @@
-ADD_SUBDIRECTORY(pkg_upgrade)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(pkgmgr-tool_unittests C CXX)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(pkgmgr-tool_unittests REQUIRED
+  dlog
+  gmock
+  pkgmgr-parser
+  pkgmgr-info
+  libtzplatform-config
+  libsmack
+  sqlite3
+)
+
+FOREACH(flag ${pkgmgr-tool_unittests_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -fPIE")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++14")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+ADD_DEFINITIONS("-DDB_PATH=\"${DB_PATH}\"")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../src/pkg_upgrade/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/pkg_upgrade/src PKG_UPGRADE_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/rsc-copy/src RSC_COPY_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/pkg_upgrade/src LIB_SOURCES)
+LIST(REMOVE_ITEM LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../../src/pkg_upgrade/src/main.cc)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES)
+
+ADD_EXECUTABLE(${PROJECT_NAME}
+       ${PKG_UPGRADE_SRCS}
+    ${RSC_COPY_SRCS}
+       ${MOCK_SOURCES}
+       ${LIB_SOURCES}
+    test_main.cc
+)
+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}
+    ${pkgmgr-tool_unittests_LDFLAGS}
+)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
+INSTALL(DIRECTORY pkg_upgrade/data/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/pkg_upgrade/data)
diff --git a/tests/unit_tests/pkg_upgrade/CMakeLists.txt b/tests/unit_tests/pkg_upgrade/CMakeLists.txt
deleted file mode 100644 (file)
index 935e117..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
-PROJECT(pkgmgr-tool_unittests C CXX)
-
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(pkgmgr-tool_unittests REQUIRED
-  dlog
-  gmock
-  pkgmgr-parser
-  pkgmgr-info
-  libtzplatform-config
-  libsmack
-  sqlite3
-)
-
-FOREACH(flag ${pkgmgr-tool_unittests_CFLAGS})
-    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -fPIE")
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++14")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
-
-ADD_DEFINITIONS("-DDB_PATH=\"${DB_PATH}\"")
-
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../src/pkg_upgrade/include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../)
-
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../../src/pkg_upgrade/src LIB_SOURCES)
-LIST(REMOVE_ITEM LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/pkg_upgrade/src/main.cc)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../mock MOCK_SOURCES)
-
-ADD_EXECUTABLE(${PROJECT_NAME}
-       ${SOURCES}
-       ${MOCK_SOURCES}
-       ${LIB_SOURCES}
-)
-
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
-TARGET_LINK_LIBRARIES(${PROJECT_NAME}
-    ${pkgmgr-tool_unittests_LDFLAGS}
-)
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
-INSTALL(DIRECTORY data/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/data)