From: Sangyoon Jang Date: Tue, 19 Nov 2019 09:35:50 +0000 (+0900) Subject: Fix smoke-test functions for rollback cases X-Git-Tag: accepted/tizen/5.5/unified/20200105.221118~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=08d91e262044fd9ee82018db71b48373834317cb;p=platform%2Fcore%2Fappfw%2Fwgt-backend.git Fix smoke-test functions for rollback cases The custom step cannot be added outside of installer, because steps are initialized when Run() invoked. (If some step added outside of installer, that step will be executed at first, ignoring original steps) This patch defines a new virtual function creating overridden installer object which is fail at the end of steps or specific stage. Requires: - https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-installers/+/218093 Change-Id: I99de606909e5a673d45545dd05095ee0f4111a51 Signed-off-by: Sangyoon Jang --- diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index 817cdbc..14965f9 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -61,14 +61,26 @@ WgtBackendInterface::CreateInstaller(ci::PkgMgrPtr pkgmgr) const { return AppInstallerPtr(new wgt::WgtInstaller(pkgmgr)); } -WgtBackendInterface::AppQueryInterfacePtr +WgtBackendInterface::AppInstallerPtr +WgtBackendInterface::CreateFailExpectedInstaller( + ci::PkgMgrPtr pkgmgr, int fail_at) const { + return AppInstallerPtr(new FailExpectedWgtInstaller(pkgmgr, fail_at)); +} + +HybridBackendInterface::AppQueryInterfacePtr HybridBackendInterface::CreateQueryInterface() const { return AppQueryInterfacePtr(new wgt::WgtAppQueryInterface()); } -WgtBackendInterface::AppInstallerPtr +HybridBackendInterface::AppInstallerPtr HybridBackendInterface::CreateInstaller(ci::PkgMgrPtr pkgmgr) const { return AppInstallerPtr(new hybrid::HybridInstaller(pkgmgr)); } +HybridBackendInterface::AppInstallerPtr +HybridBackendInterface::CreateFailExpectedInstaller( + ci::PkgMgrPtr pkgmgr, int fail_at) const { + return AppInstallerPtr(new FailExpectedHybridInstaller(pkgmgr, fail_at)); +} + } // namespace smoke_test diff --git a/src/unit_tests/smoke_utils.h b/src/unit_tests/smoke_utils.h index e6ecbae..7b22263 100644 --- a/src/unit_tests/smoke_utils.h +++ b/src/unit_tests/smoke_utils.h @@ -5,14 +5,17 @@ #ifndef UNIT_TESTS_SMOKE_UTILS_H_ #define UNIT_TESTS_SMOKE_UTILS_H_ -#include #include +#include +#include #include #include #include #include +#include "hybrid/hybrid_installer.h" +#include "wgt/wgt_installer.h" #include "wgt/wgt_app_query_interface.h" namespace smoke_test { @@ -39,6 +42,8 @@ class WgtBackendInterface: public BackendInterface { AppQueryInterfacePtr CreateQueryInterface() const override; AppInstallerPtr CreateInstaller( common_installer::PkgMgrPtr pkgmgr) const override; + AppInstallerPtr CreateFailExpectedInstaller( + common_installer::PkgMgrPtr pkgmgr, int fail_at) const override; }; class HybridBackendInterface: public BackendInterface { @@ -49,6 +54,79 @@ class HybridBackendInterface: public BackendInterface { AppQueryInterfacePtr CreateQueryInterface() const override; AppInstallerPtr CreateInstaller( common_installer::PkgMgrPtr pkgmgr) const override; + AppInstallerPtr CreateFailExpectedInstaller( + common_installer::PkgMgrPtr pkgmgr, int fail_at) const override; +}; + +#define OVERRIDE_STEPS_BLOCK(TYPE, STEPS) \ + void STEPS() override { \ + TYPE::STEPS(); \ + if (fail_at_ > -1) \ + AddStepAtIndex(fail_at_); \ + else \ + AddStep(); \ + } \ + +class FailExpectedWgtInstaller : public wgt::WgtInstaller { + public: + explicit FailExpectedWgtInstaller( + common_installer::PkgMgrPtr pkgmgr, int fail_at) + : wgt::WgtInstaller(pkgmgr), fail_at_(fail_at) { } + + private: + 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 fail_at_; +}; + +class FailExpectedHybridInstaller : public hybrid::HybridInstaller { + public: + explicit FailExpectedHybridInstaller( + common_installer::PkgMgrPtr pkgmgr, int fail_at) + : hybrid::HybridInstaller(pkgmgr), fail_at_(fail_at) { } + + 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 fail_at_; }; } // namespace smoke_test