From d372a85c569cba6384e8dcebbc21df80bdda939a Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Tue, 16 Feb 2016 10:18:31 +0100 Subject: [PATCH] Adjust to change in PkgmgrInterface Following changes need to be submitted together: - https://review.tizen.org/gerrit/59442 - https://review.tizen.org/gerrit/59443 - https://review.tizen.org/gerrit/59444 To verify: $ /usr/bin/wgt-backend-ut/smoke_test # install, update, uninstall and wgt package by wgt-backend directly Change-Id: I89c72f9be7d6695d629c6e9d292c4f8e82a7d138 --- src/unit_tests/smoke_test.cc | 36 ++++++++++++++++++++++++++++++++---- src/wgt_backend/wgt_backend.cc | 4 +++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index f23d98b..39d8dd7 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -48,6 +48,22 @@ enum class RequestResult { CRASH }; +class TestPkgmgrInstaller : public ci::PkgmgrInstallerInterface { + public: + bool CreatePkgMgrInstaller(pkgmgr_installer** installer, + ci::InstallationMode* mode) { + *installer = pkgmgr_installer_new(); + if (!*installer) + return false; + *mode = ci::InstallationMode::ONLINE; + return true; + } + + bool ShouldCreateSignal() const { + return false; + } +}; + class StepCrash : public ci::Step { public: using Step::Step; @@ -209,11 +225,12 @@ ci::AppInstaller::Result RunInstallerWithPkgrmgr(ci::PkgMgrPtr pkgmgr, ci::AppInstaller::Result Install(const bf::path& path, RequestResult mode = RequestResult::NORMAL) { const char* argv[] = {"", "-i", path.c_str()}; + TestPkgmgrInstaller pkgmgr_installer; std::unique_ptr query_interface = CreateQueryInterface(); auto pkgmgr = ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast(argv), - query_interface.get()); + &pkgmgr_installer, query_interface.get()); if (!pkgmgr) { LOG(ERROR) << "Failed to initialize pkgmgr interface"; return ci::AppInstaller::Result::UNKNOWN; @@ -234,11 +251,12 @@ ci::AppInstaller::Result Update(const bf::path& path_old, ci::AppInstaller::Result Uninstall(const std::string& pkgid, RequestResult mode = RequestResult::NORMAL) { const char* argv[] = {"", "-d", pkgid.c_str()}; + TestPkgmgrInstaller pkgmgr_installer; std::unique_ptr query_interface = CreateQueryInterface(); auto pkgmgr = ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast(argv), - query_interface.get()); + &pkgmgr_installer, query_interface.get()); if (!pkgmgr) { LOG(ERROR) << "Failed to initialize pkgmgr interface"; return ci::AppInstaller::Result::UNKNOWN; @@ -254,11 +272,12 @@ ci::AppInstaller::Result Reinstall(const bf::path& path, return ci::AppInstaller::Result::UNKNOWN; } const char* argv[] = {"", "-r", delta_dir.c_str()}; + TestPkgmgrInstaller pkgmgr_installer; std::unique_ptr query_interface = CreateQueryInterface(); auto pkgmgr = ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast(argv), - query_interface.get()); + &pkgmgr_installer, query_interface.get()); if (!pkgmgr) { LOG(ERROR) << "Failed to initialize pkgmgr interface"; return ci::AppInstaller::Result::UNKNOWN; @@ -278,11 +297,12 @@ ci::AppInstaller::Result DeltaInstall(const bf::path& path, ci::AppInstaller::Result Recover(const bf::path& recovery_file, RequestResult mode = RequestResult::NORMAL) { const char* argv[] = {"", "-b", recovery_file.c_str()}; + TestPkgmgrInstaller pkgmgr_installer; std::unique_ptr query_interface = CreateQueryInterface(); auto pkgmgr = ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast(argv), - query_interface.get()); + &pkgmgr_installer, query_interface.get()); if (!pkgmgr) { LOG(ERROR) << "Failed to initialize pkgmgr interface"; return ci::AppInstaller::Result::UNKNOWN; @@ -304,10 +324,18 @@ class SmokeEnvironment : public testing::Environment { bf::remove_all(home_ / KUserAppsDirBackup, error); if (bf::exists(home_ / KUserAppsDir)) { bf::rename(home_ / KUserAppsDir, home_ / KUserAppsDirBackup, error); + if (error) + LOG(ERROR) << "Failed to setup test environment. Does some previous" + << " test crashed? Directory: " + << (home_ / KUserAppsDirBackup) << " should not exist."; assert(!error); } if (bf::exists(home_ / kApplicationDir)) { bf::rename(home_ / kApplicationDir, home_ / kApplicationDirBackup, error); + if (error) + LOG(ERROR) << "Failed to setup test environment. Does some previous" + << " test crashed? Directory: " + << (home_ / kApplicationDirBackup) << " should not exist."; assert(!error); } } diff --git a/src/wgt_backend/wgt_backend.cc b/src/wgt_backend/wgt_backend.cc index 3d59c2e..14639c6 100644 --- a/src/wgt_backend/wgt_backend.cc +++ b/src/wgt_backend/wgt_backend.cc @@ -13,8 +13,10 @@ namespace ci = common_installer; int main(int argc, char** argv) { + ci::PkgmgrInstaller pkgmgr_installer; wgt::WgtAppQueryInterface query_interface; - auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &query_interface); + auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer, + &query_interface); if (!pkgmgr) { LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; return EINVAL; -- 2.7.4