ci::AppInstaller::Result Uninstall(const std::string& pkgid,
PackageType type,
+ bool is_preload,
RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-d", pkgid.c_str(), "-u", kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-ci::AppInstaller::Result UninstallPreload(const std::string& pkgid,
- PackageType type, RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-d", pkgid.c_str(), "--preload", "--force-remove"};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
+ if (is_preload) {
+ const char* argv[] = {"", "-d", pkgid.c_str(), "--preload",
+ "--force-remove"};
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
+ } else {
+ const char* argv[] = {"", "-d", pkgid.c_str(), "-u",
+ kTestUserIdStr.c_str()};
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
+ }
}
ci::AppInstaller::Result RDSUpdate(const bf::path& path,
return entries;
}
+void UninstallAllAppsInDirectory(bf::path dir, bool is_preload) {
+ 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(), PackageType::WGT,
+ is_preload, 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 smokewgt, 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, InstallationMode) {
bf::path path = kSmokePackagesDirectory / "InstallationMode.wgt";
std::string pkgid = "smokeapp03";
std::string appid = "smokeapp05.DeinstallationMode";
ASSERT_EQ(Install(path, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ASSERT_EQ(Uninstall(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(Uninstall(pkgid, PackageType::WGT, false),
+ ci::AppInstaller::Result::OK);
CheckPackageNonExistance(pkgid, {appid});
}
std::string appid1 = "smokehyb03.Web";
ASSERT_EQ(Install(path, PackageType::HYBRID),
ci::AppInstaller::Result::OK);
- ASSERT_EQ(Uninstall(pkgid, PackageType::HYBRID),
+ ASSERT_EQ(Uninstall(pkgid, PackageType::HYBRID, false),
ci::AppInstaller::Result::OK);
CheckPackageNonExistance(pkgid, {appid1});
}
ValidateDataFiles(pkgid, kTestUserId);
}
+// TODO(b.kunikowski): Change pkgid to "smokewgt##" like others pkgids, because
+// it is needed for properly test environment tear-down
TEST_F(SmokeTest, UserDefinedPlugins) {
bf::path path = kSmokePackagesDirectory / "SimpleEchoPrivilege.wgt";
std::string pkgid = "0CSPVhKmRk";
std::string appid = "smokeapp39.DeinstallationModePreload";
ASSERT_EQ(InstallPreload(path, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ASSERT_EQ(UninstallPreload(pkgid, PackageType::WGT),
+ ASSERT_EQ(Uninstall(pkgid, PackageType::WGT, true),
ci::AppInstaller::Result::OK);
CheckPackageReadonlyNonExistance(pkgid, {appid});
}