Fix extensive smoke test 14/236814/6
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 22 Jun 2020 08:36:18 +0000 (17:36 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Thu, 3 Sep 2020 03:03:47 +0000 (12:03 +0900)
- Handle the cleanup recovery type

Change-Id: Ife8675b5509610e18431784c7a73319275a7a334
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
test/smoke_tests/extensive_smoke_test.cc
test/smoke_tests/smoke_test_helper.cc

index 7d052ec8605b13b640992bd7105cb722762bf1c4..559aa92abb1ed057706ea27cd6128ea506793a22 100644 (file)
@@ -131,6 +131,8 @@ TEST_F(SmokeTest, DeltaMode_Tpk_Rollback) {
 TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) {
   bf::path path = kSmokePackagesDirectory / "RecoveryMode_Tpk_Installation.tpk";
   std::string pkgid = "smokeapp15";
+  std::string appid = "smokeapp15.RecoveryModeTpkInstallation";
+  std::string exec = "native";
   RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
 
   std::string test_uid_str = std::to_string(params.test_user.uid);
@@ -141,9 +143,17 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) {
       bf::path recovery_file = FindRecoveryFile("/tpk-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, exec}, params));
+        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+            ci::AppInstaller::Result::OK);
+      } else {
+        EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
+      }
     }
     return true;
   }, params.pkg_type);
@@ -167,12 +177,20 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Update) {
       bf::path recovery_file = FindRecoveryFile("/tpk-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, exec}, params));
-
+      std::string version = recovery_info->cleanup() ? "2" : "1";
       EXTENDED_ASSERT_TRUE(
-          ValidateFileContentInPackage(pkgid, "VERSION", "1\n", params));
+          ValidateFileContentInPackage(pkgid, "res/VERSION", version, params));
+      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);
+      }
     }
     return true;
   }, params.pkg_type);
@@ -310,17 +328,30 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
       bf::path recovery_file = FindRecoveryFile("/tpk-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, exec}, params));
-
+      std::string contents = recovery_info->cleanup() ?
+          "version 2" : "version 1";
       EXTENDED_ASSERT_TRUE(
-          ValidateFileContentInPackage(pkgid, "res/MODIFIED", "version 1",
+          ValidateFileContentInPackage(pkgid, "res/MODIFIED", contents,
               params));
       bf::path root_path = ci::GetRootAppPath(params.is_readonly,
           params.test_user.uid);
-      EXTENDED_ASSERT_TRUE(bf::exists(root_path / pkgid / "res/DELETED"));
-      EXTENDED_ASSERT_FALSE(bf::exists(root_path / pkgid / "res/ADDED"));
+
+      if (recovery_info->cleanup()) {
+        EXTENDED_ASSERT_FALSE(bf::exists(root_path / pkgid / "res/DELETED"));
+        EXTENDED_ASSERT_TRUE(bf::exists(root_path / pkgid / "res/ADDED"));
+        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+            ci::AppInstaller::Result::OK);
+        EXTENDED_ASSERT_EQ(backend.Install(path_old),
+            ci::AppInstaller::Result::OK);
+      } else {
+        EXTENDED_ASSERT_TRUE(bf::exists(root_path / pkgid / "res/DELETED"));
+        EXTENDED_ASSERT_FALSE(bf::exists(root_path / pkgid / "res/ADDED"));
+      }
     }
     return true;
   }, params.pkg_type);
@@ -347,6 +378,9 @@ TEST_F(SmokeTest, UpdateMode_Rollback) {
 
 TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
   bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForMountInstall.tpk";
+  std::string pkgid = "smoketpk37";
+  std::string appid = "smoketpk37.RecoveryMode_ForMountInstall";
+  std::string exec = "smoketpk37";
   RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
 
   std::string test_uid_str = std::to_string(params.test_user.uid);
@@ -354,14 +388,21 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
       {"", "-w", path.string(), "-u", test_uid_str.c_str()};
   backend.CrashAfterEachStep(&args, [&](int step) -> bool {
     if (step >= 2) {
-      std::string pkgid = "smoketpk37";
-      std::string appid = "smoketpk37.RecoveryMode_ForMountInstall";
       bf::path recovery_file = FindRecoveryFile("/tpk-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, exec}, params));
+        EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+            ci::AppInstaller::Result::OK);
+      } else {
+        EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
+      }
     }
     return true;
   }, params.pkg_type);
@@ -392,13 +433,23 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
       bf::path recovery_file = FindRecoveryFile("/tpk-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, exec}, params));
+      std::string version = recovery_info->cleanup() ? "2" : "1";
 
       EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
-        "res/VERSION", "1", params));
+        "res/VERSION", version, params));
+      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);
+      }
     }
     return true;
   }, params.pkg_type);
index dc3fc75fe65f42744a8259503520d1583e5de751..626281d90707501f77f541aab3daab7363418a11 100644 (file)
@@ -44,6 +44,12 @@ int main(const int argc, char* argv[]) {
     bool remove_plugins = false;
     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[backend_argc-1]);
        backend_argc -= 2;
@@ -62,12 +68,6 @@ int main(const int argc, char* argv[]) {
       LOG(DEBUG) << "Remove parser plugins steps";
     }
 
-    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;
     tpk::TpkAppQueryInterface interface;
     ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv,