Merge SmokeTestHelperRunner into BackendInterface 68/283268/1
authorIlho Kim <ilho159.kim@samsung.com>
Thu, 13 Oct 2022 10:31:12 +0000 (19:31 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Fri, 21 Oct 2022 06:48:04 +0000 (15:48 +0900)
Related change:
  [app-installers] https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-installers/+/283265/

Change-Id: I2b0c870fc0c57a063133168440971aeb63caf007
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
test/smoke_tests/recovery_test.cc
test/smoke_tests/tpk_smoke_utils.cc
test/smoke_tests/tpk_smoke_utils.h

index 6c59c4c2f19dbe9901091d12fc3f7ceff40b12b4..66414acbdcf1f32f5bb5ee01602b68d470ec767e 100644 (file)
@@ -82,10 +82,10 @@ class SmokeEnvironment : public testing::Environment {
 
     ci::PkgQueryInterface pkg_query("recoverypkg", test_user.uid, true);
     if (pkg_query.IsPackageInstalled()) {
-      TpkSmokeTestHelperRunner backend;
-      SmokeTestHelperRunner::Result ret =
-          backend.UninstallWithSubprocess("recoverypkg", test_user.uid);
-      ASSERT_EQ(ret, SmokeTestHelperRunner::Result::SUCCESS);
+      TpkBackendInterface backend(std::to_string(test_user.uid));
+      BackendInterface::SubProcessResult ret =
+          backend.UninstallWithSubprocess("recoverypkg");
+      ASSERT_EQ(ret, BackendInterface::SubProcessResult::SUCCESS);
     }
 
     if (request_mode_ == ci::RequestMode::USER) {
@@ -128,13 +128,14 @@ namespace smoke_test {
 
 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:
-  TpkSmokeTestHelperRunner backend;
+  TpkBackendInterface backend;
   TestParameters params;
 };
 
@@ -144,13 +145,13 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) {
   bf::path path = kSmokePackagesDirectory / "RecoveryPkg.tpk";
   int wait_time = delay + interval * test_count;
 
-  SmokeTestHelperRunner::Result ret = backend.InstallWithSubprocessAndKill(
-      path, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret = backend.InstallWithSubprocessAndKill(
+      path, 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);
   std::string pkgid = "recoverypkg";
   bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
       params.test_user.uid);
@@ -159,8 +160,8 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) {
                  "this test is skipped" << std::endl;
     return;
   }
-  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
 }
 
@@ -168,22 +169,20 @@ 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) {
+  BackendInterface::SubProcessResult ret = backend.InstallWithSubprocess(path);
+  if (ret != BackendInterface::SubProcessResult::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) {
+  ret = backend.UninstallWithSubprocessAndKill(pkgid, wait_time);
+  if (ret == BackendInterface::SubProcessResult::SUCCESS) {
     std::cout << "uninstall finished before process killed" << std::endl;
     return;
   }
-  ASSERT_EQ(ret, SmokeTestHelperRunner::Result::KILLED);
+  ASSERT_EQ(ret, BackendInterface::SubProcessResult::KILLED);
 
   bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
       params.test_user.uid);
@@ -192,8 +191,8 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Uninstallation) {
                  "this test is skipped" << std::endl;
     return;
   }
-  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
 }
 
