TestParameters params;
};
+class PreloadSmokeTest : public testing::Test {
+ public:
+ PreloadSmokeTest() : backend(std::to_string(env->test_user.uid)),
+ params{PackageType::TPK, true} {
+ params.test_user.uid = env->test_user.uid;
+ params.test_user.gid = env->test_user.gid;
+ }
+ protected:
+ TpkBackendInterface backend;
+ TestParameters params;
+};
+
TEST_F(SmokeTest, DeltaMode_Tpk_Rollback) {
bf::path path = kSmokePackagesDirectory / "DeltaMode_Tpk_Rollback.tpk";
bf::path delta_package = kSmokePackagesDirectory /
});
}
+TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) {
+ bf::path path_old = kSmokePackagesDirectory /
+ "RecoveryMode_ForReadonlyUpdateInstall.tpk";
+ bf::path path_new = kSmokePackagesDirectory /
+ "RecoveryMode_ForReadonlyUpdateInstall_2.tpk";
+ RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK);
+
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ std::vector<std::string> args =
+ {"", "-i", path_new.string(), "-u", test_uid_str.c_str()};
+ backend.CrashAfterEachStep(&args, [&](int step) -> bool {
+ if (step >= 2) {
+ std::string pkgid = "smoketpk46";
+ std::string appid = "smoketpk46.RecoveryMode_ForReadonlyUpdateInstall";
+ std::string exec = "smoketpk46";
+ bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
+ params.test_user.uid);
+ EXTENDED_ASSERT_FALSE(recovery_file.empty());
+ std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
+ GetRecoverFileInfo(recovery_file);
+ EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
+ ci::AppInstaller::Result::OK);
+ if (recovery_info->cleanup())
+ params.is_readonly = false;
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ std::string version = recovery_info->cleanup() ? "2" : "1";
+ EXTENDED_ASSERT_TRUE(
+ ValidateFileContentInPackage(pkgid, "res/VERSION", version, params));
+ if (recovery_info->cleanup()) {
+ EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+ ci::AppInstaller::Result::OK);
+ }
+ }
+ return true;
+ }, params.pkg_type);
+}
+
} // namespace smoke_test
int main(int argc, char** argv) {
ASSERT_FALSE(bf::exists(recovery_info->unpacked_dir()));
}
+TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path_old = kSmokePackagesDirectory /
+ "RecoveryMode_ForReadonlyUpdateInstall.tpk";
+ bf::path path_new = kSmokePackagesDirectory /
+ "RecoveryMode_ForReadonlyUpdateInstall_2.tpk";
+ RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK);
+
+ std::string pkgid = "smoketpk46";
+ std::string appid = "smoketpk46.RecoveryMode_ForReadonlyUpdateInstall";
+ std::string exec = "smoketpk46";
+ ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
+ std::string version_old = pkg_query.Version();
+
+ ci::Subprocess backend_crash("/usr/bin/tpk-installer-ut/smoke-test-helper");
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ backend_crash.Run("-i", path_new.string(), "-u", test_uid_str.c_str());
+ ASSERT_NE(backend_crash.Wait(), 0);
+
+ 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_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
+
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1", params));
+ ASSERT_FALSE(bf::exists(recovery_info->unpacked_dir()));
+ ci::PkgQueryInterface pkg_query2(pkgid, params.test_user.uid, true);
+ std::string version_recovered = pkg_query2.Version();
+ ASSERT_TRUE(version_old == version_recovered);
+}
+
} // namespace smoke_test
int main(int argc, char** argv) {