// globaluser entries
const char kGlobalManifestDir[] = "/opt/share/packages";
const char kSkelDir[] = "/etc/skel/apps_rw";
+const char kPreloadApps[] = "/usr/apps";
+const char kPreloadManifestDir[] = "/usr/share/packages";
+const char kPreloadIcons[] = "/usr/share/icons";
enum class RequestResult {
NORMAL,
bool ValidateFileContentInPackage(const std::string& pkgid,
const std::string& relative,
- const std::string& expected) {
- bf::path root_path = ci::GetRootAppPath(false,
+ const std::string& expected,
+ bool is_readonly = false) {
+ bf::path root_path = ci::GetRootAppPath(is_readonly,
kTestUserId);
bf::path file_path = root_path / pkgid / relative;
if (!bf::exists(file_path)) {
ASSERT_EQ(*system_share, stats.st_gid) << "Invalid gid: " << cache_path;
}
-void ValidatePackageFS(const std::string& pkgid, const std::string&,
- uid_t uid, gid_t gid) {
- bf::path root_path = ci::GetRootAppPath(false, uid);
+void ValidatePackageFS(const std::string& pkgid, const std::string& appid,
+ uid_t uid, gid_t gid, bool is_readonly = false) {
+ bf::path root_path = ci::GetRootAppPath(is_readonly, uid);
bf::path package_path = root_path / pkgid;
bf::path shared_path = package_path / "shared";
ASSERT_TRUE(bf::exists(root_path));
ASSERT_TRUE(bf::exists(shared_path));
bf::path manifest_path =
- bf::path(getUserManifestPath(uid, false)) / (pkgid + ".xml");
+ bf::path(getUserManifestPath(uid, is_readonly)) / (pkgid + ".xml");
ASSERT_TRUE(bf::exists(manifest_path));
// backups should not exist
}
}
-void PackageCheckCleanup(const std::string& pkgid, const std::string&) {
- bf::path root_path = ci::GetRootAppPath(false,
+void PackageCheckCleanup(const std::string& pkgid, const std::string&,
+ bool is_readonly = false) {
+ bf::path root_path = ci::GetRootAppPath(is_readonly,
kTestUserId);
bf::path package_path = root_path / pkgid;
ASSERT_FALSE(bf::exists(package_path));
bf::path manifest_path =
bf::path(getUserManifestPath(
- kTestUserId, false)) / (pkgid + ".xml");
+ kTestUserId, is_readonly)) / (pkgid + ".xml");
ASSERT_FALSE(bf::exists(manifest_path));
// backups should not exist
ASSERT_FALSE(bf::exists(manifest_backup));
}
-void ValidatePackage(const std::string& pkgid, const std::string& appid) {
+void ValidatePackage(const std::string& pkgid, const std::string& appid,
+ bool is_readonly = false) {
ASSERT_TRUE(ci::QueryIsPackageInstalled(
pkgid, ci::GetRequestMode(kTestUserId),
kTestUserId));
- ValidatePackageFS(pkgid, appid, kTestUserId, kTestGroupId);
+ ValidatePackageFS(pkgid, appid, kTestUserId, kTestGroupId, is_readonly);
if (kTestUserId == kGlobalUserUid) {
ci::UserList list = ci::GetUserList();
for (auto& l : list)
}
void CheckPackageNonExistance(const std::string& pkgid,
- const std::string& appid) {
+ const std::string& appid,
+ bool is_readonly = false) {
ASSERT_FALSE(ci::QueryIsPackageInstalled(
pkgid, ci::GetRequestMode(kTestUserId),
kTestUserId));
- PackageCheckCleanup(pkgid, appid);
+ PackageCheckCleanup(pkgid, appid, is_readonly);
}
std::unique_ptr<ci::AppQueryInterface> CreateQueryInterface() {
return CallBackend(SIZEOFARRAY(argv), argv, mode);
}
+ci::AppInstaller::Result InstallPreload(const bf::path& path,
+ RequestResult mode = RequestResult::NORMAL) {
+ const char* argv[] = {"", "-i", path.c_str(), "--preload"};
+ return CallBackend(SIZEOFARRAY(argv), argv, mode);
+}
+
bool CheckAvailableExternalPath() {
bf::path ext_mount_path = ci::GetExternalCardPath();
LOG(DEBUG) << "ext_mount_path :" << ext_mount_path;
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);
+}
+
ci::AppInstaller::Result EnablePackage(const std::string& path,
RequestResult mode = RequestResult::NORMAL) {
const char* argv[] = {"", "-A", path.c_str(), "-u", kTestUserIdStr.c_str()};
entries.emplace_back(path);
}
+ if (getuid() == 0) {
+ entries.emplace_back(kPreloadApps);
+ entries.emplace_back(kPreloadManifestDir);
+ entries.emplace_back(kPreloadIcons);
+ }
+
if (uid == kGlobalUserUid) {
entries.emplace_back(kSkelDir);
entries.emplace_back(kGlobalManifestDir);
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n"));
}
+TEST_F(SmokeTest, InstallationMode_Preload) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path = kSmokePackagesDirectory / "InstallationMode_Preload.tpk";
+ std::string pkgid = "smoketpk29";
+ std::string appid = "smoketpk29.InstallationModePreload";
+ ASSERT_EQ(InstallPreload(path), ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, appid, true);
+}
+
+TEST_F(SmokeTest, UpdateMode_Preload) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Preload.tpk";
+ bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Preload2.tpk";
+ std::string pkgid = "smoketpk30";
+ std::string appid = "smoketpk30.UpdateModePreload";
+ ASSERT_EQ(InstallPreload(path_old), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(InstallPreload(path_new), ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, appid, true);
+
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "2", true));
+}
+
+TEST_F(SmokeTest, DeinstallationMode_Preload) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Preload.tpk";
+ 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);
+ CheckPackageNonExistance(pkgid, appid, true);
+}
+
TEST_F(SmokeTest, InstallationMode_GoodSignature) {
bf::path path =
kSmokePackagesDirectory / "InstallationMode_GoodSignature.tpk";