Implement recovery test for uninstallation 44/236344/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 16 Jun 2020 09:50:32 +0000 (18:50 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 16 Jun 2020 09:50:32 +0000 (18:50 +0900)
Recovery for uninstallation should be operated as normal uninstall.

Change-Id: I6435b7a50a936948083a7248883158c24a8b0d49
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/unit_tests/recovery_test.cc

index f0db4f25522abbf3e300449f2855214c51e32e16..4d85fd7b078d1cd72e505ccb85896c42f9cba34c 100644 (file)
@@ -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<ReqType, std::string> 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"))