@@ -204,16 +203,16 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Update) {
   bf::path path_new = kSmokePackagesDirectory / "RecoveryPkg2.tpk";
   int wait_time = delay + interval * test_count;
 
-  ASSERT_EQ(backend.InstallWithSubprocess(path_old, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.InstallWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
 
-  SmokeTestHelperRunner::Result ret = backend.InstallWithSubprocessAndKill(
-      path_new, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret = backend.InstallWithSubprocessAndKill(
+      path_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);
 
   std::string pkgid = "recoverypkg";
   std::string appid = "recoverypkg";
@@ -228,8 +227,8 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Update) {
 
   std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
       GetRecoverFileInfo(recovery_file);
-  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION",
       recovery_info->cleanup() ? "2\n" : "1\n", params));
@@ -242,16 +241,16 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
   bf::path path_new = kSmokePackagesDirectory / "RecoveryPkg.delta";
   int wait_time = delay + interval * test_count;
 
-  ASSERT_EQ(backend.InstallWithSubprocess(path_old, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.InstallWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
 
-  SmokeTestHelperRunner::Result ret = backend.InstallWithSubprocessAndKill(
-      path_new, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret = backend.InstallWithSubprocessAndKill(
+      path_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);
 
   std::string pkgid = "recoverypkg";
   std::string appid = "recoverypkg";
@@ -268,8 +267,8 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
 
   std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
       GetRecoverFileInfo(recovery_file);
-  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file),
+      BackendInterface::SubProcessResult::SUCCESS);
   ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION",
       recovery_info->cleanup() ? "2\n" : "1\n", params));
@@ -285,9 +284,9 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
   bf::path path = kSmokePackagesDirectory / "RecoveryPkg.tpk";
   int wait_time = delay + interval * test_count;
 
-  SmokeTestHelperRunner::Result ret = backend.MountInstallWithSubprocessAndKill(
-      path, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret = backend.MountInstallWithSubprocessAndKill(
+      path, wait_time);
+  if (ret == BackendInterface::SubProcessResult::SUCCESS) {
     std::cout << "mount install finished before process killed" << std::endl;
     return;
   }
@@ -300,8 +299,8 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
                  "this test is skipped" << std::endl;
     return;
   }
-  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file),
+      BackendInterface::SubProcessResult::SUCCESS);
 
   ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
 }
@@ -315,12 +314,12 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
       kSmokePackagesDirectory / "RecoveryPkg2.tpk";
   int wait_time = delay + interval * test_count;
 
-  ASSERT_EQ(backend.MountInstallWithSubprocess(path_old, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.MountInstallWithSubprocess(path_old),
+      BackendInterface::SubProcessResult::SUCCESS);
 
-  SmokeTestHelperRunner::Result ret = backend.MountInstallWithSubprocessAndKill(
-      path_new, params.test_user.uid, wait_time);
-  if (ret == SmokeTestHelperRunner::Result::SUCCESS) {
+  BackendInterface::SubProcessResult ret = backend.MountInstallWithSubprocessAndKill(
+      path_new, wait_time);
+  if (ret == BackendInterface::SubProcessResult::SUCCESS) {
     std::cout << "mount update finished before process killed" << std::endl;
     return;
   }
@@ -340,8 +339,8 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
   ScopedTzipInterface poweroff_unmount_interface(pkgid, params.test_user.uid);
   poweroff_unmount_interface.Release();
 
-  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file, params.test_user.uid),
-      SmokeTestHelperRunner::Result::SUCCESS);
+  ASSERT_EQ(backend.RecoveryWithSubprocess(recovery_file),
+      BackendInterface::SubProcessResult::SUCCESS);
 
   ScopedTzipInterface interface(pkgid, params.test_user.uid);
   ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
index 70a344cde7cf5303e3ab45fac422a668f949d07c..89765969dcfce413f02bb547e52d4a9d64a47bd1 100644 (file)
@@ -54,6 +54,11 @@ TpkBackendInterface::CreateFailExpectedInstaller(
   return AppInstallerPtr(new FailExpectedTpkInstaller(pkgmgr, fail_at));
 }
 
+common_installer::Subprocess TpkBackendInterface::CreateSubprocess() const {
+  return common_installer::Subprocess(
+      "/usr/bin/tpk-installer-ut/smoke-test-helper");
+}
+
 TpkBackendInterface::CommandResult
 TpkBackendInterface::InstallWithTEP(
     const bf::path& path, const bf::path& tep) const {
index f6186f9d11e0131e206751204da5ed04a949d50e..f2fd74b6307d77f331e937a18e084035f74c9fee 100644 (file)
@@ -50,14 +50,7 @@ class TpkBackendInterface: public BackendInterface {
       common_installer::PkgMgrPtr pkgmgr) const override;
   AppInstallerPtr CreateFailExpectedInstaller(
       common_installer::PkgMgrPtr pkgmgr, int fail_at) const override;
-};
-
-class TpkSmokeTestHelperRunner : public SmokeTestHelperRunner {
- private:
-  common_installer::Subprocess CreateSubprocess() const {
-    return common_installer::Subprocess(
-        "/usr/bin/tpk-installer-ut/smoke-test-helper");
-  }
+  common_installer::Subprocess CreateSubprocess() const override;
 };
 
 #ifdef OVERRIDE_STEPS_BLOCK