From ab5be800980cda31ac46b18e9337101b430d56bf Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 5 Jul 2022 21:37:53 +0900 Subject: [PATCH 01/16] Implement undo RemovePerUserStorageDirectories If the uninstallation is failed after this step, there is a problem that the user directory remains erased so recreate the user directories removed by this step Change-Id: Ib776b43fd7d9e313c1bb1d3251a9a89cce6e27f8 Signed-off-by: Ilho Kim --- src/hybrid/hybrid_installer.cc | 7 +++++++ src/wgt/wgt_installer.cc | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 37ac600..fd9b5a8 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -124,6 +125,9 @@ void HybridInstaller::UpdateSteps() { void HybridInstaller::UninstallSteps() { AppInstaller::UninstallSteps(); + ReplaceStep( + "RemovePerUserStorageDirectories", + wgt::filesystem::HybridAdditionalSharedDirs); AddStepAfter( "RemovePerUserStorageDirectories"); } @@ -348,6 +352,9 @@ void HybridInstaller::ManifestPartialUpdateSteps() { void HybridInstaller::PartialUninstallSteps() { AppInstaller::PartialUninstallSteps(); + ReplaceStep( + "RemovePerUserStorageDirectories", + wgt::filesystem::HybridAdditionalSharedDirs); AddStepAfter( "RemovePerUserStorageDirectories"); } diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 5b023ae..30997b7 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -115,6 +116,9 @@ void WgtInstaller::UpdateSteps() { void WgtInstaller::UninstallSteps() { AppInstaller::UninstallSteps(); + ReplaceStep( + "RemovePerUserStorageDirectories", + wgt::filesystem::WgtAdditionalSharedDirs); AddStepAfter( "RemovePerUserStorageDirectories"); } @@ -354,6 +358,9 @@ void WgtInstaller::ManifestPartialUpdateSteps() { void WgtInstaller::PartialUninstallSteps() { AppInstaller::PartialUninstallSteps(); + ReplaceStep( + "RemovePerUserStorageDirectories", + wgt::filesystem::WgtAdditionalSharedDirs); AddStepAfter( "RemovePerUserStorageDirectories"); } -- 2.7.4 From e73ffadb5d3e4c99b3437a23d387666f9e759dab Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 8 Jul 2022 20:20:42 +0900 Subject: [PATCH 02/16] Implement StepRestoreWgtSymbolicLink If the uninstallation fails with the bin path removed recover the wgt symbolic link Change-Id: If1a4fd95be319fded67bd778f21e9abd2fae512a Signed-off-by: Ilho Kim --- src/hybrid/hybrid_installer.cc | 5 ++++ .../filesystem/step_restore_wgt_symbolic_link.cc | 34 ++++++++++++++++++++++ .../filesystem/step_restore_wgt_symbolic_link.h | 34 ++++++++++++++++++++++ src/wgt/wgt_installer.cc | 5 ++++ 4 files changed, 78 insertions(+) create mode 100644 src/wgt/step/filesystem/step_restore_wgt_symbolic_link.cc create mode 100644 src/wgt/step/filesystem/step_restore_wgt_symbolic_link.h diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index fd9b5a8..df7495b 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -33,6 +33,7 @@ #include "wgt/step/encryption/step_remove_encryption_data.h" #include "wgt/step/filesystem/step_copy_preview_icons.h" #include "wgt/step/filesystem/step_create_wgt_symbolic_link.h" +#include "wgt/step/filesystem/step_restore_wgt_symbolic_link.h" #include "wgt/step/filesystem/step_wgt_patch_icons.h" #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h" #include "wgt/step/filesystem/step_wgt_undo_patch_storage_directories.h" @@ -128,6 +129,8 @@ void HybridInstaller::UninstallSteps() { ReplaceStep( "RemovePerUserStorageDirectories", wgt::filesystem::HybridAdditionalSharedDirs); + AddStepAfter( + "RemovePerUserStorageDirectories"); AddStepAfter( "RemovePerUserStorageDirectories"); } @@ -355,6 +358,8 @@ void HybridInstaller::PartialUninstallSteps() { ReplaceStep( "RemovePerUserStorageDirectories", wgt::filesystem::HybridAdditionalSharedDirs); + AddStepAfter( + "RemovePerUserStorageDirectories"); AddStepAfter( "RemovePerUserStorageDirectories"); } diff --git a/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.cc b/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.cc new file mode 100644 index 0000000..0cc2e5e --- /dev/null +++ b/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by a apache 2.0 license that can be +// found in the LICENSE file. + +#include "wgt/step/filesystem/step_restore_wgt_symbolic_link.h" + +#include "wgt/step/filesystem/step_create_wgt_symbolic_link.h" + +namespace bf = boost::filesystem; +namespace bs = boost::system; + +namespace wgt { +namespace filesystem { + +common_installer::Step::Status StepRestoreWgtSymbolicLink::undo() { + StepCreateWgtSymbolicLink step(context_); + + Status result = step.precheck(); + if (result != Status::OK) { + LOG(ERROR) << "Fail to execute precheck of CreateWgtSymbolicLink"; + return result; + } + + result = step.process(); + if (result != Status::OK) { + LOG(ERROR) << "Fail to execute process of CreateWgtSymbolicLink"; + return result; + } + + return result; +} + +} // namespace filesystem +} // namespace wgt diff --git a/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.h b/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.h new file mode 100644 index 0000000..f0f141e --- /dev/null +++ b/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.h @@ -0,0 +1,34 @@ +// Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by a apache 2.0 license that can be +// found in the LICENSE file. + +#ifndef WGT_STEP_FILESYSTEM_STEP_RESTORE_WGT_SYMBOLIC_LINK_H_ +#define WGT_STEP_FILESYSTEM_STEP_RESTORE_WGT_SYMBOLIC_LINK_H_ + +#include + +#include +#include + +namespace wgt { +namespace filesystem { + +/** + * \brief Step that create symbolic link to application + */ +class StepRestoreWgtSymbolicLink : public common_installer::Step { + public: + using Step::Step; + + Status precheck() override { return Status::OK; } + Status process() override { return Status::OK; } + Status clean() override { return Status::OK; } + Status undo() override; + + STEP_NAME(RestoreWgtSymbolicLink) +}; + +} // namespace filesystem +} // namespace wgt + +#endif // WGT_STEP_FILESYSTEM_STEP_RESTORE_WGT_SYMBOLIC_LINK_H_ diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 30997b7..d79b585 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -26,6 +26,7 @@ #include "wgt/step/encryption/step_remove_encryption_data.h" #include "wgt/step/filesystem/step_copy_preview_icons.h" #include "wgt/step/filesystem/step_create_wgt_symbolic_link.h" +#include "wgt/step/filesystem/step_restore_wgt_symbolic_link.h" #include "wgt/step/filesystem/step_wgt_patch_icons.h" #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h" #include "wgt/step/filesystem/step_wgt_prepare_package_directory.h" @@ -119,6 +120,8 @@ void WgtInstaller::UninstallSteps() { ReplaceStep( "RemovePerUserStorageDirectories", wgt::filesystem::WgtAdditionalSharedDirs); + AddStepAfter( + "RemovePerUserStorageDirectories"); AddStepAfter( "RemovePerUserStorageDirectories"); } @@ -361,6 +364,8 @@ void WgtInstaller::PartialUninstallSteps() { ReplaceStep( "RemovePerUserStorageDirectories", wgt::filesystem::WgtAdditionalSharedDirs); + AddStepAfter( + "RemovePerUserStorageDirectories"); AddStepAfter( "RemovePerUserStorageDirectories"); } -- 2.7.4 From ae4a97529841338c3b0905f67551bf751a3e46a1 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Wed, 24 Aug 2022 17:57:37 +0900 Subject: [PATCH 03/16] Release version 0.15.25 Changes: - Implement undo RemovePerUserStorageDirectories - Implement StepRestoreWgtSymbolicLink Change-Id: Ib329dfca791c3b196297ef9cec2cb81bf57588d5 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 f34bd29..9b46696 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.24 +Version: 0.15.25 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 9f899c0fa84e44fcabe06c15765efc4b759557f9 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 13 Sep 2022 11:22:43 +0900 Subject: [PATCH 04/16] Try to remove the location of the extract entry Because MountInstall is performed when there is no manifest a file may exist in the extract entry path, so remove that Related: [app-installers]https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-installers/+/281054/ Change-Id: I26e93e345779df832b421758f99d9600aa5bde3a Signed-off-by: Ilho Kim --- src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 4e90b29..2439ded 100644 --- a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc @@ -88,9 +88,12 @@ ci::Step::Status StepWgtPreparePackageDirectory::ExtractEntries() { } for (auto& entry : GetExtractEntries()) { - if (context_->request_type.get() == ci::RequestType::MountUpdate) + 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; + } if (!ci::ExtractToTmpDir(context_->file_path.get().c_str(), resource_path.c_str(), entry)) { -- 2.7.4 From dfdea00641995df48a972299dbeb60ba272917b7 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Wed, 14 Sep 2022 16:21:57 +0900 Subject: [PATCH 05/16] Release version 0.15.26 Changes: - Try to remove the location of the extract entry Change-Id: I8dfffbe625810b379ed27b5142829464e4ea382c 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 9b46696..3c568f7 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.25 +Version: 0.15.26 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 4010df0327593e18531f921bc0f23675124a5db4 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 19 Sep 2022 17:14:43 +0900 Subject: [PATCH 06/16] Fix static analysis issue Change-Id: I010cb0d5dd7f41c56f10db975db72b53e8b8c84d Signed-off-by: Sangyoon Jang --- src/wgt/utils/extension_config_parser.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wgt/utils/extension_config_parser.cc b/src/wgt/utils/extension_config_parser.cc index 684c292..93d0abf 100644 --- a/src/wgt/utils/extension_config_parser.cc +++ b/src/wgt/utils/extension_config_parser.cc @@ -38,6 +38,11 @@ std::unique_ptr return nullptr; } root_node = xmlDocGetRootElement(doc); + if (!root_node) { + LOG(ERROR) << "Failed to get root element from " << config_xml; + xmlFreeDoc(doc); + return nullptr; + } std::unique_ptr dv = LoadXMLNode(root_node); std::unique_ptr result(new parser::DictionaryValue); if (dv) -- 2.7.4 From 99de35b457fad1e5d99424b6c1fa20ae7f05700e Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 20 Sep 2022 15:08:19 +0900 Subject: [PATCH 07/16] Release version 0.15.27 Changes: - Fix static analysis issue Change-Id: I8b5da545471ce0856de6d6aef1f19740797b2cb8 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 3c568f7..3147cd7 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.26 +Version: 0.15.27 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 2f69ae753aa94a29658d6ca28859dd4cb9b697dd Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Thu, 22 Sep 2022 14:13:39 +0900 Subject: [PATCH 08/16] Fix static analysis issue - Null pointer dereference Change-Id: Ie3dda3872cf472d9c3a76a4b1f7738d6725bb5c6 Signed-off-by: Ilho Kim --- src/hybrid/step/pkgmgr/step_merge_xml.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hybrid/step/pkgmgr/step_merge_xml.cc b/src/hybrid/step/pkgmgr/step_merge_xml.cc index 8b6fbb3..4a3cd7d 100644 --- a/src/hybrid/step/pkgmgr/step_merge_xml.cc +++ b/src/hybrid/step/pkgmgr/step_merge_xml.cc @@ -98,6 +98,10 @@ xmlNodePtr StepMergeXml::GetXmlNode(const xmlDocPtr doc, void StepMergeXml::MergeXmlNode(xmlNodePtr node1, xmlNodePtr node2) { xmlNodePtr last = xmlGetLastChild(node1); + if (!last) { + LOG(ERROR) << "Failed to get last child node"; + return; + } xmlNodePtr next; // merge node2's child into node1 for (xmlNodePtr cur = node2->children; cur; cur = next) { -- 2.7.4 From 117a7d9d257bf3aa238afacace19e044870a1607 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Thu, 22 Sep 2022 15:29:18 +0900 Subject: [PATCH 09/16] Release version 0.15.28 Changes: - Fix static analysis issue Change-Id: I1799ced2e7db107e670bff1154b3a4bab5dddc5e 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 3147cd7..7ab44d9 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.27 +Version: 0.15.28 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From ca549614e741b7a3f3d1c95b7b075269f61bb325 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 5 Jan 2023 16:22:59 +0900 Subject: [PATCH 10/16] Give an exec label,capability to the smoke test tool The installer is executed with System::Privileged label and mac_override Give an exec label and capability so that the smoke test tool is executed with the same label Change-Id: I6e756f231c7b93c21b884ca944ead46d324cf83f Signed-off-by: ilho kim --- packaging/wgt-backend.spec | 5 +++-- packaging/wgt-installer-tests.manifest | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 7ab44d9..958c74b 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -73,8 +73,9 @@ mkdir -p %{buildroot}/etc/package-manager/backend ln -s %{_bindir}/wgt-backend %{buildroot}%{_sysconfdir}/package-manager/backend/wgt %post -n wgt-installer-tests -/usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner=eip %{_bindir}/wgt-installer-ut/smoke-test -/usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner=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/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/extensive-smoke-test %files %manifest wgt-backend.manifest diff --git a/packaging/wgt-installer-tests.manifest b/packaging/wgt-installer-tests.manifest index f5159f3..e0632fd 100644 --- a/packaging/wgt-installer-tests.manifest +++ b/packaging/wgt-installer-tests.manifest @@ -3,8 +3,8 @@ - - - + + + -- 2.7.4 From a0d957f2eaecaabc56f878f8b7d0af01c0ecb273 Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 5 Jan 2023 16:39:51 +0900 Subject: [PATCH 11/16] Fix ManifestDirectUpdate test If the update is performed quickly The installed time may be the same sleep 1 second before ManifestDirectUpdate Change-Id: Idea086d66cb7627975d623ecf66c8deeaf0bd05d Signed-off-by: ilho kim --- test/smoke_tests/smoke_test.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/smoke_tests/smoke_test.cc b/test/smoke_tests/smoke_test.cc index 53377a8..4f81d90 100644 --- a/test/smoke_tests/smoke_test.cc +++ b/test/smoke_tests/smoke_test.cc @@ -720,11 +720,12 @@ TEST_F(SmokeTest, ManifestDirectUpdateMode) { ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK); int install_time = GetAppInstalledTime(appid.c_str(), params.test_user.uid); + sleep(1); ASSERT_EQ(backend.ManifestDirectInstall(pkgid), ci::AppInstaller::Result::OK); - ASSERT_TRUE(GetAppInstalledTime(appid.c_str(), - params.test_user.uid) > install_time) - << "Package is not updated (app installed time didn't change)."; + ASSERT_GT( + GetAppInstalledTime(appid.c_str(), params.test_user.uid), install_time) + << "Package is not updated (app installed time didn't change)."; ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); } @@ -778,10 +779,11 @@ TEST_F(HybridSmokeTest, ManifestDirectUpdateMode) { ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK); int install_time = GetAppInstalledTime(appid.c_str(), params.test_user.uid); + sleep(1); ASSERT_EQ(backend.ManifestDirectInstall(pkgid), ci::AppInstaller::Result::OK); - ASSERT_TRUE(GetAppInstalledTime(appid.c_str(), - params.test_user.uid) > install_time) - << "Package is not updated (app installed time didn't change)."; + ASSERT_GT( + GetAppInstalledTime(appid.c_str(), params.test_user.uid), install_time) + << "Package is not updated (app installed time didn't change)."; ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params)); } -- 2.7.4 From 234b2afd450c369d0b21aaa014c706a47802148f Mon Sep 17 00:00:00 2001 From: ilho kim Date: Thu, 5 Jan 2023 18:26:45 +0900 Subject: [PATCH 12/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 13/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 14/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 15/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 16/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