#include <common/step/filesystem/step_update_tep.h>
#include <common/step/mount/step_mount_install.h>
#include <common/step/mount/step_mount_unpacked.h>
+#include <common/step/mount/step_mount_recover.h>
#include <common/step/mount/step_mount_update.h>
#include <common/step/pkgmgr/step_check_removable.h>
#include <common/step/pkgmgr/step_check_restriction.h>
AddStep<ci::filesystem::StepRecoverExternalStorage>();
AddStep<ci::filesystem::StepRecoverStorageDirectories>();
AddStep<ci::filesystem::StepRecoverFiles>();
+ AddStep<ci::mount::StepMountRecover>();
AddStep<tpk::security::StepTpkRecoverSignature>();
AddStep<ci::pkgmgr::StepRecoverApplication>();
AddStep<ci::security::StepRecoverSecurity>();
explicit ScopedTzipInterface(const std::string& pkgid)
: pkg_path_(bf::path(ci::GetRootAppPath(false,
kTestUserId)) / pkgid),
- interface_(ci::GetMountLocation(pkg_path_)) {
+ interface_(ci::GetMountLocation(pkg_path_)),
+ mounted_(true) {
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_;
};
class TestPkgmgrInstaller : public ci::PkgmgrInstallerInterface {
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
}
+TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
+ bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForMountInstall.wgt";
+ RemoveAllRecoveryFiles();
+ Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ backend_crash.Run("-w", path.string(), "-u", kTestUserIdStr.c_str());
+ ASSERT_NE(backend_crash.Wait(), 0);
+
+ std::string pkgid = "smokeapp31";
+ std::string appid = "smokeapp31.RecoveryModeForMountInstall";
+ bf::path recovery_file = FindRecoveryFile();
+ ASSERT_FALSE(recovery_file.empty());
+ ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ CheckPackageNonExistance(pkgid, {appid});
+}
+
+TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
+ bf::path path_old =
+ kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate.wgt";
+ bf::path path_new =
+ kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate_2.wgt";
+ std::string pkgid = "smokeapp32";
+ std::string appid = "smokeapp32.RecoveryModeForMountUpdate";
+ RemoveAllRecoveryFiles();
+ ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ backend_crash.Run("-w", path_new.string(), "-u", kTestUserIdStr.c_str());
+ ASSERT_NE(backend_crash.Wait(), 0);
+
+ // 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(Recover(recovery_file, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+
+ ScopedTzipInterface interface(pkgid);
+ ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
+}
+
TEST_F(SmokeTest, InstallationMode_GoodSignature) {
bf::path path = kSmokePackagesDirectory / "InstallationMode_GoodSignature.wgt"; // NOLINT
ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
#include <common/step/filesystem/step_unzip.h>
#include <common/step/filesystem/step_update_tep.h>
#include <common/step/mount/step_mount_install.h>
+#include <common/step/mount/step_mount_recover.h>
#include <common/step/mount/step_mount_unpacked.h>
#include <common/step/mount/step_mount_update.h>
#include <common/step/pkgmgr/step_check_removable.h>
AddStep<ci::filesystem::StepRecoverExternalStorage>();
AddStep<ci::filesystem::StepRecoverStorageDirectories>();
AddStep<ci::filesystem::StepRecoverFiles>();
+ AddStep<ci::mount::StepMountRecover>();
AddStep<wgt::security::StepWgtRecoverSignature>();
AddStep<ci::pkgmgr::StepRecoverApplication>();
AddStep<ci::security::StepRecoverSecurity>();