for (auto& path : backups_)
ASSERT_TRUE(BackupPathCopyAndRemove(path));
}
+
+ CreateDatabase();
}
void TearDown() override {
ASSERT_TRUE(request_mode_ == ci::RequestMode::GLOBAL ||
}, params.pkg_type);
}
+TEST_F(SmokeTest, RecoveryMode_AddResControl) {
+ bf::path path_old = kSmokePackagesDirectory
+ / "RecoveryMode_AddResControl.tpk";
+ bf::path path_new = kSmokePackagesDirectory
+ / "RecoveryMode_AddResControl_2.tpk";
+ RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+
+ std::string pkgid = "smoketpk50";
+ std::string appid = "smoketpk50.RecoveryMode_AddResControl";
+ std::string exec = "native";
+ bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ params.test_user.uid);
+
+ 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) {
+ 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);
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ bool dir_exists = recovery_info->cleanup();
+ EXTENDED_ASSERT_EQ(bf::exists(root_path / pkgid / "res/mount/allowed"),
+ dir_exists);
+ EXTENDED_ASSERT_EQ(bf::exists(root_path / pkgid / "res/mount/global"),
+ dir_exists);
+ EXTENDED_ASSERT_EQ(bf::exists(root_path / pkgid / "res/mount/work"),
+ dir_exists);
+
+ if (recovery_info->cleanup()) {
+ EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+ ci::AppInstaller::Result::OK);
+ EXTENDED_ASSERT_EQ(backend.Install(path_old),
+ ci::AppInstaller::Result::OK);
+ }
+ }
+ return true;
+ }, params.pkg_type);
+}
+
+TEST_F(SmokeTest, RecoveryMode_RemoveResControl) {
+ bf::path path_old = kSmokePackagesDirectory
+ / "RecoveryMode_RemoveResControl.tpk";
+ bf::path path_new = kSmokePackagesDirectory
+ / "RecoveryMode_RemoveResControl_2.tpk";
+ RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+
+ std::string pkgid = "smoketpk51";
+ std::string appid = "smoketpk51.RecoveryMode_RemoveResControl";
+ std::string exec = "native";
+ bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ params.test_user.uid);
+
+ 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) {
+ 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);
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ bool dir_exists = !recovery_info->cleanup();
+ EXTENDED_ASSERT_EQ(bf::exists(root_path / pkgid / "res/mount/allowed"),
+ dir_exists);
+ EXTENDED_ASSERT_EQ(bf::exists(root_path / pkgid / "res/mount/global"),
+ dir_exists);
+ EXTENDED_ASSERT_EQ(bf::exists(root_path / pkgid / "res/mount/work"),
+ dir_exists);
+
+ if (recovery_info->cleanup()) {
+ EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+ ci::AppInstaller::Result::OK);
+ EXTENDED_ASSERT_EQ(backend.Install(path_old),
+ ci::AppInstaller::Result::OK);
+ }
+ }
+ return true;
+ }, params.pkg_type);
+}
+
} // namespace smoke_test
int main(int argc, char** argv) {
ASSERT_TRUE(version_old == version_recovered);
}
+TEST_F(SmokeTest, InstallationMode_ResControl) {
+ bf::path path = kSmokePackagesDirectory / "InstallationMode_ResControl.tpk";
+ std::string pkgid = "smoketpk47";
+ std::string appid = "smoketpk47.InstallationMode_ResControl";
+ std::string exec = "native";
+ bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ params.test_user.uid);
+
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/work"));
+}
+
+TEST_F(SmokeTest, UpdateMode_AddResControl) {
+ bf::path path_old = kSmokePackagesDirectory
+ / "UpdateMode_AddResControl.tpk";
+ bf::path path_new = kSmokePackagesDirectory
+ / "UpdateMode_AddResControl_2.tpk";
+ std::string pkgid = "smoketpk48";
+ std::string appid = "smoketpk48.UpdateMode_AddResControl";
+ std::string exec = "native";
+ bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ params.test_user.uid);
+
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/work"));
+
+ ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/work"));
+}
+
+TEST_F(SmokeTest, UpdateMode_RemoveResControl) {
+ bf::path path_old = kSmokePackagesDirectory
+ / "UpdateMode_RemoveResControl.tpk";
+ bf::path path_new = kSmokePackagesDirectory
+ / "UpdateMode_RemoveResControl_2.tpk";
+ std::string pkgid = "smoketpk49";
+ std::string appid = "smoketpk49.UpdateMode_RemoveResControl";
+ std::string exec = "native";
+ bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ params.test_user.uid);
+
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/work"));
+
+ ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/work"));
+}
+
+TEST_F(SmokeTest, RecoveryMode_AddResControl) {
+ bf::path path_old = kSmokePackagesDirectory
+ / "RecoveryMode_AddResControl.tpk";
+ bf::path path_new = kSmokePackagesDirectory
+ / "RecoveryMode_AddResControl_2.tpk";
+ RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
+
+ std::string pkgid = "smoketpk50";
+ std::string appid = "smoketpk50.RecoveryMode_AddResControl";
+ std::string exec = "native";
+ bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ params.test_user.uid);
+
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/work"));
+
+ 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_FALSE(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res/mount/work"));
+}
+
+TEST_F(SmokeTest, RecoveryMode_RemoveResControl) {
+ bf::path path_old = kSmokePackagesDirectory
+ / "RecoveryMode_RemoveResControl.tpk";
+ bf::path path_new = kSmokePackagesDirectory
+ / "RecoveryMode_RemoveResControl_2.tpk";
+ RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
+
+ std::string pkgid = "smoketpk51";
+ std::string appid = "smoketpk51.RecoveryMode_RemoveResControl";
+ std::string exec = "native";
+ bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ params.test_user.uid);
+
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/work"));
+
+ 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(bf::exists(root_path / pkgid / "res/mount/allowed"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/global"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res/mount/work"));
+}
+
} // namespace smoke_test
int main(int argc, char** argv) {