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) {
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) {