From: Sangyoon Jang Date: Fri, 13 Oct 2017 04:53:13 +0000 (+0900) Subject: Add smoke test for extended storage installation X-Git-Tag: submit/tizen/20171017.074628~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f66100a5974d7780264412403b33c8ca214cd850;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git Add smoke test for extended storage installation Change-Id: Ie9ba9a90256f284959de4c9076240948054a06e4 Signed-off-by: Sangyoon Jang --- diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 2de3b37..8536959 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -243,7 +243,8 @@ TEST_F(SmokeTest, InstallExternal_Tpk) { bf::path path = kSmokePackagesDirectory / "InstallExternal_Tpk.tpk"; std::string pkgid = "smokeapp29"; std::string appid = "smokeapp29.InstallExternalTpk"; - ASSERT_EQ(InstallExternal(path), ci::AppInstaller::Result::OK); + ASSERT_EQ(InstallWithStorage(path, StorageType::EXTERNAL), + ci::AppInstaller::Result::OK); ASSERT_TRUE(ValidateExternalPackage(pkgid, appid)); } @@ -594,6 +595,16 @@ TEST_F(PreloadSmokeTest, ReadonlyUpdateUninstallMode) { ValidatePackage(pkgid, {appid}, true); } +TEST_F(SmokeTest, InstallExtended_Tpk) { + ASSERT_TRUE(CheckAvailableExtendedStorage()); + bf::path path = kSmokePackagesDirectory / "InstallExtended_Tpk.tpk"; + std::string pkgid = "smoketpk45"; + std::string appid = "smoketpk45.InstallExtendedTpk"; + ASSERT_EQ(InstallWithStorage(path, StorageType::EXTENDED), + ci::AppInstaller::Result::OK); + ASSERT_TRUE(ValidateExtendedPackage(pkgid, appid)); +} + } // namespace common_installer int main(int argc, char** argv) { diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index 6decfdd..185f8fa 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -383,6 +383,22 @@ bool ValidateExternalPackage(const std::string& pkgid, return true; } +bool ValidateExtendedPackage(const std::string& pkgid, + const std::string& appid) { + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + std::string storage = pkg_query.StorageForPkgId(); + bf::path extended_path = + bf::path(ci::GetExtendedRootAppPath(kTestUserId)) / pkgid; + if (!bf::exists(extended_path)) { + LOG(INFO) << "Extended storage not exists!"; + EXTENDED_ASSERT_EQ(storage, "installed_internal"); + } else { + EXTENDED_ASSERT_EQ(storage, "installed_extended"); + } + EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, appid)); + return true; +} + bool CheckPackageNonExistance(const std::string& pkgid, const std::string& appid, bool is_readonly) { @@ -525,12 +541,36 @@ bool CheckAvailableExternalPath() { return true; } -ci::AppInstaller::Result InstallExternal(const bf::path& path, - RequestResult mode) { +bool CheckAvailableExtendedStorage() { + bf::path extended_path = bf::path(tzplatform_getenv(TZ_SYS_EXTENDEDSD)); + LOG(DEBUG) << "extended_path :" << extended_path; + // TODO(jeremy.jang): It should be checked by libstorage API. + if (!bf::exists(extended_path)) { + LOG(ERROR) << "Extended storage not exists!"; + return false; + } + return true; +} + +ci::AppInstaller::Result InstallWithStorage(const bf::path& path, + StorageType type, + RequestResult mode) { int default_storage = 0; + int storage = 0; + switch (type) { + case StorageType::EXTERNAL: + storage = 1; + break; + case StorageType::EXTENDED: + storage = 2; + break; + default: + LOG(ERROR) << "Unknown storage type"; + break; + } vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, &default_storage); - vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, 1); + vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, storage); const char* argv[] = {"", "-i", path.c_str(), "-u", kTestUserIdStr.c_str()}; ci::AppInstaller::Result result = CallBackend(SIZEOFARRAY(argv), argv, mode); @@ -544,7 +584,8 @@ ci::AppInstaller::Result MigrateLegacyExternalImage(const std::string& pkgid, const bf::path& path, const bf::path& legacy_path, RequestResult mode) { - if (InstallExternal(path) != ci::AppInstaller::Result::OK) { + if (InstallWithStorage(path, StorageType::EXTERNAL) != + ci::AppInstaller::Result::OK) { LOG(ERROR) << "Failed to install application. Cannot perform Migrate"; return ci::AppInstaller::Result::ERROR; } diff --git a/src/unit_tests/smoke_utils.h b/src/unit_tests/smoke_utils.h index 3b671c8..20f472f 100644 --- a/src/unit_tests/smoke_utils.h +++ b/src/unit_tests/smoke_utils.h @@ -124,6 +124,12 @@ class TestPkgmgrInstaller : public ci::PkgmgrInstallerInterface { } }; +enum class StorageType { + INTERNAL, + EXTERNAL, + EXTENDED +}; + ci::RequestMode ParseRequestMode(int argc, char** argv); bool AddTestUser(const char *user_name); @@ -158,12 +164,17 @@ bool ValidateExternalPackage_FS(const std::string& pkgid, bool ValidateExternalPackage(const std::string& pkgid, const std::string& appid); +bool ValidateExtendedPackage(const std::string& pkgid, + const std::string& appid); + bool CheckPackageNonExistance(const std::string& pkgid, const std::string& appid, bool is_readonly = false); bool CheckAvailableExternalPath(); +bool CheckAvailableExtendedStorage(); + std::unique_ptr CreateQueryInterface(); std::unique_ptr CreateInstaller(ci::PkgMgrPtr pkgmgr); @@ -186,8 +197,8 @@ ci::AppInstaller::Result Install(const bf::path& path, ci::AppInstaller::Result InstallPreload(const bf::path& path, RequestResult mode = RequestResult::NORMAL); - -ci::AppInstaller::Result InstallExternal(const bf::path& path, +ci::AppInstaller::Result InstallWithStorage(const bf::path& path, + StorageType type = StorageType::INTERNAL, RequestResult mode = RequestResult::NORMAL); ci::AppInstaller::Result MigrateLegacyExternalImage(const std::string& pkgid, diff --git a/src/unit_tests/test_samples/smoke/InstallExtended_Tpk.tpk b/src/unit_tests/test_samples/smoke/InstallExtended_Tpk.tpk new file mode 100644 index 0000000..a06bb03 Binary files /dev/null and b/src/unit_tests/test_samples/smoke/InstallExtended_Tpk.tpk differ