Move all tests under single directory hierarchy 24/280724/3
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 2 Sep 2022 10:28:53 +0000 (12:28 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 2 Sep 2022 14:41:01 +0000 (14:41 +0000)
This commit:
 - moves api tests to tests/api_tests,
 - moves integration tests under tests/integration and adds it into tests package
 - moves client example application under test/client_example
 - drops no-op sessiond tests (test template)
 - drops unused infrastructure for runnnig tests at build time

Change-Id: I6047f66c358b089710c30709454f7afa891bd10b

24 files changed:
CMakeLists.txt
libsessiond/test/CMakeLists.txt [deleted file]
libsessiond/test/test_h_lib.cpp [deleted file]
packaging/sessiond.spec
sessiond/test/CMakeLists.txt [deleted file]
sessiond/test/test_one.cpp [deleted file]
tests/CMakeLists.txt [new file with mode: 0644]
tests/api_tests/CMakeLists.txt [moved from libsessiond/target_test/CMakeLists.txt with 100% similarity]
tests/api_tests/test_api_add_remove_user.cpp [moved from libsessiond/target_test/test_api_add_remove_user.cpp with 100% similarity]
tests/api_tests/test_api_add_remove_user_err.cpp [moved from libsessiond/target_test/test_api_add_remove_user_err.cpp with 100% similarity]
tests/api_tests/test_api_adduserwait.cpp [moved from libsessiond/target_test/test_api_adduserwait.cpp with 100% similarity]
tests/api_tests/test_api_event_wait_done_err.cpp [moved from libsessiond/target_test/test_api_event_wait_done_err.cpp with 100% similarity]
tests/api_tests/test_api_get_user_list.cpp [moved from libsessiond/target_test/test_api_get_user_list.cpp with 100% similarity]
tests/api_tests/test_api_register_event_err.cpp [moved from libsessiond/target_test/test_api_register_event_err.cpp with 100% similarity]
tests/api_tests/test_api_removeuserwait.cpp [moved from libsessiond/target_test/test_api_removeuserwait.cpp with 100% similarity]
tests/api_tests/test_api_switch_user_completion.cpp [moved from libsessiond/target_test/test_api_switch_user_completion.cpp with 100% similarity]
tests/api_tests/test_api_switch_user_wait.cpp [moved from libsessiond/target_test/test_api_switch_user_wait.cpp with 100% similarity]
tests/api_tests/test_api_switchuser.cpp [moved from libsessiond/target_test/test_api_switchuser.cpp with 100% similarity]
tests/api_tests/test_api_switchuser_err.cpp [moved from libsessiond/target_test/test_api_switchuser_err.cpp with 100% similarity]
tests/api_tests/test_hlp.hpp [moved from libsessiond/target_test/test_hlp.hpp with 100% similarity]
tests/client_example/CMakeLists.txt [moved from clientExample/CMakeLists.txt with 90% similarity]
tests/client_example/main.cpp [moved from clientExample/app/main.cpp with 100% similarity]
tests/integration/CMakeLists.txt [new file with mode: 0644]
tests/integration/sessiond-integration-tests.sh [moved from sessiond-integration-tests.sh with 100% similarity]

index d03fff9..0deede7 100644 (file)
@@ -13,29 +13,4 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 add_subdirectory(common)
 add_subdirectory(libsessiond)
 add_subdirectory(sessiond)
-add_subdirectory(clientExample)
-
-option(ENABLE_TARGET_TESTS "On target tests" ON)
-if(ENABLE_TARGET_TESTS)
-       find_package(GTest REQUIRED)
-       add_subdirectory(libsessiond/target_test)
-endif(ENABLE_TARGET_TESTS)
-
-enable_testing()
-
-#set ON if want run libsessiond test
-option(ENABLE_LIB_TESTS "Run libsessiond unit tests after build" OFF)
-if(ENABLE_LIB_TESTS)
-       find_package(GTest REQUIRED)
-       include(CTest)
-       add_subdirectory(libsessiond/test)
-endif(ENABLE_LIB_TESTS)
-
-#set ON if want run sessiond tests
-option(ENABLE_SESSIOND_TESTS "Run sessiond unit tests after build" OFF)
-
-if(ENABLE_SESSIOND_TESTS)
-       find_package(GTest REQUIRED)
-       include(CTest)
-       add_subdirectory(sessiond/test)
-endif(ENABLE_SESSIOND_TEST)
+add_subdirectory(tests)
diff --git a/libsessiond/test/CMakeLists.txt b/libsessiond/test/CMakeLists.txt
deleted file mode 100644 (file)
index c6cb9c7..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-function(add_libsd_mocked_test name wraps)
-
-       message("cmake src dir ====> ${CMAKE_SOURCE_DIR}")
-       set(CMAKE_CXX_STANDARD 20)
-       add_executable(test_${name} test_${name}.cpp)
-       add_library( libsessiond_test STATIC ${CMAKE_SOURCE_DIR}/libsessiond/src/lib.c)
-       include_directories(${CMAKE_SOURCE_DIR}/libsessiond/include ${GTEST_INCLUDE_DIR})
-       target_link_libraries(test_${name} libsessiond_test gtest_main gtest ${wraps})
-       gtest_discover_tests(test_${name})
-
-       endfunction(add_libsd_mocked_test)
-
-add_libsd_mocked_test(h_lib  "")
diff --git a/libsessiond/test/test_h_lib.cpp b/libsessiond/test/test_h_lib.cpp
deleted file mode 100644 (file)
index fea3b24..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#include<iostream>
-#include <gtest/gtest.h>
-
-#include "sessiond.h"
-
-// Test
-TEST(subsession_add_user_test, AddUserTest) {
-       int res = subsession_add_user(0, 0, NULL, NULL);
-       EXPECT_EQ(res,0);
-}
index 54f8e63..6ba1f11 100644 (file)
@@ -46,7 +46,6 @@ mkdir -p build
 pushd build
 %cmake .. -DVERSION=%{version} -DCMAKE_BUILD_TYPE=Release
 make %{?jobs:-j%jobs}
-make %{?jobs:-j%jobs} test
 popd
 cp %{SOURCE1} .
 
@@ -91,6 +90,7 @@ popd
 %manifest sessiond.manifest
 %license LICENSE.MIT
 %{_bindir}/test_*
+%{_bindir}/sessiond-integration-tests.sh
 
 %files -n subsession-client-example
 %manifest sessiond.manifest
diff --git a/sessiond/test/CMakeLists.txt b/sessiond/test/CMakeLists.txt
deleted file mode 100644 (file)
index 891a137..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-function(add_sd_mocked_test name wraps)
-
-       message("cmake sessiond test src dir ====> ${CMAKE_SOURCE_DIR}")
-       set(CMAKE_CXX_STANDARD 20)
-       add_executable(test_${name} test_${name}.cpp)
-       #uncomment this line when add functions/files to test
-
-       #add_library( sessiond_test STATIC ${CMAKE_SOURCE_DIR}/sessiond/src/files.c)
-
-       #uncomment this line when "include" directory for local includes exists
-       #include_directories(${CMAKE_SOURCE_DIR}/sessiond/include ${GTEST_INCLUDE_DIR})
-
-       #add additional libs here
-       target_link_libraries(test_${name}  gtest_main gtest  ${wraps})
-       gtest_discover_tests(test_${name})
-
-endfunction(add_sd_mocked_test)
-
-add_sd_mocked_test(one  "")
diff --git a/sessiond/test/test_one.cpp b/sessiond/test/test_one.cpp
deleted file mode 100644 (file)
index d7a39db..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#include<iostream>
-#include <gtest/gtest.h>
-
-// this test will fail
-TEST(test_one, TestOne) {
-       EXPECT_EQ(0,1);
-}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..051d4f8
--- /dev/null
@@ -0,0 +1,10 @@
+add_subdirectory(client_example)
+add_subdirectory(integration)
+
+option(ENABLE_TARGET_TESTS "On target API tests" ON)
+if(ENABLE_TARGET_TESTS)
+       find_package(GTest REQUIRED)
+       add_subdirectory(api_tests)
+endif(ENABLE_TARGET_TESTS)
+
+enable_testing()
similarity index 90%
rename from clientExample/CMakeLists.txt
rename to tests/client_example/CMakeLists.txt
index 2b729b3..5b486fb 100644 (file)
@@ -7,7 +7,7 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 find_package(PkgConfig)
 pkg_check_modules(DEPS REQUIRED IMPORTED_TARGET glib-2.0 gio-2.0 gobject-2.0)
 
-add_executable(subsession-client-example app/main.cpp)
+add_executable(subsession-client-example main.cpp)
 target_compile_features(subsession-client-example PUBLIC cxx_std_20)
 target_link_libraries(subsession-client-example PRIVATE PkgConfig::DEPS libsessiond)
 install(TARGETS subsession-client-example)
diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2f02827
--- /dev/null
@@ -0,0 +1,3 @@
+install(FILES sessiond-integration-tests.sh
+       DESTINATION bin
+       PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)