// 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 file_path = GetPackageRoot(pkgid, kTestUserId) / relative;
+ const std::string& expected,
+ bool is_readonly = false) {
+ bf::path file_path = ci::GetRootAppPath(is_readonly, kTestUserId);
+ file_path = file_path / pkgid / relative;
if (!bf::exists(file_path)) {
LOG(ERROR) << file_path << " doesn't exist";
return false;
void ValidatePackageFS(const std::string& pkgid,
const std::vector<std::string>& appids,
- uid_t uid, gid_t gid) {
- bf::path root_path = ci::GetRootAppPath(false, uid);
- bf::path package_path = GetPackageRoot(pkgid, uid);
+ uid_t uid, gid_t gid, bool is_readonly) {
+ 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(package_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));
for (auto& appid : appids) {
}
void PackageCheckCleanup(const std::string& pkgid,
- const std::vector<std::string>&) {
- bf::path package_path = GetPackageRoot(pkgid, kTestUserId);
+ const std::vector<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");
+ bf::path manifest_path = bf::path(getUserManifestPath(kTestUserId,
+ is_readonly)) / (pkgid + ".xml");
ASSERT_FALSE(bf::exists(manifest_path));
// backups should not exist
}
void ValidatePackage(const std::string& pkgid,
- const std::vector<std::string>& appids) {
+ const std::vector<std::string>& appids, bool is_readonly = false) {
ASSERT_TRUE(ci::QueryIsPackageInstalled(
- pkgid, ci::GetRequestMode(kTestUserId),
- kTestUserId));
- ValidatePackageFS(pkgid, appids, kTestUserId, kTestGroupId);
+ pkgid, ci::GetRequestMode(kTestUserId), kTestUserId));
+ ValidatePackageFS(pkgid, appids, kTestUserId, kTestGroupId, is_readonly);
if (kTestUserId == kGlobalUserUid) {
ci::UserList list = ci::GetUserList();
for (auto& l : list)
ASSERT_EQ(app2ext_usr_enable_external_pkg(pkgid.c_str(), uid), 0);
bf::path root_path = ci::GetRootAppPath(false, uid);
ASSERT_TRUE(bf::exists(root_path / pkgid / ".mmc" / "res"));
- ValidatePackageFS(pkgid, appids, uid, gid);
+ ValidatePackageFS(pkgid, appids, uid, gid, false);
ASSERT_EQ(app2ext_usr_disable_external_pkg(pkgid.c_str(), uid), 0);
}
PackageCheckCleanup(pkgid, appids);
}
+void CheckPackageReadonlyNonExistance(const std::string& pkgid,
+ const std::vector<std::string>& appids) {
+ ASSERT_FALSE(ci::QueryIsPackageInstalled(
+ pkgid, ci::GetRequestMode(kTestUserId), kTestUserId));
+ PackageCheckCleanup(pkgid, appids, true);
+}
+
std::unique_ptr<ci::AppQueryInterface> CreateQueryInterface() {
std::unique_ptr<ci::AppQueryInterface> query_interface(
new wgt::WgtAppQueryInterface());
return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
}
+ci::AppInstaller::Result InstallPreload(const bf::path& path, PackageType type,
+ RequestResult mode = RequestResult::NORMAL) {
+ const char* argv[] = {"", "-i", path.c_str(), "--preload"};
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
+}
+
bool CheckAvailableExternalPath() {
bf::path ext_mount_path = ci::GetExternalCardPath();
LOG(DEBUG) << "ext_mount_path :" << ext_mount_path;
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);
+}
+
ci::AppInstaller::Result RDSUpdate(const bf::path& path,
const std::string& pkgid,
PackageType type,
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);
ValidateExternalPackage(pkgid, {appid});
}
+TEST_F(SmokeTest, InstallationMode_Preload) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path = kSmokePackagesDirectory / "InstallationMode_Preload.wgt";
+ std::string pkgid = "smokeapp37";
+ std::string appid = "smokeapp37.InstallationModePreload";
+ ASSERT_EQ(InstallPreload(path, PackageType::WGT),
+ 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.wgt";
+ bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Preload2.wgt";
+ std::string pkgid = "smokeapp38";
+ std::string appid = "smokeapp38.UpdateModePreload";
+ ASSERT_EQ(InstallPreload(path_old, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, kTestUserId);
+ ASSERT_EQ(InstallPreload(path_new, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid}, true);
+
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2",
+ true));
+ ValidateDataFiles(pkgid, kTestUserId);
+}
+
+TEST_F(SmokeTest, DeinstallationMode_Preload) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Preload.wgt";
+ std::string pkgid = "smokeapp39";
+ std::string appid = "smokeapp39.DeinstallationModePreload";
+ ASSERT_EQ(InstallPreload(path, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_EQ(UninstallPreload(pkgid, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ CheckPackageReadonlyNonExistance(pkgid, {appid});
+}
+
} // namespace common_installer
int main(int argc, char** argv) {