Merge SmokeTestHelperRunner into BackendInterface 71/283271/1
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 21 Oct 2022 07:09:00 +0000 (16:09 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Fri, 21 Oct 2022 07:18:58 +0000 (16:18 +0900)
Related change:
  [app-installers] https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-installers/+/283265/

Change-Id: Ie5ba408d92859463deafb037407aabf3c53c6fa5
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
test/smoke_test/smoke_utils.cc
test/smoke_test/smoke_utils.h
test/smoke_test/unified_recovery_test.cc

index c871d405a9db7ec9e3f88106fbc1c290bbfdcec8..301911e4acd45de2dda3f158ef4db3b3dc4941b1 100644 (file)
@@ -152,6 +152,11 @@ UnifiedBackendInterface::CreateFailExpectedInstaller(
   return factory_->CreateFailExpectedInstaller(0, pkgmgr, fail_at);
 }
 
+common_installer::Subprocess UnifiedBackendInterface::CreateSubprocess() const {
+  return common_installer::Subprocess(
+      "/usr/bin/unified-installer-ut/smoke-test-helper");
+}
+
 UnifiedRecoveryInfo::UnifiedRecoveryInfo(bf::path path) : path_(path) {
 }
 
index 4a18f9cbe8f8c26ea95e9057ca253eff328cb50e..bfdbc257e9d17c34071f92b763e7ae115d8a09ff 100644 (file)
@@ -36,14 +36,7 @@ class UnifiedBackendInterface : public BackendInterface {
       common_installer::PkgMgrPtr pkgmgr) const override;
   AppInstallerPtr CreateFailExpectedInstaller(
       common_installer::PkgMgrPtr pkgmgr, int fail_at) const override;
-};
-
-class UnifiedSmokeTestHelperRunner : public SmokeTestHelperRunner {
- private:
-  common_installer::Subprocess CreateSubprocess() const {
-    return common_installer::Subprocess(
-        "/usr/bin/unified-installer-ut/smoke-test-helper");
-  }
+  common_installer::Subprocess CreateSubprocess() const override;
 };
 
 class UnifiedRecoveryInfo {
index c044c6617b387b2eb28fa656c4e1e9935649f9cf..defbd83ebd1e99e23dc2a4796ddd2a248a3a5622 100644 (file)
@@ -117,13 +117,14 @@ const bf::path kUnifiedSmokePackagesDirectory =
 
 class SmokeTest : public testing::Test {
  public:
-  SmokeTest() : params{PackageType::TPK, false} {
+  SmokeTest() : backend(std::to_string(env->test_user.uid)),
+      params{PackageType::TPK, false} {
     params.test_user.uid = env->test_user.uid;
     params.test_user.gid = env->test_user.gid;
   }
 
  protected:
-  UnifiedSmokeTestHelperRunner backend;
+  UnifiedBackendInterface backend;
   TestParameters params;
 };
 
@@ -148,13 +149,13 @@ TEST_F(SmokeTest, RecoveryMode_Multi_Installation) {
   };
 
   int wait_time = delay + interval * test_count;
-  SmokeTestHelperRunner::Result ret = backend.InstallPkgsWithSubprocessAndKill(
-      paths, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret =
+      backend.InstallPkgsWithSubprocessAndKill(paths, wait_time);
+  if (ret == BackendInterface::SubProcessResult::SUCCESS) {
     std::cout << "install finished before process killed" << std::endl;
     return;
   }
-  ASSERT_EQ(ret, SmokeTestHelperRunner::Result::KILLED);
+  ASSERT_EQ(ret, BackendInterface::SubProcessResult::KILLED);
 
   bf::path recovery_file = FindRecoveryFile("/unified-recovery",
       params.test_user.uid);
@@ -173,8 +174,8 @@ TEST_F(SmokeTest, RecoveryMode_Multi_Installation) {
     return;
   }
   ASSERT_EQ(
-      backend.RecoveryPkgsWithSubprocess(recovery_list, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.RecoverPkgsWithSubprocess(recovery_list),
+      BackendInterface::SubProcessResult::SUCCESS);
   if (recovery_info.GetCleanUp()) {
     params.pkg_type = PackageType::TPK;
     ASSERT_TRUE(ValidatePackage(pkgids.at(0), app_infos.at(0), params));
@@ -183,14 +184,14 @@ TEST_F(SmokeTest, RecoveryMode_Multi_Installation) {
     params.pkg_type = PackageType::HYBRID;
     ASSERT_TRUE(ValidatePackage(pkgids.at(2), app_infos.at(2), params));
     ASSERT_EQ(
-        backend.UninstallWithSubprocess(pkgids.at(0), params.test_user.uid),
-        SmokeTestHelperRunner::Result::SUCCESS);
+        backend.UninstallWithSubprocess(pkgids.at(0)),
+        BackendInterface::SubProcessResult::SUCCESS);
     ASSERT_EQ(
-        backend.UninstallWithSubprocess(pkgids.at(1), params.test_user.uid),
-        SmokeTestHelperRunner::Result::SUCCESS);
+        backend.UninstallWithSubprocess(pkgids.at(1)),
+        BackendInterface::SubProcessResult::SUCCESS);
     ASSERT_EQ(
-        backend.UninstallWithSubprocess(pkgids.at(2), params.test_user.uid),
-        SmokeTestHelperRunner::Result::SUCCESS);
+        backend.UninstallWithSubprocess(pkgids.at(2)),
+        BackendInterface::SubProcessResult::SUCCESS);
   } else {
     params.pkg_type = PackageType::TPK;
     ASSERT_TRUE(CheckPackageNonExistance(pkgids.at(0), params));
@@ -226,16 +227,16 @@ TEST_F(SmokeTest, RecoveryMode_Multi_Update) {
   };
   int wait_time = delay + interval * test_count;
 
-  ASSERT_EQ(backend.InstallPkgsWithSubprocess(paths_old, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.InstallPkgsWithSubprocess(paths_old),
+      BackendInterface::SubProcessResult::SUCCESS);
 
-  SmokeTestHelperRunner::Result ret = backend.InstallPkgsWithSubprocessAndKill(
-      paths_new, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret =
+      backend.InstallPkgsWithSubprocessAndKill(paths_new, wait_time);
+  if (ret == BackendInterface::SubProcessResult::SUCCESS) {
     std::cout << "update finished before process killed" << std::endl;
     return;
   }
-  ASSERT_EQ(ret, SmokeTestHelperRunner::Result::KILLED);
+  ASSERT_EQ(ret, BackendInterface::SubProcessResult::KILLED);
 
   bf::path recovery_file = FindRecoveryFile("/unified-recovery",
       params.test_user.uid);
@@ -255,8 +256,8 @@ TEST_F(SmokeTest, RecoveryMode_Multi_Update) {
   }
 
   ASSERT_EQ(
-      backend.RecoveryPkgsWithSubprocess(recovery_list, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.RecoverPkgsWithSubprocess(recovery_list),
+      BackendInterface::SubProcessResult::SUCCESS);
   if (recovery_info.GetCleanUp()) {
     params.pkg_type = PackageType::TPK;
     ASSERT_TRUE(ValidatePackage(pkgids.at(0), app_infos.at(0), params));
@@ -285,14 +286,14 @@ TEST_F(SmokeTest, RecoveryMode_Multi_Update) {
         pkgids.at(2), "res/wgt/VERSION", "1", params));
   }
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(0), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(0)),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(1), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(1)),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(2), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(2)),
+      BackendInterface::SubProcessResult::SUCCESS);
 }
 
 TEST_F(SmokeTest, RecoveryMode_ForDelta) {
@@ -320,16 +321,16 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
   };
   int wait_time = delay + interval * test_count;
 
