From: Chanwoo Choi Date: Fri, 17 Jun 2022 09:03:11 +0000 (+0900) Subject: tests: Move test code into tests directory and redefine the test role X-Git-Tag: accepted/tizen/unified/20220628.133607~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c15611cbf696b7fb212e8f37a97b6b35dcb10d4;p=platform%2Fcore%2Fsystem%2Fpass.git tests: Move test code into tests directory and redefine the test role Move test code into tests directory and redefine the test role as following because unittest will be added for each module. - intergraion test : Test the public interface of PASS daemon - haltest : Test the HAL interface of PASS daemon Change-Id: Ief0d07b38491454dc0dbb06a268e5c56de31a886 Signed-off-by: Chanwoo Choi --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 517d855..6116b46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(pass C) +PROJECT(pass) ######################################################## # PASS CMakeLists.txt @@ -130,5 +130,6 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/systemd/ DESTINATION lib/systemd/s PATTERN "${PROJECT_NAME}.service" ) -ADD_SUBDIRECTORY(unittest) +ADD_SUBDIRECTORY(tests/integration-test) +ADD_SUBDIRECTORY(tests/haltest) ADD_SUBDIRECTORY(lib) diff --git a/packaging/pass.spec b/packaging/pass.spec index 7c64eae..29a506e 100644 --- a/packaging/pass.spec +++ b/packaging/pass.spec @@ -123,7 +123,7 @@ systemctl daemon-reload %files -n %{unittest_name} %defattr(-,root,root,-) -%{_bindir}/pass-unittests +%{_bindir}/pass-tests %files -n %{libpass_resource_monitor_name} %license LICENSE diff --git a/unittest/CMakeLists.txt b/tests/haltest/CMakeLists.txt similarity index 73% rename from unittest/CMakeLists.txt rename to tests/haltest/CMakeLists.txt index 802fa58..1f0e9a3 100644 --- a/unittest/CMakeLists.txt +++ b/tests/haltest/CMakeLists.txt @@ -29,16 +29,9 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") -SET(src ${CMAKE_SOURCE_DIR}/unittest/power-haltests.cpp) +SET(src ${CMAKE_SOURCE_DIR}/tests/haltest/power-haltests.cpp) GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) MESSAGE("${src_name}") ADD_EXECUTABLE(${src_name} ${SRCS} ${src}) TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal) INSTALL(TARGETS ${src_name} DESTINATION /usr/bin/hal) - -SET(src ${CMAKE_SOURCE_DIR}/unittest/pass-unittests.cpp) -GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) -MESSAGE("${src_name}") -ADD_EXECUTABLE(${src_name} ${SRCS} ${src}) -TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal) -INSTALL(TARGETS ${src_name} DESTINATION /usr/bin/) diff --git a/unittest/power-haltests.cpp b/tests/haltest/power-haltests.cpp similarity index 100% rename from unittest/power-haltests.cpp rename to tests/haltest/power-haltests.cpp diff --git a/tests/integration-test/CMakeLists.txt b/tests/integration-test/CMakeLists.txt new file mode 100644 index 0000000..2f12af5 --- /dev/null +++ b/tests/integration-test/CMakeLists.txt @@ -0,0 +1,37 @@ +PROJECT(pass C CXX) + +SET(SRCS ${CMAKE_SOURCE_DIR}/src/pass/pass-hal.c + ${CMAKE_SOURCE_DIR}/src/pass/pass-parser.c + ${CMAKE_SOURCE_DIR}/src/util/common.c +) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/pass) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) + +INCLUDE(FindPkgConfig) +pkg_check_modules(gtest_pkgs REQUIRED + glib-2.0 + gio-2.0 + gmock + dlog + json-c + hal-api-power +) + +FOREACH(flag ${gtest_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE -fPIC") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +SET(src ${CMAKE_SOURCE_DIR}/tests/integration-test/pass-tests.cpp) +GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) +MESSAGE("${src_name}") +ADD_EXECUTABLE(${src_name} ${SRCS} ${src}) +TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal) +INSTALL(TARGETS ${src_name} DESTINATION /usr/bin/) diff --git a/unittest/pass-unittests.cpp b/tests/integration-test/pass-tests.cpp similarity index 100% rename from unittest/pass-unittests.cpp rename to tests/integration-test/pass-tests.cpp