From: Damian Pietruchowski Date: Thu, 2 Feb 2017 14:38:28 +0000 (+0100) Subject: Missing smoke tests for tpk-backend X-Git-Tag: accepted/tizen/common/20170209.122459~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F112774%2F5;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git Missing smoke tests for tpk-backend RecoveryMode_ForMountInstall RecoveryMode_ForMountUpdate MountInstallationMode_Rollback MountUpdateMode_Rollback. Requires: https://review.tizen.org/gerrit/#/c/112744/ Change-Id: I487474d8c0d36153ed0bb0e0e4a4080b544feb7d Signed-off-by: Damian Pietruchowski --- diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 52ecac7..bdb1d95 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -84,13 +84,21 @@ class ScopedTzipInterface { interface_.MountZip(ci::GetZipPackageLocation(pkg_path_, pkgid)); } + void Release() { + if (mounted_) { + interface_.UnmountZip(); + mounted_ = false; + } + } + ~ScopedTzipInterface() { - interface_.UnmountZip(); + Release(); } private: bf::path pkg_path_; ci::TzipInterface interface_; + bool mounted_; }; bool TouchFile(const bf::path& path) { @@ -996,6 +1004,73 @@ TEST_F(SmokeTest, UpdateMode_Rollback) { ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1")); } +TEST_F(SmokeTest, RecoveryMode_ForMountInstall) { + bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForMountInstall.tpk"; + RemoveAllRecoveryFiles(); + ci::Subprocess backend_crash("/usr/bin/tpk-backend-ut/smoke-test-helper"); + backend_crash.Run("-w", path.string(), "-u", kTestUserIdStr.c_str()); + ASSERT_NE(0, backend_crash.Wait()); + + std::string pkgid = "smoketpk37"; + std::string appid = "smoketpk37.RecoveryMode_ForMountInstall"; + bf::path recovery_file = FindRecoveryFile(); + ASSERT_FALSE(recovery_file.empty()); + ASSERT_EQ(ci::AppInstaller::Result::OK, Recover(recovery_file)); + CheckPackageNonExistance(pkgid, appid); +} + +TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) { + bf::path path_old = + kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate.tpk"; + bf::path path_new = + kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate2.tpk"; + RemoveAllRecoveryFiles(); + ASSERT_EQ(ci::AppInstaller::Result::OK, MountInstall(path_old)); + ci::Subprocess backend_crash("/usr/bin/tpk-backend-ut/smoke-test-helper"); + backend_crash.Run("-w", path_new.string(), "-u", kTestUserIdStr.c_str()); + ASSERT_NE(0, backend_crash.Wait()); + + std::string pkgid = "smoketpk38"; + std::string appid = "smoketpk38.RecoveryMode_ForMountUpdate"; + + // Filesystem may be mounted after crash + ScopedTzipInterface poweroff_unmount_interface(pkgid); + poweroff_unmount_interface.Release(); + + bf::path recovery_file = FindRecoveryFile(); + ASSERT_FALSE(recovery_file.empty()); + ASSERT_EQ(ci::AppInstaller::Result::OK, Recover(recovery_file)); + ScopedTzipInterface interface(pkgid); + ValidatePackage(pkgid, appid); + + ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1")); +} + +TEST_F(SmokeTest, MountInstallationMode_Rollback) { + bf::path path = + kSmokePackagesDirectory / "MountInstallationMode_Rollback.tpk"; + std::string pkgid = "smoketpk39"; + std::string appid = "smoketpk39.MountInstallationMode_Rollback"; + ASSERT_EQ(ci::AppInstaller::Result::ERROR, + MountInstall(path, RequestResult::FAIL)); + ScopedTzipInterface package_mount(pkgid); + CheckPackageNonExistance(pkgid, appid); +} + +TEST_F(SmokeTest, MountUpdateMode_Rollback) { + bf::path old_path = kSmokePackagesDirectory / "MountUpdateMode_Rollback.tpk"; + bf::path new_path = kSmokePackagesDirectory / "MountUpdateMode_Rollback2.tpk"; + std::string pkgid = "smoketpk40"; + std::string appid = "smoketpk40.MountUpdateMode_Rollback"; + ASSERT_EQ(ci::AppInstaller::Result::OK, MountInstall(old_path)); + ASSERT_EQ(ci::AppInstaller::Result::ERROR, + MountInstall(new_path, RequestResult::FAIL)); + ScopedTzipInterface package_mount(pkgid); + ValidatePackage(pkgid, appid); + + ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1")); +} + } // namespace common_installer int main(int argc, char** argv) { diff --git a/src/unit_tests/test_samples/smoke/MountInstallationMode_Rollback.tpk b/src/unit_tests/test_samples/smoke/MountInstallationMode_Rollback.tpk new file mode 100644 index 0000000..1d371be Binary files /dev/null and b/src/unit_tests/test_samples/smoke/MountInstallationMode_Rollback.tpk differ diff --git a/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback.tpk b/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback.tpk new file mode 100644 index 0000000..ccd5af0 Binary files /dev/null and b/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback.tpk differ diff --git a/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback2.tpk b/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback2.tpk new file mode 100644 index 0000000..3ec0596 Binary files /dev/null and b/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback2.tpk differ diff --git a/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountInstall.tpk b/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountInstall.tpk new file mode 100644 index 0000000..3a33b26 Binary files /dev/null and b/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountInstall.tpk differ diff --git a/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate.tpk b/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate.tpk new file mode 100644 index 0000000..362a1fc Binary files /dev/null and b/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate.tpk differ diff --git a/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate2.tpk b/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate2.tpk new file mode 100644 index 0000000..86ef6ce Binary files /dev/null and b/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate2.tpk differ