return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
}
-static const std::string appDirPath(const TemporaryTestUser &user)
+static const std::string appDirPath(const TemporaryTestUser &user,
+ const std::string &appId, const std::string &pkgId)
{
struct tzplatform_context *tzCtxPtr = nullptr;
"tzplatform_context_getenv failed"
<< "for getting sys rw app of user <" << user.getUserName() << ">");
- return appDir;
+ return std::string(appDir) + "/" + pkgId + "/" + appId;
}
static const std::string nonAppDirPath(const TemporaryTestUser &user)
mode_t execFileMode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
mode_t normalFileMode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
- mkdirSafe(dir, dirMode);
+ mktreeSafe(dir, dirMode);
creatSafe(dir + "/" + EXEC_FILE, execFileMode);
creatSafe(dir + "/" + NORMAL_FILE, normalFileMode);
symlinkSafe(dir + "/" + EXEC_FILE, dir + "/" + LINK_PREFIX + EXEC_FILE);
dir + "/" + LINK_PREFIX + "non_app_" + NORMAL_FILE);
}
-static void generateAppDir(const TemporaryTestUser &user)
+static void generateAppDir(const TemporaryTestUser &user,
+ const std::string &appId, const std::string &pkgId)
{
- const std::string dir = appDirPath(user);
+ const std::string dir = appDirPath(user, appId, pkgId);
const std::string nonAppDir = nonAppDirPath(user);
createInnerAppDir(dir, nonAppDir);
createTestDir(dir + "/inner_dir");
}
-static void createTestDirs(const TemporaryTestUser &user)
+static void createTestDirs(const TemporaryTestUser &user,
+ const std::string &appId, const std::string &pkgId)
{
- generateAppDir(user);
+ generateAppDir(user, appId, pkgId);
generateNonAppDir(user);
}
-static void removeTestDirs(const TemporaryTestUser &user)
+static void removeTestDirs(const TemporaryTestUser &user,
+ const std::string &appId, const std::string &pkgId)
{
- removeDir(appDirPath(user));
+ removeDir(appDirPath(user, appId, pkgId));
removeDir(nonAppDirPath(user));
}
TemporaryTestUser testUser(new_user_name, GUM_USERTYPE_NORMAL, false);
testUser.create();
- removeTestDirs(testUser);
- createTestDirs(testUser);
+ removeTestDirs(testUser, sm_app_id, sm_pkg_id);
+ createTestDirs(testUser, sm_app_id, sm_pkg_id);
- const std::string userAppDirPath = appDirPath(testUser);
+ const std::string userAppDirPath = appDirPath(testUser, sm_app_id, sm_pkg_id);
//switch user to non-root
result = drop_root_privileges(testUser.getUid(), testUser.getGid());
TemporaryTestUser testUser(new_user_name, GUM_USERTYPE_NORMAL, false);
testUser.create();
- removeTestDirs(testUser);
- createTestDirs(testUser);
+ removeTestDirs(testUser, sm_app_id, sm_pkg_id);
+ createTestDirs(testUser, sm_app_id, sm_pkg_id);
- install_and_check(sm_app_id, sm_pkg_id, testUser, appDirPath(testUser), true);
+ install_and_check(sm_app_id, sm_pkg_id, testUser, appDirPath(testUser, sm_app_id, sm_pkg_id), true);
//switch user to non-root - root may not uninstall apps for specified users
result = drop_root_privileges(testUser.getUid(), testUser.getGid());
test_user.create();
test_user.getUidString(uid_string);
- removeTestDirs(test_user);
- createTestDirs(test_user);
+ removeTestDirs(test_user, sm_app_id, sm_pkg_id);
+ createTestDirs(test_user, sm_app_id, sm_pkg_id);
install_app(sm_app_id, sm_pkg_id, test_user.getUid());
test_user.create();
test_user.getUidString(uid_string);
- removeTestDirs(test_user);
- createTestDirs(test_user);
+ removeTestDirs(test_user, sm_app_id, sm_pkg_id);
+ createTestDirs(test_user, sm_app_id, sm_pkg_id);
addUserRequest.setUid(test_user.getUid());
addUserRequest.setUserType(SM_USER_TYPE_NORMAL);
TemporaryTestUser test_user(new_user_name, GUM_USERTYPE_NORMAL, true);
test_user.create();
- removeTestDirs(test_user);
- createTestDirs(test_user);
+ removeTestDirs(test_user, app_id, pkg_id);
+ createTestDirs(test_user, app_id, pkg_id);
install_app(app_id, pkg_id, test_user.getUid());