-  ASSERT_EQ(backend.InstallPkgsWithSubprocess(paths_old, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.InstallPkgsWithSubprocess(paths_old),
+      BackendInterface::SubProcessResult::SUCCESS);
 
-  SmokeTestHelperRunner::Result ret = backend.InstallPkgsWithSubprocessAndKill(
-      paths_new, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret =
+      backend.InstallPkgsWithSubprocessAndKill(paths_new, wait_time);
+  if (ret == BackendInterface::SubProcessResult::SUCCESS) {
     std::cout << "delta finished before process killed" << std::endl;
     return;
   }
-  ASSERT_EQ(ret, SmokeTestHelperRunner::Result::KILLED);
+  ASSERT_EQ(ret, BackendInterface::SubProcessResult::KILLED);
 
   bf::path recovery_file = FindRecoveryFile("/unified-recovery",
       params.test_user.uid);
@@ -349,8 +350,8 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
   }
 
   ASSERT_EQ(
-      backend.RecoveryPkgsWithSubprocess(recovery_list, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.RecoverPkgsWithSubprocess(recovery_list),
+      BackendInterface::SubProcessResult::SUCCESS);
   if (recovery_info.GetCleanUp()) {
     params.pkg_type = PackageType::TPK;
     ASSERT_TRUE(ValidatePackage(pkgids.at(0), app_infos.at(0), params));
@@ -379,14 +380,14 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
         pkgids.at(2), "res/wgt/VERSION", "1", params));
   }
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(0), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(0)),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(1), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(1)),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(2), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(2)),
+      BackendInterface::SubProcessResult::SUCCESS);
 }
 
 TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
