return MountInstall(path_new, mode);
}
-ci::AppInstaller::Result Uninstall(const std::string& pkgid,
+ci::AppInstaller::Result Uninstall(const std::string& pkgid, bool is_readonly,
RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-d", pkgid.c_str(), "-u", kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, mode);
-}
-
-ci::AppInstaller::Result UninstallPreload(const std::string& pkgid,
- RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-d", pkgid.c_str(), "--preload", "--force-remove"};
- return CallBackend(SIZEOFARRAY(argv), argv, mode);
+ if (is_readonly) {
+ const char* argv[] = {"", "-d", pkgid.c_str(), "--preload",
+ "--force-remove"};
+ return CallBackend(SIZEOFARRAY(argv), argv, mode);
+ } else {
+ const char* argv[] = {"", "-d", pkgid.c_str(), "-u",
+ kTestUserIdStr.c_str()};
+ return CallBackend(SIZEOFARRAY(argv), argv, mode);
+ }
}
ci::AppInstaller::Result EnablePackage(const std::string& path,
return entries;
}
+void UninstallAllAppsInDirectory(bf::path dir, bool is_readonly) {
+ if (bf::exists(dir)) {
+ for (auto& dir_entry : boost::make_iterator_range(
+ bf::directory_iterator(dir), bf::directory_iterator())) {
+ if (dir_entry.path().string().find("smoke") != std::string::npos &&
+ bf::is_directory(dir_entry)) {
+ if (Uninstall(dir_entry.path().filename().string(), is_readonly,
+ RequestResult::NORMAL) != ci::AppInstaller::Result::OK) {
+ LOG(ERROR) << "Cannot uninstall smoke test app: "
+ << dir_entry.path().filename().string();
+ }
+ }
+ }
+ }
+}
+
+void UninstallAllSmokeApps(uid_t uid) {
+ if (getuid() == 0) {
+ bf::path root_path = kPreloadApps;
+ UninstallAllAppsInDirectory(root_path, true);
+ }
+ bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ UninstallAllAppsInDirectory(apps_rw, false);
+}
+
} // namespace
namespace common_installer {
BackupPath(path);
}
void TearDown() override {
- // TODO(s89.jang): Uninstall smoke packages to clear security context
+ UninstallAllSmokeApps(uid_);
for (auto& path : backups_)
RestorePath(path);
}
class SmokeTest : public testing::Test {
};
+// TODO(b.kunikowski): New smoke app pkgid name convention.
+// Change all smokeapp pkgids to smoketpk, because now there
+// may be some smoke app pkgid identical as in tpk smoke tests, and this may
+// cause bad results of some smoke tests.
+
TEST_F(SmokeTest, DeltaMode_Tpk) {
bf::path path = kSmokePackagesDirectory / "DeltaMode_Tpk.tpk";
bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Tpk.delta";
std::string pkgid = "smokeapp14";
std::string appid = "smokeapp14.DeinstallationModeTpk";
ASSERT_EQ(Install(path), ci::AppInstaller::Result::OK);
- ASSERT_EQ(Uninstall(pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(Uninstall(pkgid, false), ci::AppInstaller::Result::OK);
CheckPackageNonExistance(pkgid, appid);
}
std::string pkgid = "smoketpk31";
std::string appid = "smoketpk31.DeinstallationModePreload";
ASSERT_EQ(InstallPreload(path), ci::AppInstaller::Result::OK);
- ASSERT_EQ(UninstallPreload(pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(Uninstall(pkgid, true), ci::AppInstaller::Result::OK);
CheckPackageNonExistance(pkgid, appid, true);
}