ASSERT_TRUE(ValidateExtendedPackage(pkgid, {appid}, params));
}
+TEST_F(SmokeTest, RecoveryMode_CrashAfterUnzip) {
+ bf::path path = kSmokePackagesDirectory / "RecoveryMode_CrashAfterUnzip.wgt";
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ backend_crash.Run("-i", path.string(), "-u", test_uid_str.c_str(),
+ "-step_name", "Unzip");
+ ASSERT_NE(backend_crash.Wait(), 0);
+
+ std::string pkgid = "smokewgt45";
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
+ ASSERT_FALSE(recovery_file.empty());
+ std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
+ GetRecoverFileInfo(recovery_file);
+ ASSERT_TRUE(recovery_info);
+ ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
+ ASSERT_FALSE(bf::exists(recovery_info->unpacked_dir()));
+}
+
} // namespace smoke_test
int main(int argc, char** argv) {
wgt::WgtInstaller::STEPS(); \
if (crash_at_ > -1) \
AddStepAtIndex<StepCrash>(crash_at_); \
+ else if (step_name_.size()) \
+ AddStepAfter<StepCrash>(step_name_); \
else \
AddStep<StepCrash>(); \
} \
class CrashWgtInstaller : public wgt::WgtInstaller {
public:
- explicit CrashWgtInstaller(ci::PkgMgrPtr pkgmgr, int crash_at)
- : wgt::WgtInstaller(pkgmgr), crash_at_(crash_at) { }
+ explicit CrashWgtInstaller(ci::PkgMgrPtr pkgmgr, int crash_at,
+ std::string step_name) : wgt::WgtInstaller(pkgmgr), crash_at_(crash_at),
+ step_name_(step_name) { }
private:
OVERRIDE_STEPS_BLOCK(InstallSteps)
OVERRIDE_STEPS_BLOCK(RecoverDBSteps)
int crash_at_;
+ std::string step_name_;
};
} // namespace
int main(int argc, char** argv) {
int index = -1;
int backend_argc = argc;
+ std::string step_name;
if (!strcmp(argv[argc-2], "-idx")) {
index = atoi(argv[argc-1]);
backend_argc = argc - 2;
LOG(DEBUG) << "Step crash after " << index << " step.";
}
+ if (!strcmp(argv[argc-2], "-step_name")) {
+ step_name = argv[argc-1];
+ backend_argc = argc-2;
+ LOG(DEBUG) << "Step crash after " << step_name << " step.";
+ }
+
ci::PkgmgrInstaller pkgmgr_installer;
wgt::WgtAppQueryInterface query_interface;
auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv,
return EINVAL;
}
- ::CrashWgtInstaller installer(pkgmgr, index);
+ ::CrashWgtInstaller installer(pkgmgr, index, step_name);
return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
}