@@ -410,14 +411,13 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
   };
 
   int wait_time = delay + interval * test_count;
-  SmokeTestHelperRunner::Result ret =
-      backend.MountInstallPkgsWithSubprocessAndKill(
-          paths, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret =
+      backend.MountInstallPkgsWithSubprocessAndKill(paths, wait_time);
+  if (ret == BackendInterface::SubProcessResult::SUCCESS) {
     std::cout << "install finished before process killed" << std::endl;
     return;
   }
-  ASSERT_EQ(ret, SmokeTestHelperRunner::Result::KILLED);
+  ASSERT_EQ(ret, BackendInterface::SubProcessResult::KILLED);
 
   bf::path recovery_file = FindRecoveryFile("/unified-recovery",
       params.test_user.uid);
@@ -436,8 +436,8 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
     return;
   }
   ASSERT_EQ(
-      backend.RecoveryPkgsWithSubprocess(recovery_list, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.RecoverPkgsWithSubprocess(recovery_list),
+      BackendInterface::SubProcessResult::SUCCESS);
   if (recovery_info.GetCleanUp()) {
     params.pkg_type = PackageType::TPK;
     ASSERT_TRUE(ValidatePackage(pkgids.at(0), app_infos.at(0), params));
@@ -446,14 +446,14 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
     params.pkg_type = PackageType::HYBRID;
     ASSERT_TRUE(ValidatePackage(pkgids.at(2), app_infos.at(2), params));
     ASSERT_EQ(
-        backend.UninstallWithSubprocess(pkgids.at(0), params.test_user.uid),
-        SmokeTestHelperRunner::Result::SUCCESS);
+        backend.UninstallWithSubprocess(pkgids.at(0)),
+        BackendInterface::SubProcessResult::SUCCESS);
     ASSERT_EQ(
-        backend.UninstallWithSubprocess(pkgids.at(1), params.test_user.uid),
-        SmokeTestHelperRunner::Result::SUCCESS);
+        backend.UninstallWithSubprocess(pkgids.at(1)),
+        BackendInterface::SubProcessResult::SUCCESS);
     ASSERT_EQ(
-        backend.UninstallWithSubprocess(pkgids.at(2), params.test_user.uid),
-        SmokeTestHelperRunner::Result::SUCCESS);
+        backend.UninstallWithSubprocess(pkgids.at(2)),
+        BackendInterface::SubProcessResult::SUCCESS);
   } else {
     params.pkg_type = PackageType::TPK;
     ASSERT_TRUE(CheckPackageNonExistance(pkgids.at(0), params));
@@ -490,17 +490,16 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
   int wait_time = delay + interval * test_count;
 
   ASSERT_EQ(backend.
-      MountInstallPkgsWithSubprocess(paths_old, params.test_user.uid),
-          SmokeTestHelperRunner::Result::SUCCESS);
+      MountInstallPkgsWithSubprocess(paths_old),
+          BackendInterface::SubProcessResult::SUCCESS);
 
-  SmokeTestHelperRunner::Result ret =
-      backend.MountInstallPkgsWithSubprocessAndKill(
-          paths_new, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret =
+      backend.MountInstallPkgsWithSubprocessAndKill(paths_new, wait_time);
+  if (ret == BackendInterface::SubProcessResult::SUCCESS) {
     std::cout << "update finished before process killed" << std::endl;
     return;
   }
-  ASSERT_EQ(ret, SmokeTestHelperRunner::Result::KILLED);
+  ASSERT_EQ(ret, BackendInterface::SubProcessResult::KILLED);
 
   bf::path recovery_file = FindRecoveryFile("/unified-recovery",
       params.test_user.uid);
@@ -526,8 +525,8 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
   }
 
   ASSERT_EQ(
-      backend.RecoveryPkgsWithSubprocess(recovery_list, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.RecoverPkgsWithSubprocess(recovery_list),
+      BackendInterface::SubProcessResult::SUCCESS);
 
   ScopedTzipInterface interface_1(pkgids.at(0), params.test_user.uid);
   ScopedTzipInterface interface_2(pkgids.at(1), params.test_user.uid);
@@ -562,14 +561,14 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
   }
 
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(0), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(0)),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(1), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(1)),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_EQ(
-      backend.UninstallWithSubprocess(pkgids.at(2), params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+      backend.UninstallWithSubprocess(pkgids.at(2)),
+      BackendInterface::SubProcessResult::SUCCESS);
 }
 
 }  // namespace smoke_test