Fix extensive smoke test 61/242261/4
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 25 Aug 2020 09:03:17 +0000 (18:03 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Thu, 3 Sep 2020 02:58:31 +0000 (11:58 +0900)
- Handle the cleanup recovery type
- Fix RecoveryMode_ForMountInstall.wgt package's appid correctly

Change-Id: I46d9d7dcdbddd9191ec1049b067a47141e786cdf
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
test/smoke_tests/extensive_smoke_test.cc
test/smoke_tests/smoke_test_helper.cc
test/smoke_tests/test_samples/smoke/RecoveryMode_ForMountInstall.wgt

index 4fc3275..444fbd9 100644 (file)
@@ -97,9 +97,17 @@ TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
       bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
                                                 params.test_user.uid);
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
+      std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
+          GetRecoverFileInfo(recovery_file);
       EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
           ci::AppInstaller::Result::OK);
-      EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
+      if (recovery_info->cleanup()) {
+        EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
+        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+            ci::AppInstaller::Result::OK);
+      } else {
+        EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
+      }
     }
     return true;
   }, params.pkg_type);
@@ -122,13 +130,24 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
       bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
                                                 params.test_user.uid);
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
+      std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
+          GetRecoverFileInfo(recovery_file);
       EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
           ci::AppInstaller::Result::OK);
       EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
 
+      std::string version = recovery_info->cleanup() ? "2\n" :"1\n";
       EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
-          "res/wgt/VERSION", "1\n", params));
+          "res/wgt/VERSION", version, params));
       EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
+
+      if (recovery_info->cleanup()) {
+        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.Install(path_old),
+            ci::AppInstaller::Result::OK);
+        AddDataFiles(pkgid, params.test_user.uid);
+      }
     }
     return true;
   }, params.pkg_type);
@@ -150,13 +169,24 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
       bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
                                                 params.test_user.uid);
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
+      std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
+          GetRecoverFileInfo(recovery_file);
       EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
           ci::AppInstaller::Result::OK);
       EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
+      std::string contents = recovery_info->cleanup() ? "2\n" : "1\n";
 
       EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
-          "res/wgt/VERSION", "1\n", params));
+          "res/wgt/VERSION", contents, params));
       EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
+
+      if (recovery_info->cleanup()) {
+        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.Install(path_old),
+            ci::AppInstaller::Result::OK);
+        AddDataFiles(pkgid, params.test_user.uid);
+      }
     }
     return true;
   }, params.pkg_type);
@@ -175,9 +205,18 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
       bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
                                                 params.test_user.uid);
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
+      std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
+          GetRecoverFileInfo(recovery_file);
       EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
           ci::AppInstaller::Result::OK);
-      EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
+      ScopedTzipInterface interface(pkgid, params.test_user.uid);
+      if (recovery_info->cleanup()) {
+        EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
+        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+            ci::AppInstaller::Result::OK);
+      } else {
+        EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
+      }
     }
     return true;
   }, params.pkg_type);
@@ -206,14 +245,25 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
       bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
                                                 params.test_user.uid);
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
+      std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
+          GetRecoverFileInfo(recovery_file);
       EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
           ci::AppInstaller::Result::OK);
 
       ScopedTzipInterface interface(pkgid, params.test_user.uid);
       EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
+      std::string version = recovery_info->cleanup() ? "2\n" : "1\n";
       EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(
-          pkgid, "res/wgt/VERSION", "1\n", params));
+          pkgid, "res/wgt/VERSION", version, params));
       EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
+      if (recovery_info->cleanup()) {
+        interface.Release();
+        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.MountInstall(path_old),
+            ci::AppInstaller::Result::OK);
+        AddDataFiles(pkgid, params.test_user.uid);
+      }
     }
     return true;
   }, params.pkg_type);
index 1bd7d80..a52afa2 100644 (file)
@@ -19,8 +19,14 @@ int main(int argc, char** argv) {
     std::string step_name;
     smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS;
 
+    if (!strcmp(argv[backend_argc - 1], "-type_clean")) {
+      backend_argc--;
+      type = smoke_test::CrashStepType::CLEAN;
+      LOG(DEBUG) << "step will be crashed in clean operation";
+    }
+
     if (!strcmp(argv[backend_argc - 2], "-idx")) {
-      index = atoi(argv[argc - 1]);
+      index = atoi(argv[backend_argc - 1]);
       backend_argc -= 2;
       LOG(DEBUG) << "Step crash after " << index << " step.";
     }
@@ -31,12 +37,6 @@ int main(int argc, char** argv) {
       LOG(DEBUG) << "Step crash after " << step_name << " step.";
     }
 
-    if (!strcmp(argv[backend_argc - 1], "-type_clean")) {
-      backend_argc--;
-      type = smoke_test::CrashStepType::CLEAN;
-      LOG(DEBUG) << "step will be crashed in clean operation";
-    }
-
     ci::PkgmgrInstaller pkgmgr_installer;
     wgt::WgtAppQueryInterface query_interface;
     auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv,
index 14c8562..7da0b98 100644 (file)
Binary files a/test/smoke_tests/test_samples/smoke/RecoveryMode_ForMountInstall.wgt and b/test/smoke_tests/test_samples/smoke/RecoveryMode_ForMountInstall.wgt differ