From: Junghyun Yeon Date: Tue, 16 Jun 2020 09:50:32 +0000 (+0900) Subject: Implement recovery test for uninstallation X-Git-Tag: submit/tizen/20200706.085806~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=854a0adba3d4237c15a7ca2781f7f140192dac3c;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git Implement recovery test for uninstallation Recovery for uninstallation should be operated as normal uninstall. Change-Id: I6435b7a50a936948083a7248883158c24a8b0d49 Signed-off-by: Junghyun Yeon --- diff --git a/src/unit_tests/recovery_test.cc b/src/unit_tests/recovery_test.cc index f0db4f2..4d85fd7 100644 --- a/src/unit_tests/recovery_test.cc +++ b/src/unit_tests/recovery_test.cc @@ -23,6 +23,7 @@ namespace ci = common_installer; enum class ReqType : int { UNKNOWN_REQ, INSTALL_REQ, + UNINSTALL_REQ, UPDATE_REQ, DELTA_REQ, MOUNT_INSTALL_REQ, @@ -37,6 +38,8 @@ enum class BackupType : int { std::map install_req_filter = { { ReqType::INSTALL_REQ, "--gtest_filter=SmokeTest.RecoveryMode_Tpk_Installation" }, + { ReqType::UNINSTALL_REQ, + "--gtest_filter=SmokeTest.RecoveryMode_Tpk_Uninstallation" }, { ReqType::UPDATE_REQ, "--gtest_filter=SmokeTest.RecoveryMode_Tpk_Update" }, { ReqType::DELTA_REQ, @@ -165,6 +168,39 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) { ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); } +TEST_F(SmokeTest, RecoveryMode_Tpk_Uninstallation) { + RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid); + bf::path path = kSmokePackagesDirectory / "RecoveryPkg.tpk"; + + SmokeTestHelperRunner::Result ret = backend.InstallWithSubprocess( + path, params.test_user.uid); + if (ret != SmokeTestHelperRunner::Result::SUCCESS) { + std::cout << "failed to install package before uninstall" << std::endl; + return; + } + + std::string pkgid = "recoverypkg"; + int wait_time = delay + interval * test_count; + ret = backend.UninstallWithSubprocessAndKill( + pkgid, params.test_user.uid, wait_time); + if (ret == SmokeTestHelperRunner::Result::SUCCESS) { + std::cout << "uninstall finished before process killed" << std::endl; + return; + } + ASSERT_EQ(ret, SmokeTestHelperRunner::Result::KILLED); + + bf::path recovery_file = FindRecoveryFile("/tpk-recovery", + params.test_user.uid); + if (recovery_file.empty()) { + std::cout << "recovery file dosen't exist, " + "this test is skipped" << std::endl; + return; + } + ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file, params.test_user.uid), + SmokeTestHelperRunner::Result::SUCCESS); + ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); +} + TEST_F(SmokeTest, RecoveryMode_Tpk_Update) { RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid); @@ -336,6 +372,9 @@ int main(int argc, char** argv) { ("install", "recovery test for forced termination " "during package installing") + ("uninstall", + "recovery test for forced termination " + "during package uninstallation") ("update", "recovery test for forced termination " "during package updating") @@ -367,6 +406,8 @@ int main(int argc, char** argv) { if (opt_map.count("install")) req_type = ReqType::INSTALL_REQ; + if (opt_map.count("uninstall")) + req_type = ReqType::UNINSTALL_REQ; else if (opt_map.count("update")) req_type = ReqType::UPDATE_REQ; else if (opt_map.count("delta"))