From 234b2afd450c369d0b21aaa014c706a47802148f Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 5 Jan 2023 18:26:45 +0900 Subject: [PATCH 01/16] Call db create functions before starting smoke test Database will not be created automatically. Change-Id: Ia374a7884649694c2fc8afd41f38b7b09eb876ec Signed-off-by: ilho kim --- test/smoke_tests/extensive_smoke_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/smoke_tests/extensive_smoke_test.cc b/test/smoke_tests/extensive_smoke_test.cc index 6bd46c9..a2a8114 100644 --- a/test/smoke_tests/extensive_smoke_test.cc +++ b/test/smoke_tests/extensive_smoke_test.cc @@ -27,6 +27,7 @@ class SmokeEnvironment : public testing::Environment { backups_ = SetupBackupDirectories(test_user.uid); for (auto& path : backups_) ASSERT_TRUE(BackupPath(path)); + CreateDatabase(); } void TearDown() override { ASSERT_TRUE(request_mode_ == ci::RequestMode::GLOBAL || -- 2.7.4 From 9cee72eabec95b3527ed21a9e1110f13ff8c1824 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 5 Jan 2023 19:55:14 +0900 Subject: [PATCH 02/16] Run installer with subprocess in smoke test The main process becomes heavy because the extensive smoke test generates and executes a large amount of installer instance. To lighten the main process, execute it as subprocess Change-Id: Ie53606a3ce61bc2fe097e7a3d8e5badb02a2509e Signed-off-by: ilho kim --- test/smoke_tests/extensive_smoke_test.cc | 91 ++++++++++++++++++-------------- test/smoke_tests/wgt_smoke_utils.cc | 5 ++ test/smoke_tests/wgt_smoke_utils.h | 1 + 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/test/smoke_tests/extensive_smoke_test.cc b/test/smoke_tests/extensive_smoke_test.cc index a2a8114..e51a0f7 100644 --- a/test/smoke_tests/extensive_smoke_test.cc +++ b/test/smoke_tests/extensive_smoke_test.cc @@ -112,12 +112,12 @@ TEST_F(SmokeTest, RecoveryMode_ForInstallation) { EXTENDED_ASSERT_FALSE(recovery_file.empty()); std::unique_ptr recovery_info = GetRecoverFileInfo(recovery_file); - EXTENDED_ASSERT_EQ(backend.Recover(recovery_file), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file), + BackendInterface::SubProcessResult::SUCCESS); if (recovery_info->cleanup()) { EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); - EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); } else { EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); } @@ -130,7 +130,8 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) { bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt"; bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); - ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.InstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); std::string pkgid = "smokewgt10"; std::string appid = "smokewgt10.RecoveryModeForUpdate"; AddDataFiles(pkgid, params.test_user.uid); @@ -145,8 +146,8 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) { EXTENDED_ASSERT_FALSE(recovery_file.empty()); std::unique_ptr recovery_info = GetRecoverFileInfo(recovery_file); - EXTENDED_ASSERT_EQ(backend.Recover(recovery_file), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file), + BackendInterface::SubProcessResult::SUCCESS); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); std::string version = recovery_info->cleanup() ? "2\n" :"1\n"; @@ -155,10 +156,10 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) { EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid)); if (recovery_info->cleanup()) { - EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid), - ci::AppInstaller::Result::OK); - EXTENDED_ASSERT_EQ(backend.Install(path_old), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); + EXTENDED_ASSERT_EQ(backend.InstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); } } @@ -172,7 +173,8 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { std::string pkgid = "smokewgt30"; std::string appid = "smokewgt30.RecoveryModeForDelta"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); - ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK); + ASSERT_EQ(BackendInterface::SubProcessResult::SUCCESS, + backend.InstallWithSubprocess(path_old)); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); std::vector args = @@ -184,8 +186,8 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { EXTENDED_ASSERT_FALSE(recovery_file.empty()); std::unique_ptr recovery_info = GetRecoverFileInfo(recovery_file); - EXTENDED_ASSERT_EQ(backend.Recover(recovery_file), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file), + BackendInterface::SubProcessResult::SUCCESS); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); std::string contents = recovery_info->cleanup() ? "2\n" : "1\n"; @@ -194,10 +196,10 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid)); if (recovery_info->cleanup()) { - EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid), - ci::AppInstaller::Result::OK); - EXTENDED_ASSERT_EQ(backend.Install(path_old), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); + EXTENDED_ASSERT_EQ(backend.InstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); } } @@ -220,13 +222,13 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) { EXTENDED_ASSERT_FALSE(recovery_file.empty()); std::unique_ptr recovery_info = GetRecoverFileInfo(recovery_file); - EXTENDED_ASSERT_EQ(backend.Recover(recovery_file), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file), + BackendInterface::SubProcessResult::SUCCESS); ScopedTzipInterface interface(pkgid, params.test_user.uid); if (recovery_info->cleanup()) { EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); - EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); } else { EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); } @@ -243,7 +245,8 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) { std::string pkgid = "smokewgt32"; std::string appid = "smokewgt32.RecoveryModeForMountUpdate"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); - ASSERT_EQ(backend.MountInstall(path_old), ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); std::vector args = @@ -260,8 +263,8 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) { EXTENDED_ASSERT_FALSE(recovery_file.empty()); std::unique_ptr recovery_info = GetRecoverFileInfo(recovery_file); - EXTENDED_ASSERT_EQ(backend.Recover(recovery_file), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file), + BackendInterface::SubProcessResult::SUCCESS); ScopedTzipInterface interface(pkgid, params.test_user.uid); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); @@ -271,10 +274,10 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) { EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid)); if (recovery_info->cleanup()) { interface.Release(); - EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid), - ci::AppInstaller::Result::OK); - EXTENDED_ASSERT_EQ(backend.MountInstall(path_old), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); + EXTENDED_ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); } } @@ -301,7 +304,8 @@ TEST_F(SmokeTest, UpdateMode_Rollback) { bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Rollback_2.wgt"; std::string pkgid = "smokewgt07"; std::string appid = "smokewgt07.UpdateModeRollback"; - ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.InstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = @@ -321,7 +325,8 @@ TEST_F(SmokeTest, DeltaMode_Rollback) { bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Rollback.delta"; std::string pkgid = "smokewgt01"; std::string appid = "smokewgt01.DeltaMode"; - ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.InstallWithSubprocess(path), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = @@ -359,7 +364,8 @@ TEST_F(HybridSmokeTest, UpdateMode_Rollback) { "UpdateMode_Rollback_Hybrid_2.wgt"; std::string pkgid = "smokehyb08"; std::string appid1 = "smokehyb08.web"; - ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.InstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = @@ -382,7 +388,8 @@ TEST_F(HybridSmokeTest, DeltaMode_Rollback_Hybrid) { "DeltaMode_Rollback_Hybrid.delta"; std::string pkgid = "smokehyb11"; std::string appid1 = "smokehyb11.web"; - ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.InstallWithSubprocess(path), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = {"", "-i", path.c_str(), "-u", test_user_str.c_str()}; @@ -424,7 +431,8 @@ TEST_F(HybridSmokeTest, MountUpdateMode_Rollback) { "MountUpdateMode_Rollback_Hybrid_2.wgt"; std::string pkgid = "smokehyb10"; std::string appid1 = "smokehyb10.web"; - ASSERT_EQ(backend.MountInstall(path_old), ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = @@ -462,8 +470,8 @@ TEST_F(SmokeTest, MountUpdateMode_Rollback) { kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt"; std::string pkgid = "smokewgt34"; std::string appid = "smokewgt34.web"; - ASSERT_EQ(backend.MountInstall(path_old), - ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = @@ -486,7 +494,8 @@ TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) { bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForReadonlyUpdateInstall_2.wgt"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); - ASSERT_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK); + ASSERT_EQ(backend.InstallPreloadWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); std::string pkgid = "smokewgt51"; std::string appid = "smokewgt51.RecoveryModeForReadonlyUpdateInstall"; AddDataFiles(pkgid, params.test_user.uid); @@ -500,8 +509,8 @@ TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) { EXTENDED_ASSERT_FALSE(recovery_file.empty()); std::unique_ptr recovery_info = GetRecoverFileInfo(recovery_file); - EXTENDED_ASSERT_EQ(backend.Recover(recovery_file), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.RecoverWithSubprocess(recovery_file), + BackendInterface::SubProcessResult::SUCCESS); if (recovery_info->cleanup()) params.is_readonly = false; EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); @@ -512,8 +521,8 @@ TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) { EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid)); if (recovery_info->cleanup()) { - EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid), - ci::AppInstaller::Result::OK); + EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); } } diff --git a/test/smoke_tests/wgt_smoke_utils.cc b/test/smoke_tests/wgt_smoke_utils.cc index dec1e73..3b11756 100644 --- a/test/smoke_tests/wgt_smoke_utils.cc +++ b/test/smoke_tests/wgt_smoke_utils.cc @@ -67,6 +67,11 @@ WgtBackendInterface::CreateFailExpectedInstaller( return AppInstallerPtr(new FailExpectedWgtInstaller(pkgmgr, fail_at)); } +common_installer::Subprocess WgtBackendInterface::CreateSubprocess() const { + return common_installer::Subprocess( + "/usr/bin/wgt-installer-ut/smoke-test-helper"); +} + HybridBackendInterface::AppQueryInterfacePtr HybridBackendInterface::CreateQueryInterface() const { return AppQueryInterfacePtr(new wgt::WgtAppQueryInterface()); diff --git a/test/smoke_tests/wgt_smoke_utils.h b/test/smoke_tests/wgt_smoke_utils.h index 6b223e2..4467971 100644 --- a/test/smoke_tests/wgt_smoke_utils.h +++ b/test/smoke_tests/wgt_smoke_utils.h @@ -44,6 +44,7 @@ class WgtBackendInterface: public BackendInterface { common_installer::PkgMgrPtr pkgmgr) const override; AppInstallerPtr CreateFailExpectedInstaller( common_installer::PkgMgrPtr pkgmgr, int fail_at) const override; + common_installer::Subprocess CreateSubprocess() const override; }; class HybridBackendInterface: public BackendInterface { -- 2.7.4 From 523bb6a278450a8c0e5bf1709d623ac1c58098e0 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 5 Jan 2023 19:58:16 +0900 Subject: [PATCH 03/16] Supports the "remove_plugin_steps" option in smoke test This option is for prevent the excution of plugin that can affect the test Change-Id: I759cadb77421e85b9c8beed5c50f3396614358b2 Signed-off-by: ilho kim --- test/smoke_tests/smoke_test_helper.cc | 36 +++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/test/smoke_tests/smoke_test_helper.cc b/test/smoke_tests/smoke_test_helper.cc index 45dbacc..b83d41c 100644 --- a/test/smoke_tests/smoke_test_helper.cc +++ b/test/smoke_tests/smoke_test_helper.cc @@ -11,12 +11,36 @@ namespace ci = common_installer; +static int RunCrashWgtInstaller(ci::PkgMgrPtr pkgmgr, + int index, + std::string step_name, + smoke_test::CrashStepType type) { + smoke_test::CrashWgtInstaller t(pkgmgr, index, step_name, type); + + if (t.Run() != ci::AppInstaller::Result::OK) { + LOG(ERROR) << "CrashWgtInstaller run failure"; + return 1; + } + return 0; +} + +static int RunWgtInstallerWithoutParserPlugins(ci::PkgMgrPtr pkgmgr) { + smoke_test::WgtInstallerWithoutPasrserPlugins t(pkgmgr); + + if (t.Run() != ci::AppInstaller::Result::OK) { + LOG(ERROR) << "WgtInstallerWithoutPasrserPlugins run failure"; + return 1; + } + return 0; +} + // this main of test binay in done purely for recovery smoke test. int main(int argc, char** argv) { try { int index = -1; int backend_argc = argc; std::string step_name; + bool remove_plugins = false; smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS; if (!strcmp(argv[backend_argc - 1], "-type_clean")) { @@ -37,6 +61,12 @@ int main(int argc, char** argv) { LOG(DEBUG) << "Step crash after " << step_name << " step."; } + if (!strcmp(argv[backend_argc-1], "-remove_plugin_steps")) { + backend_argc--; + remove_plugins = true; + LOG(DEBUG) << "Remove parser plugins steps"; + } + ci::PkgmgrInstaller pkgmgr_installer; std::shared_ptr query_interface( new wgt::WgtAppQueryInterface()); @@ -47,8 +77,10 @@ int main(int argc, char** argv) { return EINVAL; } - smoke_test::CrashWgtInstaller installer(pkgmgr, index, step_name, type); - return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; + if (remove_plugins) + return RunWgtInstallerWithoutParserPlugins(pkgmgr); + else + return RunCrashWgtInstaller(pkgmgr, index, step_name, type); } catch (...) { std::cout << "Exception occurred during testing" << std::endl; return 1; -- 2.7.4 From dd1530bd51722621b3e82407c804222cde856cae Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 5 Jan 2023 21:44:52 +0900 Subject: [PATCH 04/16] Add hybrid smoke test helper This tool is used to execute installer with crash or plugin removed in hybrid smoke test Change-Id: Ic461c8faadf15753e2c0e2a9490bbf3340fa9bcc Signed-off-by: ilho kim --- CMakeLists.txt | 1 + packaging/wgt-backend.spec | 1 + packaging/wgt-installer-tests.manifest | 1 + test/smoke_tests/CMakeLists.txt | 6 ++ test/smoke_tests/hybrid_smoke_test_helper.cc | 88 ++++++++++++++++++++++++++++ test/smoke_tests/wgt_smoke_utils.cc | 5 ++ test/smoke_tests/wgt_smoke_utils.h | 79 ++++++++++++++++++------- 7 files changed, 159 insertions(+), 22 deletions(-) create mode 100644 test/smoke_tests/hybrid_smoke_test_helper.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index b39ba87..c1435dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ SET(TARGET_LIBNAME_HYBRID "hybrid-installer") SET(TARGET_SMOKE_TEST "smoke-test") SET(TARGET_SMOKE_TEST_EXTENSIVE "extensive-smoke-test") SET(TARGET_SMOKE_TEST_HELPER "smoke-test-helper") +SET(TARGET_HYBRID_SMOKE_TEST_HELPER "hybrid-smoke-test-helper") SET(TARGET_MANIFEST_TEST "manifest-test") SET(TARGET_WGT_SMOKE_UTILS "wgt-smoke-utils") diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 958c74b..8990a08 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -75,6 +75,7 @@ ln -s %{_bindir}/wgt-backend %{buildroot}%{_sysconfdir}/package-manager/backend/ %post -n wgt-installer-tests /usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner,cap_mac_override=eip %{_bindir}/wgt-installer-ut/smoke-test /usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner,cap_mac_override=eip %{_bindir}/wgt-installer-ut/smoke-test-helper +/usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner,cap_mac_override=eip %{_bindir}/wgt-installer-ut/hybrid-smoke-test-helper /usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner,cap_mac_override=eip %{_bindir}/wgt-installer-ut/extensive-smoke-test %files diff --git a/packaging/wgt-installer-tests.manifest b/packaging/wgt-installer-tests.manifest index e0632fd..e4cbba4 100644 --- a/packaging/wgt-installer-tests.manifest +++ b/packaging/wgt-installer-tests.manifest @@ -5,6 +5,7 @@ + diff --git a/test/smoke_tests/CMakeLists.txt b/test/smoke_tests/CMakeLists.txt index 0bd8a0a..fa1ad77 100644 --- a/test/smoke_tests/CMakeLists.txt +++ b/test/smoke_tests/CMakeLists.txt @@ -11,6 +11,9 @@ ADD_EXECUTABLE(${TARGET_SMOKE_TEST_EXTENSIVE} ADD_EXECUTABLE(${TARGET_SMOKE_TEST_HELPER} smoke_test_helper.cc ) +ADD_EXECUTABLE(${TARGET_HYBRID_SMOKE_TEST_HELPER} + hybrid_smoke_test_helper.cc +) ADD_EXECUTABLE(${TARGET_MANIFEST_TEST} manifest_test.cc ) @@ -21,6 +24,7 @@ ADD_LIBRARY(${TARGET_WGT_SMOKE_UTILS} SHARED TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST_EXTENSIVE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST_HELPER} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) +TARGET_INCLUDE_DIRECTORIES(${TARGET_HYBRID_SMOKE_TEST_HELPER} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) TARGET_INCLUDE_DIRECTORIES(${TARGET_MANIFEST_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) TARGET_INCLUDE_DIRECTORIES(${TARGET_WGT_SMOKE_UTILS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) @@ -49,12 +53,14 @@ APPLY_PKG_CONFIG(${TARGET_MANIFEST_TEST} PUBLIC TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES} ${TARGET_SMOKE_UTILS} ${TARGET_WGT_SMOKE_UTILS}) TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST_EXTENSIVE} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES} ${TARGET_SMOKE_UTILS} ${TARGET_WGT_SMOKE_UTILS}) TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_WGT_SMOKE_UTILS}) +TARGET_LINK_LIBRARIES(${TARGET_HYBRID_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_WGT_SMOKE_UTILS} ${TARGET_LIBNAME_HYBRID}) TARGET_LINK_LIBRARIES(${TARGET_MANIFEST_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${GTEST_MAIN_LIBRARIES}) TARGET_LINK_LIBRARIES(${TARGET_WGT_SMOKE_UTILS} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${TARGET_SMOKE_UTILS}) INSTALL(TARGETS ${TARGET_SMOKE_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR}) INSTALL(TARGETS ${TARGET_SMOKE_TEST_EXTENSIVE} DESTINATION ${BINDIR}/${DESTINATION_DIR}) INSTALL(TARGETS ${TARGET_SMOKE_TEST_HELPER} DESTINATION ${BINDIR}/${DESTINATION_DIR}) +INSTALL(TARGETS ${TARGET_HYBRID_SMOKE_TEST_HELPER} DESTINATION ${BINDIR}/${DESTINATION_DIR}) INSTALL(TARGETS ${TARGET_MANIFEST_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR}) INSTALL(TARGETS ${TARGET_WGT_SMOKE_UTILS} DESTINATION ${LIB_INSTALL_DIR}) INSTALL(FILES wgt_smoke_utils.h DESTINATION ${INCLUDEDIR}/app-installers/smoke_tests/) diff --git a/test/smoke_tests/hybrid_smoke_test_helper.cc b/test/smoke_tests/hybrid_smoke_test_helper.cc new file mode 100644 index 0000000..1398457 --- /dev/null +++ b/test/smoke_tests/hybrid_smoke_test_helper.cc @@ -0,0 +1,88 @@ +// Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#include +#include + +#include "smoke_tests/wgt_smoke_utils.h" +#include "wgt/utils/wgt_app_query_interface.h" + +namespace ci = common_installer; + +static int RunCrashHybridInstaller(ci::PkgMgrPtr pkgmgr, + int index, + std::string step_name, + smoke_test::CrashStepType type) { + smoke_test::CrashHybridInstaller t(pkgmgr, index, step_name, type); + + if (t.Run() != ci::AppInstaller::Result::OK) { + LOG(ERROR) << "CrashHybridInstaller run failure"; + return 1; + } + return 0; +} + +static int RunHybridInstallerWithoutParserPlugins(ci::PkgMgrPtr pkgmgr) { + smoke_test::HybridInstallerWithoutPasrserPlugins t(pkgmgr); + + if (t.Run() != ci::AppInstaller::Result::OK) { + LOG(ERROR) << "HybridInstallerWithoutPasrserPlugins run failure"; + return 1; + } + return 0; +} + +// this main of test binay in done purely for recovery smoke test. +int main(int argc, char** argv) { + try { + int index = -1; + int backend_argc = argc; + std::string step_name; + bool remove_plugins = false; + smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS; + + if (!strcmp(argv[backend_argc - 1], "-type_clean")) { + backend_argc--; + type = smoke_test::CrashStepType::CLEAN; + LOG(DEBUG) << "step will be crashed in clean operation"; + } + + if (!strcmp(argv[backend_argc - 2], "-idx")) { + index = atoi(argv[backend_argc - 1]); + backend_argc -= 2; + LOG(DEBUG) << "Step crash after " << index << " step."; + } + + if (!strcmp(argv[backend_argc - 2], "-step_name")) { + step_name = argv[backend_argc - 1]; + backend_argc -= 2; + LOG(DEBUG) << "Step crash after " << step_name << " step."; + } + + if (!strcmp(argv[backend_argc-1], "-remove_plugin_steps")) { + backend_argc--; + remove_plugins = true; + LOG(DEBUG) << "Remove parser plugins steps"; + } + + ci::PkgmgrInstaller pkgmgr_installer; + std::shared_ptr query_interface( + new wgt::WgtAppQueryInterface()); + auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, + &pkgmgr_installer, query_interface); + if (!pkgmgr) { + LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; + return EINVAL; + } + + if (remove_plugins) + return RunHybridInstallerWithoutParserPlugins(pkgmgr); + else + return RunCrashHybridInstaller(pkgmgr, index, step_name, type); + } catch (...) { + std::cout << "Exception occurred during testing" << std::endl; + return 1; + } +} + diff --git a/test/smoke_tests/wgt_smoke_utils.cc b/test/smoke_tests/wgt_smoke_utils.cc index 3b11756..a45bcc5 100644 --- a/test/smoke_tests/wgt_smoke_utils.cc +++ b/test/smoke_tests/wgt_smoke_utils.cc @@ -88,4 +88,9 @@ HybridBackendInterface::CreateFailExpectedInstaller( return AppInstallerPtr(new FailExpectedHybridInstaller(pkgmgr, fail_at)); } +common_installer::Subprocess HybridBackendInterface::CreateSubprocess() const { + return common_installer::Subprocess( + "/usr/bin/wgt-installer-ut/hybrid-smoke-test-helper"); +} + } // namespace smoke_test diff --git a/test/smoke_tests/wgt_smoke_utils.h b/test/smoke_tests/wgt_smoke_utils.h index 4467971..e0a0453 100644 --- a/test/smoke_tests/wgt_smoke_utils.h +++ b/test/smoke_tests/wgt_smoke_utils.h @@ -56,6 +56,7 @@ class HybridBackendInterface: public BackendInterface { common_installer::PkgMgrPtr pkgmgr) const override; AppInstallerPtr CreateFailExpectedInstaller( common_installer::PkgMgrPtr pkgmgr, int fail_at) const override; + common_installer::Subprocess CreateSubprocess() const override; }; #ifdef OVERRIDE_STEPS_BLOCK @@ -135,9 +136,9 @@ class FailExpectedHybridInstaller : public hybrid::HybridInstaller { #ifdef OVERRIDE_STEPS_BLOCK #undef OVERRIDE_STEPS_BLOCK #endif -#define OVERRIDE_STEPS_BLOCK(STEPS) \ +#define OVERRIDE_STEPS_BLOCK(TYPE, STEPS) \ void STEPS() override { \ - wgt::WgtInstaller::STEPS(); \ + TYPE::STEPS(); \ if (crash_at_ > -1) \ AddStepAtIndex(crash_at_, type_); \ else if (step_name_.size()) \ @@ -154,26 +155,60 @@ class CrashWgtInstaller : public wgt::WgtInstaller { step_name_(step_name), type_(type) { } private: - OVERRIDE_STEPS_BLOCK(InstallSteps) - OVERRIDE_STEPS_BLOCK(UpdateSteps) - OVERRIDE_STEPS_BLOCK(UninstallSteps) - OVERRIDE_STEPS_BLOCK(ReinstallSteps) - OVERRIDE_STEPS_BLOCK(DeltaSteps) - OVERRIDE_STEPS_BLOCK(MoveSteps) - OVERRIDE_STEPS_BLOCK(RecoverySteps) - OVERRIDE_STEPS_BLOCK(MountInstallSteps) - OVERRIDE_STEPS_BLOCK(MountUpdateSteps) - OVERRIDE_STEPS_BLOCK(ManifestDirectInstallSteps) - OVERRIDE_STEPS_BLOCK(ManifestDirectUpdateSteps) - OVERRIDE_STEPS_BLOCK(ManifestPartialInstallSteps) - OVERRIDE_STEPS_BLOCK(ManifestPartialUpdateSteps) - OVERRIDE_STEPS_BLOCK(PartialUninstallSteps) - OVERRIDE_STEPS_BLOCK(ReadonlyUpdateInstallSteps) - OVERRIDE_STEPS_BLOCK(ReadonlyUpdateUninstallSteps) - OVERRIDE_STEPS_BLOCK(DisablePkgSteps) - OVERRIDE_STEPS_BLOCK(EnablePkgSteps) - OVERRIDE_STEPS_BLOCK(MigrateExtImgSteps) - OVERRIDE_STEPS_BLOCK(RecoverDBSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, InstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, UpdateSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, UninstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReinstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, DeltaSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MoveSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, RecoverySteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MountInstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MountUpdateSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestDirectInstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestDirectUpdateSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestPartialInstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestPartialUpdateSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, PartialUninstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReadonlyUpdateInstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReadonlyUpdateUninstallSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, DisablePkgSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, EnablePkgSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MigrateExtImgSteps) + OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, RecoverDBSteps) + + int crash_at_; + std::string step_name_; + CrashStepType type_; +}; + +class CrashHybridInstaller : public hybrid::HybridInstaller { + public: + explicit CrashHybridInstaller(common_installer::PkgMgrPtr pkgmgr, + int crash_at, std::string step_name, CrashStepType type) : + hybrid::HybridInstaller(pkgmgr), crash_at_(crash_at), + step_name_(step_name), type_(type) { } + + private: + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, InstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, UpdateSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, UninstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReinstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, DeltaSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MoveSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, RecoverySteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MountInstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MountUpdateSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestDirectInstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestDirectUpdateSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestPartialInstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestPartialUpdateSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, PartialUninstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReadonlyUpdateInstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReadonlyUpdateUninstallSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, DisablePkgSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, EnablePkgSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MigrateExtImgSteps) + OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, RecoverDBSteps) int crash_at_; std::string step_name_; -- 2.7.4 From 4bbb5fc5fd8e926b21e0af06195853c4f99f9afe Mon Sep 17 00:00:00 2001 From: ilho kim Date: Tue, 10 Jan 2023 13:32:24 +0900 Subject: [PATCH 05/16] Release version 0.15.29 Changes: - Give an exec label,capability to the smoke test tool - Fix ManifestDirectUpdate test - Call db create functions before starting smoke test - Run installer with subprocess in smoke test - Supports the "remove_plugin_steps" option in smoke test - Add hybrid smoke test helper Change-Id: I0fcf58685077ab2ee77c01459739afd230a7d223 Signed-off-by: ilho kim --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 8990a08..520eacb 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.15.28 +Version: 0.15.29 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 93edec9e8074683ffc510ab13a2d7eb65ab31fb2 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Tue, 10 Jan 2023 21:18:07 +0900 Subject: [PATCH 06/16] Change backup logic in mount update If the file to be backed up is a hierarchical structure, the move operation is failed and the copy operation is executed As a result, the ownership and permission and smack label disappears in this case, Move the top directory to preserve it Change-Id: Ife987fd4bd617a623df6dd553e797a8fb57d5530 Signed-off-by: ilho kim --- src/hybrid/hybrid_installer.cc | 3 +-- .../step_wgt_prepare_package_directory.cc | 8 +------ .../step_wgt_update_package_directory.cc | 27 +++++++++++----------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index df7495b..d96fa36 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -230,7 +229,7 @@ void HybridInstaller::MountUpdateSteps() { "CheckWgtNotificationCategory"); AddStepAfter( "CheckWgtImePrivilege"); - AddStepAfter("MountUpdate"); + AddStepAfter("MountUpdate"); AddStepAfter("CreateIcons"); AddStepAfter("TpkPatchIcons", true); AddStepAfter("WgtPatchIcons"); diff --git a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc index 2439ded..7559f45 100644 --- a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc @@ -88,13 +88,7 @@ ci::Step::Status StepWgtPreparePackageDirectory::ExtractEntries() { } for (auto& entry : GetExtractEntries()) { - if (context_->request_type.get() == ci::RequestType::MountInstall) { - ci::RemoveAll(resource_path / entry); - } else if (context_->request_type.get() == ci::RequestType::MountUpdate) { - if (!ci::BackupDir(resource_path, backup_path, entry)) - return Status::APP_DIR_ERROR; - } - + ci::RemoveAll(resource_path / entry); if (!ci::ExtractToTmpDir(context_->file_path.get().c_str(), resource_path.c_str(), entry)) { LOG(ERROR) << "Failed to extract file"; diff --git a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc index 9cb801d..b23378e 100644 --- a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc @@ -11,26 +11,23 @@ #include #include +#include +#include + namespace bf = boost::filesystem; namespace bs = boost::system; namespace ci = common_installer; namespace { -const char* kBackupEntries[] = { + +const std::vector kBackupEntries = { "bin", - "shared/res" + "shared/res", + "res/wgt" }; bool MoveCreateDir(const bf::path& source, const bf::path& destination) { - if (!bf::exists(destination.parent_path())) { - bs::error_code error; - bf::create_directories(destination.parent_path(), error); - if (error) { - LOG(ERROR) << "Cannot create directory: " << destination.parent_path(); - return false; - } - } if (!ci::MoveDir(source, destination)) { LOG(ERROR) << "Failed to move directory " << destination; return false; @@ -48,11 +45,12 @@ StepWgtUpdatePackageDirectory::CreateBackupOfDirectories() { bf::path backup_path = ci::GetBackupPathForPackagePath(context_->GetPkgPath()); for (auto& entry : kBackupEntries) { - bf::path directory = context_->GetPkgPath() / entry; + std::string root_entry = entry.substr(0, entry.find("/")); + bf::path directory = context_->GetPkgPath() / root_entry; if (!bf::exists(directory)) continue; LOG(DEBUG) << "Backup directory entry: " << entry; - bf::path directory_backup = backup_path / entry; + bf::path directory_backup = backup_path / root_entry; if (!MoveCreateDir(directory, directory_backup)) { LOG(ERROR) << "Failed to create backup directory " << directory_backup; @@ -72,8 +70,9 @@ StepWgtUpdatePackageDirectory::RecoverBackupOfDirectories() { return Status::OK; for (auto& entry : kBackupEntries) { - bf::path directory = context_->GetPkgPath() / entry; - bf::path directory_backup = backup_path / entry; + std::string root_entry = entry.substr(0, entry.find("/")); + bf::path directory = context_->GetPkgPath() / root_entry; + bf::path directory_backup = backup_path / root_entry; if (!bf::exists(directory_backup)) continue; LOG(DEBUG) << "Recover directory entry: " << entry; -- 2.7.4 From 9d3abedebb8d8de1ba8343cc3820a02eb40a614a Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 12 Jan 2023 20:50:33 +0900 Subject: [PATCH 07/16] Move StepWgtPatchStorageDirectories in the right order Change-Id: I15f0d9053f40bf11495665cbc29eac687b7a1e76 Signed-off-by: ilho kim --- src/hybrid/hybrid_installer.cc | 18 ++++++------------ src/wgt/wgt_installer.cc | 18 ++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index d96fa36..99acd08 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -75,6 +75,7 @@ void HybridInstaller::InstallSteps() { AddStepAfter("CreateIcons"); AddStepAfter("TpkPatchIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("CopyTep"); AddStepAfter("CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); @@ -88,8 +89,6 @@ void HybridInstaller::InstallSteps() { ReplaceStep( "CreateStorageDirectories", wgt::filesystem::HybridAdditionalSharedDirs); - AddStepAfter( - "CreateStorageDirectories"); } void HybridInstaller::UpdateSteps() { @@ -109,6 +108,7 @@ void HybridInstaller::UpdateSteps() { AddStepAfter("CreateIcons"); AddStepAfter("TpkPatchIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("UpdateTep"); AddStepAfter("CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); @@ -119,8 +119,6 @@ void HybridInstaller::UpdateSteps() { AddStepAfter("MergeTpkConfig"); AddStepAfter("MergeTpkPrivileges", ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH); - AddStepAfter( - "CopyStorageDirectories"); } void HybridInstaller::UninstallSteps() { @@ -158,6 +156,7 @@ void HybridInstaller::DeltaSteps() { AddStepAfter("CreateIcons"); AddStepAfter("TpkPatchIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("UpdateTep"); AddStepAfter("CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); @@ -168,8 +167,6 @@ void HybridInstaller::DeltaSteps() { AddStepAfter("MergeTpkConfig"); AddStepAfter("MergeTpkPrivileges", ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH); - AddStepAfter( - "CopyStorageDirectories"); } void HybridInstaller::RecoverySteps() { @@ -198,6 +195,7 @@ void HybridInstaller::MountInstallSteps() { AddStepAfter("CreateIcons"); AddStepAfter("TpkPatchIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("CopyTep"); AddStepAfter("CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); @@ -211,8 +209,6 @@ void HybridInstaller::MountInstallSteps() { ReplaceStep( "CreateStorageDirectories", wgt::filesystem::HybridAdditionalSharedDirs); - AddStepAfter( - "CreateStorageDirectories"); } void HybridInstaller::MountUpdateSteps() { @@ -233,6 +229,7 @@ void HybridInstaller::MountUpdateSteps() { AddStepAfter("CreateIcons"); AddStepAfter("TpkPatchIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("UpdateTep"); AddStepAfter("CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); @@ -243,8 +240,6 @@ void HybridInstaller::MountUpdateSteps() { AddStepAfter("MergeTpkConfig"); AddStepAfter("MergeTpkPrivileges", ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH); - AddStepAfter( - "UpdateStorageDirectories"); } void HybridInstaller::ManifestDirectInstallSteps() { @@ -380,6 +375,7 @@ void HybridInstaller::ReadonlyUpdateInstallSteps() { AddStepAfter("CreateIcons"); AddStepAfter("TpkPatchIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("CopyTep"); AddStepAfter("CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); @@ -390,8 +386,6 @@ void HybridInstaller::ReadonlyUpdateInstallSteps() { AddStepAfter("MergeTpkConfig"); AddStepAfter("MergeTpkPrivileges", ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH); - AddStepAfter( - "UpdateStorageDirectories"); } void HybridInstaller::ReadonlyUpdateUninstallSteps() { diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index d79b585..82f1e8d 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -74,8 +74,7 @@ void WgtInstaller::InstallSteps() { AddStepAfter("CheckWgtImePrivilege"); AddStepAfter("EncryptResources"); RemoveStep("CreateIcons"); - AddStepAfter( - "CopyTep"); + AddStepAfter("CopyTep"); AddStepAfter( "WgtPatchStorageDirectories"); AddStepAfter( @@ -107,12 +106,11 @@ void WgtInstaller::UpdateSteps() { AddStepAfter("EncryptResources"); AddStepAfter("CreateIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("UpdateTep"); AddStepAfter("CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); AddStepAfter("CheckExtensionPrivileges"); - AddStepAfter( - "CopyStorageDirectories"); } void WgtInstaller::UninstallSteps() { @@ -159,12 +157,11 @@ void WgtInstaller::DeltaSteps() { AddStepAfter("EncryptResources"); AddStepAfter("CreateIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("UpdateTep"); AddStepAfter("CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); AddStepAfter("CheckExtensionPrivileges"); - AddStepAfter( - "CopyStorageDirectories"); } void WgtInstaller::RecoverySteps() { @@ -192,6 +189,7 @@ void WgtInstaller::MountInstallSteps() { AddStepAfter("MountInstall"); AddStepAfter("CreateIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("CopyTep"); AddStepAfter( "CopyPreviewIcons"); AddStepAfter( @@ -200,8 +198,6 @@ void WgtInstaller::MountInstallSteps() { ReplaceStep( "CreateStorageDirectories", wgt::filesystem::WgtAdditionalSharedDirs); - AddStepAfter( - "CreateStorageDirectories"); } void WgtInstaller::MountUpdateSteps() { @@ -221,13 +217,12 @@ void WgtInstaller::MountUpdateSteps() { AddStepAfter("MountUpdate"); AddStepAfter("CreateIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("UpdateTep"); AddStepAfter( "CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); AddStepAfter("CheckExtensionPrivileges"); - AddStepAfter( - "UpdateStorageDirectories"); } void WgtInstaller::ManifestDirectInstallSteps() { @@ -294,13 +289,12 @@ void WgtInstaller::ReadonlyUpdateInstallSteps() { AddStepAfter("EncryptResources"); AddStepAfter("CreateIcons", true); AddStepAfter("WgtPatchIcons"); + AddStepAfter("CopyTep"); AddStepAfter( "CopyPreviewIcons"); AddStepAfter( "CreateWgtSymbolicLink"); AddStepAfter("CheckExtensionPrivileges"); - AddStepAfter( - "UpdateStorageDirectories"); } void WgtInstaller::ReadonlyUpdateUninstallSteps() { -- 2.7.4 From 5f298d2a43d0defddaff7b9119d9c1197fa0ead3 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 12 Jan 2023 15:47:03 +0900 Subject: [PATCH 08/16] Add routine to check file status Change-Id: I738d4ab97fdda67111ad8316ec4fe6e04b856cef Signed-off-by: ilho kim --- test/smoke_tests/extensive_smoke_test.cc | 140 ++++++++++++++++++++++++++++--- 1 file changed, 129 insertions(+), 11 deletions(-) diff --git a/test/smoke_tests/extensive_smoke_test.cc b/test/smoke_tests/extensive_smoke_test.cc index e51a0f7..d1bdcfc 100644 --- a/test/smoke_tests/extensive_smoke_test.cc +++ b/test/smoke_tests/extensive_smoke_test.cc @@ -129,11 +129,23 @@ TEST_F(SmokeTest, RecoveryMode_ForInstallation) { TEST_F(SmokeTest, RecoveryMode_ForUpdate) { bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt"; bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt"; + std::string pkgid = "smokewgt10"; + std::string appid = "smokewgt10.RecoveryModeForUpdate"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); ASSERT_EQ(backend.InstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); - std::string pkgid = "smokewgt10"; - std::string appid = "smokewgt10.RecoveryModeForUpdate"; + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status_old(pkgid, params); + ASSERT_TRUE(expected_file_status_old.Init()); + ASSERT_EQ(backend.InstallWithSubprocess(path_new), + BackendInterface::SubProcessResult::SUCCESS); + FileInfoCollector expected_file_status_new(pkgid, params); + ASSERT_TRUE(expected_file_status_new.Init()); + ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); + ASSERT_EQ(backend.InstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); @@ -154,13 +166,20 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) { EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", version, params)); EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid)); + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); if (recovery_info->cleanup()) { + EXTENDED_ASSERT_TRUE( + expected_file_status_new.IsEqual(new_file_status, &added_files)); EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), BackendInterface::SubProcessResult::SUCCESS); EXTENDED_ASSERT_EQ(backend.InstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); + } else { + EXTENDED_ASSERT_TRUE( + expected_file_status_old.IsEqual(new_file_status, &added_files)); } } return true; @@ -175,6 +194,18 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); ASSERT_EQ(BackendInterface::SubProcessResult::SUCCESS, backend.InstallWithSubprocess(path_old)); + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status_old(pkgid, params); + ASSERT_TRUE(expected_file_status_old.Init()); + ASSERT_EQ(backend.InstallWithSubprocess(path_new), + BackendInterface::SubProcessResult::SUCCESS); + FileInfoCollector expected_file_status_new(pkgid, params); + ASSERT_TRUE(expected_file_status_new.Init()); + ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); + ASSERT_EQ(backend.InstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); std::vector args = @@ -194,13 +225,20 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", contents, params)); EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid)); + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); if (recovery_info->cleanup()) { + EXTENDED_ASSERT_TRUE( + expected_file_status_new.IsEqual(new_file_status, &added_files)); EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), BackendInterface::SubProcessResult::SUCCESS); EXTENDED_ASSERT_EQ(backend.InstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); + } else { + EXTENDED_ASSERT_TRUE( + expected_file_status_old.IsEqual(new_file_status, &added_files)); } } return true; @@ -247,6 +285,18 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) { RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status_old(pkgid, params); + ASSERT_TRUE(expected_file_status_old.Init()); + ASSERT_EQ(backend.MountInstallWithSubprocess(path_new), + BackendInterface::SubProcessResult::SUCCESS); + FileInfoCollector expected_file_status_new(pkgid, params); + ASSERT_TRUE(expected_file_status_new.Init()); + ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); + ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_user_str = std::to_string(params.test_user.uid); std::vector args = @@ -272,13 +322,20 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) { EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage( pkgid, "res/wgt/VERSION", version, params)); EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid)); + interface.Release(); + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); if (recovery_info->cleanup()) { - interface.Release(); + EXTENDED_ASSERT_TRUE( + expected_file_status_new.IsEqual(new_file_status, &added_files)); EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), BackendInterface::SubProcessResult::SUCCESS); EXTENDED_ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); + } else { + EXTENDED_ASSERT_TRUE( + expected_file_status_old.IsEqual(new_file_status, &added_files)); } } return true; @@ -306,11 +363,18 @@ TEST_F(SmokeTest, UpdateMode_Rollback) { std::string appid = "smokewgt07.UpdateModeRollback"; ASSERT_EQ(backend.InstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); - AddDataFiles(pkgid, params.test_user.uid); + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status(pkgid, params); + ASSERT_TRUE(expected_file_status.Init()); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = {"", "-i", path_new.c_str(), "-u", test_user_str.c_str()}; backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool { + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); + EXTENDED_ASSERT_TRUE( + expected_file_status.IsEqual(new_file_status, &added_files)); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, @@ -327,11 +391,18 @@ TEST_F(SmokeTest, DeltaMode_Rollback) { std::string appid = "smokewgt01.DeltaMode"; ASSERT_EQ(backend.InstallWithSubprocess(path), BackendInterface::SubProcessResult::SUCCESS); - AddDataFiles(pkgid, params.test_user.uid); + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status(pkgid, params); + ASSERT_TRUE(expected_file_status.Init()); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = {"", "-i", delta_package.c_str(), "-u", test_user_str.c_str()}; backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool { + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); + EXTENDED_ASSERT_TRUE( + expected_file_status.IsEqual(new_file_status, &added_files)); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 1\n", params)); @@ -366,11 +437,18 @@ TEST_F(HybridSmokeTest, UpdateMode_Rollback) { std::string appid1 = "smokehyb08.web"; ASSERT_EQ(backend.InstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); - AddDataFiles(pkgid, params.test_user.uid); + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status(pkgid, params); + ASSERT_TRUE(expected_file_status.Init()); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = {"", "-i", path_new.c_str(), "-u", test_user_str.c_str()}; backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool { + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); + EXTENDED_ASSERT_TRUE( + expected_file_status.IsEqual(new_file_status, &added_files)); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params)); EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, @@ -390,10 +468,17 @@ TEST_F(HybridSmokeTest, DeltaMode_Rollback_Hybrid) { std::string appid1 = "smokehyb11.web"; ASSERT_EQ(backend.InstallWithSubprocess(path), BackendInterface::SubProcessResult::SUCCESS); - AddDataFiles(pkgid, params.test_user.uid); + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status(pkgid, params); + ASSERT_TRUE(expected_file_status.Init()); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = {"", "-i", path.c_str(), "-u", test_user_str.c_str()}; backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool { + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); + EXTENDED_ASSERT_TRUE( + expected_file_status.IsEqual(new_file_status, &added_files)); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params)); // Check delta modifications bf::path root_path = GetPackageRoot(pkgid, params.test_user.uid); @@ -433,11 +518,18 @@ TEST_F(HybridSmokeTest, MountUpdateMode_Rollback) { std::string appid1 = "smokehyb10.web"; ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); - AddDataFiles(pkgid, params.test_user.uid); + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status(pkgid, params); + ASSERT_TRUE(expected_file_status.Init()); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = {"", "-w", path_new.c_str(), "-u", test_user_str.c_str()}; backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool { + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); + EXTENDED_ASSERT_TRUE( + expected_file_status.IsEqual(new_file_status, &added_files)); ScopedTzipInterface interface(pkgid, params.test_user.uid); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params)); @@ -472,11 +564,18 @@ TEST_F(SmokeTest, MountUpdateMode_Rollback) { std::string appid = "smokewgt34.web"; ASSERT_EQ(backend.MountInstallWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); - AddDataFiles(pkgid, params.test_user.uid); + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status(pkgid, params); + ASSERT_TRUE(expected_file_status.Init()); std::string test_user_str = std::to_string(params.test_user.uid); const char* argv[] = {"", "-w", path_new.c_str(), "-u", test_user_str.c_str()}; backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool { + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); + EXTENDED_ASSERT_TRUE( + expected_file_status.IsEqual(new_file_status, &added_files)); ScopedTzipInterface interface(pkgid, params.test_user.uid); EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); @@ -493,11 +592,23 @@ TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) { "RecoveryMode_ForReadonlyUpdateInstall.wgt"; bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForReadonlyUpdateInstall_2.wgt"; + std::string pkgid = "smokewgt51"; + std::string appid = "smokewgt51.RecoveryModeForReadonlyUpdateInstall"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); ASSERT_EQ(backend.InstallPreloadWithSubprocess(path_old), BackendInterface::SubProcessResult::SUCCESS); - std::string pkgid = "smokewgt51"; - std::string appid = "smokewgt51.RecoveryModeForReadonlyUpdateInstall"; + std::vector added_files; + AddDataFiles(pkgid, params.test_user.uid, &added_files); + FileInfoCollector expected_file_status_old(pkgid, params); + ASSERT_TRUE(expected_file_status_old.Init()); + ASSERT_EQ(backend.InstallWithSubprocess(path_new), + BackendInterface::SubProcessResult::SUCCESS); + params.is_readonly = false; + FileInfoCollector expected_file_status_new(pkgid, params); + ASSERT_TRUE(expected_file_status_new.Init()); + params.is_readonly = true; + ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), + BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); std::string test_uid_str = std::to_string(params.test_user.uid); std::vector args = @@ -519,11 +630,18 @@ TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) { EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", version, params)); EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid)); + FileInfoCollector new_file_status(pkgid, params); + EXTENDED_ASSERT_TRUE(new_file_status.Init()); if (recovery_info->cleanup()) { + EXTENDED_ASSERT_TRUE( + expected_file_status_new.IsEqual(new_file_status, &added_files)); EXTENDED_ASSERT_EQ(backend.UninstallWithSubprocess(pkgid), BackendInterface::SubProcessResult::SUCCESS); AddDataFiles(pkgid, params.test_user.uid); + } else { + EXTENDED_ASSERT_TRUE( + expected_file_status_old.IsEqual(new_file_status, &added_files)); } } return true; -- 2.7.4 From a2c05d73e4c08928019d512960e86acfc73a21ad Mon Sep 17 00:00:00 2001 From: ilho kim Date: Fri, 13 Jan 2023 16:53:58 +0900 Subject: [PATCH 09/16] Release version 0.15.30 Changes: - Change backup logic in mount update - Move StepWgtPatchStorageDirectories in the right order - Add routine to check file status Change-Id: Ibcf0dc872eda49280aa9179369d4cca642d98804 Signed-off-by: ilho kim --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 520eacb..ebaad27 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.15.29 +Version: 0.15.30 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 4961d18e50be8a326a86dda02d6ba661faab367c Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 23 Mar 2023 09:13:41 +0900 Subject: [PATCH 10/16] Fix static analysis issues Change-Id: Iba46bb2ddb6359bf54f0a15e1c4e922b87a3c421 Signed-off-by: Sangyoon Jang --- src/wgt/utils/extension_config_parser.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wgt/utils/extension_config_parser.cc b/src/wgt/utils/extension_config_parser.cc index 93d0abf..7583c46 100644 --- a/src/wgt/utils/extension_config_parser.cc +++ b/src/wgt/utils/extension_config_parser.cc @@ -58,6 +58,10 @@ std::string ExtensionConfigParser::GetNodeDir( if (xmlStrEqual(prop->name, kDirAttributeKey)) { char* prop_value = reinterpret_cast(xmlNodeListGetString( node->doc, prop->children, 1)); + if (!prop_value) { + LOG(ERROR) << "Failed to get value string"; + return {}; + } dir = prop_value; xmlFree(prop_value); break; @@ -116,6 +120,10 @@ std::unique_ptr xmlAttr* prop = nullptr; for (prop = root->properties; prop; prop = prop->next) { xmlChar* value_ptr = xmlNodeListGetString(root->doc, prop->children, 1); + if (!value_ptr) { + LOG(ERROR) << "Failed to get value string"; + continue; + } std::string prop_value(reinterpret_cast(value_ptr)); xmlFree(value_ptr); if (IsPropSupportDir(root, prop)) -- 2.7.4 From 1c9fc28a644a0831ec8e4cb0f154d55a9553f132 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 23 Mar 2023 12:38:39 +0900 Subject: [PATCH 11/16] Release version 0.15.31 Changes: - Fix static analysis issues Change-Id: I2870c444bb7c4a6626dfa73b54e586c3bcfabe1a Signed-off-by: Sangyoon Jang --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index ebaad27..8bd3e83 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.15.30 +Version: 0.15.31 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From b8f4916f496656ded172582dd483ecfa895887ba Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 3 Aug 2023 11:24:55 +0900 Subject: [PATCH 12/16] Fix static analysis issue 'std::time_t' to 'long' may or may not override sign-bit depending on size of implementation defined type which may cause unexpected results on porting to different platforms Change-Id: Ie4cfdc8f9e22e865d98b2b3ad2b918705f8beb5e Signed-off-by: ilho kim --- src/wgt/step/configuration/step_parse.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index d40be87..7927042 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -39,7 +40,6 @@ #include -#include #include #include #include @@ -155,7 +155,6 @@ namespace wgt { namespace configuration { namespace app_keys = wgt::application_widget_keys; -namespace sc = std::chrono; StepParse::StepParse(common_installer::InstallerContext* context, ConfigLocation config_location, @@ -182,9 +181,7 @@ std::string StepParse::GetPackageVersion( bool StepParse::FillInstallationInfo(manifest_x* manifest) { manifest->root_path = strdup( (context_->root_application_path.get() / manifest->package).c_str()); - manifest->installed_time = - strdup(std::to_string(sc::system_clock::to_time_t( - sc::system_clock::now())).c_str()); + manifest->installed_time = strdup(common_installer::GetCurrentTime().c_str()); return true; } -- 2.7.4 From 23590201874048fac5336c4062c631d2629dc44b Mon Sep 17 00:00:00 2001 From: ilho kim Date: Fri, 4 Aug 2023 13:17:27 +0900 Subject: [PATCH 13/16] Release version 0.15.32 Changes: - Fix static analysis issue Change-Id: I30a2dcd1b07b10b3f40afe012fbb4adc3bd51b40 Signed-off-by: ilho kim --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 8bd3e83..563323a 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.15.31 +Version: 0.15.32 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 083cf65383b8d6f5935679ff4d0e7293ffa15526 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 10 Aug 2023 14:30:20 +0900 Subject: [PATCH 14/16] Fix static analysis issue Check the return value of glob() Change-Id: I7f526ca453ccdde105d44193914833f0ec512868 Signed-off-by: ilho kim --- src/wgt/step/security/step_check_extension_privileges.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wgt/step/security/step_check_extension_privileges.cc b/src/wgt/step/security/step_check_extension_privileges.cc index 796022d..e40fc6b 100755 --- a/src/wgt/step/security/step_check_extension_privileges.cc +++ b/src/wgt/step/security/step_check_extension_privileges.cc @@ -56,11 +56,16 @@ common_installer::Step::Status StepCheckExtensionPrivileges::process() { std::set xmlFiles; { glob_t glob_result; - glob(app_ext_config_pattern.c_str(), GLOB_TILDE, NULL, &glob_result); - for (unsigned int i = 0; i < glob_result.gl_pathc; ++i) { - xmlFiles.insert(glob_result.gl_pathv[i]); + int ret = glob(app_ext_config_pattern.c_str(), + GLOB_TILDE, NULL, &glob_result); + if (ret == 0) { + for (unsigned int i = 0; i < glob_result.gl_pathc; ++i) { + xmlFiles.insert(glob_result.gl_pathv[i]); + } + globfree(&glob_result); + } else { + LOG(ERROR) << "Fail to get extension paths, error code : " << ret; } - globfree(&glob_result); } GList* privileges = nullptr; BOOST_SCOPE_EXIT_ALL(privileges) { -- 2.7.4 From 698d89be978169d7f659b6dcd7a61b0d33c604f3 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Fri, 11 Aug 2023 11:10:12 +0900 Subject: [PATCH 15/16] Release version 0.15.33 Changes: - Fix static analysis issue Change-Id: Ida3aaecd1dcc0206fc80ea31a9fcf23534011f43 Signed-off-by: ilho kim --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 563323a..ce4ab7a 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.15.32 +Version: 0.15.33 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 53b146f1502b64a31c098025eb3f54ea8f9e1574 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Fri, 20 Oct 2023 15:24:46 +0900 Subject: [PATCH 16/16] Remove code that may fall info infinite loop Change-Id: I8ebbac18e15ec68c0dc215ec619527b5aa93fbca Signed-off-by: ilho kim --- src/wgt/step/encryption/step_encrypt_resources.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wgt/step/encryption/step_encrypt_resources.cc b/src/wgt/step/encryption/step_encrypt_resources.cc index 40b6781..448d2f4 100644 --- a/src/wgt/step/encryption/step_encrypt_resources.cc +++ b/src/wgt/step/encryption/step_encrypt_resources.cc @@ -36,9 +36,9 @@ const std::set encryptSet { ".html", ".htm", ".css", ".js"}; FILE* OpenFile(const bf::path& path, const std::string& mode) { FILE* result = nullptr; - do { - result = fopen(path.c_str(), mode.c_str()); - } while ((nullptr == result)); + result = fopen(path.c_str(), mode.c_str()); + if (result == nullptr) + LOG(ERROR) << "open [" << path << "] fail, errno : " << errno; return result; } -- 2.7.4