From: Ilho Kim Date: Thu, 13 Oct 2022 10:31:12 +0000 (+0900) Subject: Merge SmokeTestHelperRunner into BackendInterface X-Git-Tag: accepted/tizen/unified/20230102.131959~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=71a4643f0c1269ccc4fd091188e2d2cfd30606f0;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git Merge SmokeTestHelperRunner into BackendInterface Related change: [app-installers] https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-installers/+/283265/ Change-Id: I2b0c870fc0c57a063133168440971aeb63caf007 Signed-off-by: Ilho Kim --- diff --git a/test/smoke_tests/recovery_test.cc b/test/smoke_tests/recovery_test.cc index 6c59c4c..66414ac 100644 --- a/test/smoke_tests/recovery_test.cc +++ b/test/smoke_tests/recovery_test.cc @@ -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 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 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)); diff --git a/test/smoke_tests/tpk_smoke_utils.cc b/test/smoke_tests/tpk_smoke_utils.cc index 70a344c..8976596 100644 --- a/test/smoke_tests/tpk_smoke_utils.cc +++ b/test/smoke_tests/tpk_smoke_utils.cc @@ -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 { diff --git a/test/smoke_tests/tpk_smoke_utils.h b/test/smoke_tests/tpk_smoke_utils.h index f6186f9..f2fd74b 100644 --- a/test/smoke_tests/tpk_smoke_utils.h +++ b/test/smoke_tests/tpk_smoke_utils.h @@ -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