ASSERT_TRUE(ValidateExtendedPackage(pkgid, {appid, exec}, params));
}
+TEST_F(SmokeTest, RecoveryMode_CrashAfterUnzip) {
+ bf::path path = kSmokePackagesDirectory / "RecoveryMode_CrashAfterUnzip.tpk";
+ RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
+ ci::Subprocess backend_crash("/usr/bin/tpk-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 = "smokeapp47";
+ bf::path recovery_file = FindRecoveryFile("/tpk-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) {
tpk::TpkInstaller::STEPS(); \
if (crash_at_ > -1) \
AddStepAtIndex<StepCrash>(crash_at_); \
+ else if (step_name_.size()) \
+ AddStepAfter<StepCrash>(step_name_); \
else \
AddStep<StepCrash>(); \
} \
class CrashTpkInstaller : public tpk::TpkInstaller {
public:
- explicit CrashTpkInstaller(ci::PkgMgrPtr pkgmgr, int crash_at)
- : tpk::TpkInstaller(pkgmgr), crash_at_(crash_at) { }
+ explicit CrashTpkInstaller(ci::PkgMgrPtr pkgmgr, int crash_at,
+ std::string step_name) : tpk::TpkInstaller(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(const 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;
tpk::TpkAppQueryInterface interface;
ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv,
return -1;
}
- ::CrashTpkInstaller t(pkgmgr, index);
+ ::CrashTpkInstaller t(pkgmgr, index, step_name);
if (t.Run() != ci::AppInstaller::Result::OK) {
LOG(ERROR) << "CrashTpkInstaller run failure";