Fix recovery test when recovery file doesn't exist 97/219197/3
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 3 Dec 2019 05:21:09 +0000 (14:21 +0900)
committerilho kim <ilho159.kim@samsung.com>
Thu, 12 Dec 2019 23:28:15 +0000 (23:28 +0000)
If installer is terminated before creating the recovery file
The test should be skipped, not failed

Change-Id: I9df1d77f2848c5e975596b7d4085700f41a0d6d3
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/unit_tests/recovery_test.cc

index 4f053452d809d4f9f5bc2d2448484a64895fd0bf..b8647beb1fcc5eaff3029d5230232dd5e57afc10 100644 (file)
@@ -125,8 +125,12 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) {
     std::string pkgid = "recoverypkg";
     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_FALSE(recovery_file.empty());
     ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
     ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
   } else {
@@ -153,8 +157,12 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Update) {
     std::string exec = "recoverypkg";
     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_FALSE(recovery_file.empty());
     std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
         GetRecoverFileInfo(recovery_file);
     ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
@@ -187,8 +195,12 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
         params.test_user.uid);
     bf::path root_path = ci::GetRootAppPath(params.is_readonly,
                                             params.test_user.uid);
+    if (recovery_file.empty()) {
+      std::cout << "recovery file dosen't exist, "
+                   "this test is skipped" << std::endl;
+      return;
+    }
 
-    ASSERT_FALSE(recovery_file.empty());
     std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
         GetRecoverFileInfo(recovery_file);
     ASSERT_EQ(ci::AppInstaller::Result::OK, backend.Recover(recovery_file));
@@ -219,8 +231,12 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
     std::string pkgid = "recoverypkg";
     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_FALSE(recovery_file.empty());
     ASSERT_EQ(ci::AppInstaller::Result::OK, backend.Recover(recovery_file));
     ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
   } else {
@@ -249,12 +265,16 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
     std::string exec = "recoverypkg";
     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;
+    }
 
     // Filesystem may be mounted after crash
     ScopedTzipInterface poweroff_unmount_interface(pkgid, params.test_user.uid);
     poweroff_unmount_interface.Release();
 
-    ASSERT_FALSE(recovery_file.empty());
     ASSERT_EQ(ci::AppInstaller::Result::OK, backend.Recover(recovery_file));
     ScopedTzipInterface interface(pkgid, params.test_user.uid);
     ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));