diff --git a/appdata-sandbox.json b/appdata-sandbox.json old mode 100755 new mode 100644 index c4a062d5e42155fc15644a5495da48bb5ffb3a01..fbb0a01fdea2004f4a51893576f3eee1595c792c --- a/appdata-sandbox.json +++ b/appdata-sandbox.json @@ -909,13 +909,6 @@ "sandbox-flags" : [ "bind", "rec" ], "mount-shared-flag" : "true", "check-action-status": "true" - }, { - "src-path" : "/dev/fuse", - "sandbox-path" : "/mnt/data/fuse", - "sandbox-flags" : [ "MS_NOSUID", "MS_NODEV", "MS_NOEXEC", "MS_NOATIME", "MS_LAZYTIME" ], - "dac-override-sensitive": "true", - "fs-type": "fuse", - "check-action-status": "false" }, { "src-path" : "", "sandbox-path" : "", @@ -1080,5 +1073,60 @@ "gids":[1007], "mount-paths": [] }] + }], + "debug": [{ + "common":[{ + "mount-paths":[ + { + "src-path" : "/data/app/el1//base/", + "sandbox-path" : "/data/storage/el1/base", + "sandbox-flags": ["bind", "rec"], + "mount-shared-flag": "true", + "check-action-status": "false" + }, { + "src-path" : "/data/app/el1//database/", + "sandbox-path" : "/data/storage/el1/database", + "sandbox-flags": ["bind", "rec"], + "mount-shared-flag": "true", + "check-action-status": "false" + }, { + "src-path" : "/data/app/el2//base/", + "sandbox-path" : "/data/storage/el2/base", + "sandbox-flags": ["bind", "rec"], + "mount-shared-flag": "true", + "check-action-status": "false" + }, { + "src-path" : "/data/app/el2//database/", + "sandbox-path" : "/data/storage/el2/database", + "sandbox-flags": ["bind", "rec"], + "mount-shared-flag": "true", + "check-action-status": "false" + }, { + "src-path" : "/mnt/hmdfs//cloud/data/", + "sandbox-path" : "/data/storage/el2/cloud", + "sandbox-flags": ["bind", "rec"], + "mount-shared-flag": "true", + "check-action-status": "false" + } + ] + }], + "permission":[{ + "ohos.permission.PROTECT_SCREEN_LOCK_DATA":[{ + "mount-paths": [ + { + "src-path" : "/data/app/el5//base/", + "sandbox-path" : "/data/storage/el5/base", + "sandbox-flags": ["bind", "rec"], + "mount-shared-flag": "true", + "check-action-status": "false" + }, { + "src-path" : "/data/app/el5//database/", + "sandbox-path" : "/data/storage/el5/database", + "sandbox-flags": ["bind", "rec"], + "mount-shared-flag": "true", + "check-action-status": "false" + }] + }] + }] }] } diff --git a/appspawn.cfg b/appspawn.cfg index 989ab65f4fcbd0dc054b5d67a1081965fa15d955..9759e7e8feb970fdd3e59b74c7a842d5e3147d5f 100644 --- a/appspawn.cfg +++ b/appspawn.cfg @@ -17,9 +17,9 @@ "chown root appspawn /dev/pids", "chown root appspawn /dev/pids/tasks", "chown root appspawn /dev/pids/cgroup.procs", - "chmod 0750 /dev/pids", - "chmod 0750 /dev/pids/tasks", - "chmod 0750 /dev/pids/cgroup.procs" + "chmod 0755 /dev/pids", + "chmod 0755 /dev/pids/tasks", + "chmod 0755 /dev/pids/cgroup.procs" ] } ], diff --git a/common/appspawn_server.c b/common/appspawn_server.c index 2b7b2ceacbc0390fa0600a3ffa60646e6d5077b1..c1d41ccdeac2f043c1a4b22948406f7d47bc2024 100644 --- a/common/appspawn_server.c +++ b/common/appspawn_server.c @@ -37,9 +37,9 @@ static void NotifyResToParent(struct AppSpawnContent *content, AppSpawnClient *c { StartAppspawnTrace("NotifyResToParent"); APPSPAWN_LOGI("NotifyResToParent: %{public}d", result); - if (content->notifyResToParent != NULL) { - content->notifyResToParent(content, client, result); - } + APPSPAWN_CHECK(content != NULL && content->notifyResToParent != NULL, FinishAppspawnTrace(); + return, "invalid param"); + content->notifyResToParent(content, client, result); FinishAppspawnTrace(); } @@ -104,8 +104,9 @@ int AppSpawnChild(AppSpawnContent *content, AppSpawnClient *client) AppSpawnEnvClear(content, client); return 0); - // notify success to father process and start app process - NotifyResToParent(content, client, 0); + bool isAppspawn = (content->mode == MODE_FOR_APP_SPAWN || content->mode == MODE_FOR_APP_COLD_RUN); + APPSPAWN_CHECK_ONLY_EXPER(isAppspawn, + NotifyResToParent(content, client, 0)); StartAppspawnTrace("AppSpawnExecutePostReplyHook"); (void)AppSpawnExecutePostReplyHook(content, client); @@ -115,6 +116,8 @@ int AppSpawnChild(AppSpawnContent *content, AppSpawnClient *client) ret = content->runChildProcessor(content, client); } if (ret != 0) { + APPSPAWN_CHECK_ONLY_EXPER(!isAppspawn, + NotifyResToParent(content, client, ret)); AppSpawnEnvClear(content, client); } return 0; diff --git a/interfaces/innerkits/client/appspawn_msg.c b/interfaces/innerkits/client/appspawn_msg.c index ab871cb74511a8df717eca26a9f097ce7f0b49cb..3b7332af8b66328434d91375d25895f2c1ec5131 100644 --- a/interfaces/innerkits/client/appspawn_msg.c +++ b/interfaces/innerkits/client/appspawn_msg.c @@ -19,7 +19,7 @@ #include "appspawn_utils.h" #include "parameter.h" #include "securec.h" - +#define OHOS_PERMISSION_FOWNER "ohos.permission.FOWNER" static inline int CalcFlagsUnits(uint32_t maxIndex) { return ((maxIndex / 32) + ((maxIndex % 32 == 0) ? 0 : 1)); // 32 max bit in uint32_t @@ -552,10 +552,17 @@ int AppSpawnClientAddPermission(AppSpawnClientHandle handle, AppSpawnReqMsgHandl APPSPAWN_CHECK(permission != NULL, return APPSPAWN_ARG_INVALID, "Invalid permission "); APPSPAWN_CHECK(reqNode->permissionFlags != NULL, return APPSPAWN_ARG_INVALID, "No permission tlv "); + if (strcmp(permission, OHOS_PERMISSION_FOWNER) == 0) { + APPSPAWN_LOGI("AppSpawnClientAddPermission %{public}s", permission); + return AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_SET_CAPS_FOWNER); + } + +#ifdef APPSPAWN_SANDBOX_NEW // Don't need to transmit sandbox permission in nwebspawn mode if (reqMgr->type == CLIENT_FOR_NWEBSPAWN) { return 0; } +#endif int32_t maxIndex = GetMaxPermissionIndex(handle); int index = GetPermissionIndex(handle, permission); diff --git a/interfaces/innerkits/include/appspawn.h b/interfaces/innerkits/include/appspawn.h index 217363b04777759caf1ce254839894778dd5fd90..e9feda93d264c0030938a117aa16c600796121db 100644 --- a/interfaces/innerkits/include/appspawn.h +++ b/interfaces/innerkits/include/appspawn.h @@ -123,6 +123,7 @@ typedef enum { MSG_UNINSTALL_DEBUG_HAP, MSG_LOCK_STATUS, MSG_OBSERVE_PROCESS_SIGNAL_STATUS, + MSG_UNLOAD_WEBLIB_IN_APPSPAWN, MSG_LOAD_WEBLIB_IN_APPSPAWN, MAX_TYPE_INVALID } AppSpawnMsgType; diff --git a/modules/ace_adapter/ace_adapter.cpp b/modules/ace_adapter/ace_adapter.cpp index eb42eacd1db3f7b707767803ba364b6bf0438d4a..e4e95d24e4f3fee1f59ba3a38a26d5c61ce03b11 100644 --- a/modules/ace_adapter/ace_adapter.cpp +++ b/modules/ace_adapter/ace_adapter.cpp @@ -220,20 +220,39 @@ static int BuildFdInfoMap(const AppSpawnMsgNode *message, std::mapforkCtx.fd[1]; + property->forkCtx.fd[1] = -1; + AppSpawnEnvClear(content, client); + APPSPAWN_CHECK(fd >= 0, return, "invalid fd for notify parent"); + int ret = 0; + ssize_t written = write(fd, &ret, sizeof(ret)); + (void)close(fd); + APPSPAWN_LOGI("ClearEnvAndReturnSuccess %{public}zd", written); +} + APPSPAWN_STATIC int RunChildThread(const AppSpawnMgr *content, const AppSpawningCtx *property) { std::string checkExit; if (OHOS::system::GetBoolParameter("persist.init.debug.checkexit", true)) { checkExit = std::to_string(getpid()); } +#ifdef ARKWEB_UTILS_ENABLE + const char* bundleName = GetBundleName(property); + std::string bundleNameStr = (bundleName != NULL) ? std::string(bundleName) : ""; + OHOS::ArkWeb::SelectWebcoreBeforeProcessRun(bundleNameStr); +#endif setenv(APPSPAWN_CHECK_EXIT, checkExit.c_str(), true); if (CheckAppMsgFlagsSet(property, APP_FLAGS_CHILDPROCESS)) { std::map fdMap; BuildFdInfoMap(property->message, fdMap, IsColdRunMode(content)); - AppSpawnEnvClear((AppSpawnContent *)&content->content, (AppSpawnClient *)&property->client); + ClearEnvAndReturnSuccess((AppSpawnContent *)&content->content, (AppSpawnClient *)&property->client); OHOS::AppExecFwk::MainThread::StartChild(fdMap); } else { - AppSpawnEnvClear((AppSpawnContent *)&content->content, (AppSpawnClient *)&property->client); + ClearEnvAndReturnSuccess((AppSpawnContent *)&content->content, (AppSpawnClient *)&property->client); OHOS::AppExecFwk::MainThread::Start(); } unsetenv(APPSPAWN_CHECK_EXIT); @@ -265,7 +284,7 @@ APPSPAWN_STATIC int RunChildByRenderCmd(const AppSpawnMgr *content, const AppSpa } options.push_back(nullptr); // clear appspawn env, do not user any content and property - AppSpawnEnvClear((AppSpawnContent *)&content->content, (AppSpawnClient *)&property->client); + ClearEnvAndReturnSuccess((AppSpawnContent *)&content->content, (AppSpawnClient *)&property->client); execvp(args[0].c_str(), options.data()); // If it succeeds calling execvp, it never returns. int err = errno; diff --git a/modules/common/appspawn_begetctl.c b/modules/common/appspawn_begetctl.c index c813e83979b2d1aa58f34596168773158d4af2cc..3696bb8ffb15f38071f147ebdb5ee79abcb5b8b9 100755 --- a/modules/common/appspawn_begetctl.c +++ b/modules/common/appspawn_begetctl.c @@ -48,7 +48,7 @@ APPSPAWN_STATIC void RunAppSandbox(const char *ptyName) } APPSPAWN_CHECK(realPath != NULL, _exit(1), "Failed get realpath, err=%{public}d", errno); int n = strncmp(realPath, "/dev/pts/", strlen("/dev/pts/")); - APPSPAWN_CHECK(n == 0, free(realPath); _exit(1), "pts path %{public}s is invaild", realPath); + APPSPAWN_CHECK(n == 0, free(realPath); _exit(1), "pts path %{public}s is invalid", realPath); int fd = open(realPath, O_RDWR); free(realPath); APPSPAWN_CHECK(fd >= 0, _exit(1), "Failed open %{public}s, err=%{public}d", ptyName, errno); diff --git a/modules/common/appspawn_cgroup.c b/modules/common/appspawn_cgroup.c index eaf73279148cb2e762c7724d83895bf30b0c2dcb..4f6043a6b5df7e1eac1ac2f2a44df2b4249c78a6 100644 --- a/modules/common/appspawn_cgroup.c +++ b/modules/common/appspawn_cgroup.c @@ -151,7 +151,7 @@ APPSPAWN_STATIC int ProcessMgrAddApp(const AppSpawnMgr *content, const AppSpawne APPSPAWN_LOGV("ProcessMgrAddApp %{public}d %{public}d to cgroup ", appInfo->pid, appInfo->uid); int ret = GetCgroupPath(appInfo, path, sizeof(path)); APPSPAWN_CHECK(ret == 0, return -1, "Failed to get real path errno: %{public}d", errno); - (void)CreateSandboxDir(path, 0750); // 0750 default mode + (void)CreateSandboxDir(path, 0755); // 0755 default mode ret = strcat_s(path, sizeof(path), "cgroup.procs"); APPSPAWN_CHECK(ret == 0, return ret, "Failed to strcat_s errno: %{public}d", errno); ret = WriteToFile(path, 0, (pid_t *)&appInfo->pid, 1); diff --git a/modules/common/appspawn_common.c b/modules/common/appspawn_common.c index 901c06bbe1cf2ed6d3382ed948e70335a48ffc43..7c6095d776e9c7bed2e24c42a0d5ec0dcee0ad2f 100644 --- a/modules/common/appspawn_common.c +++ b/modules/common/appspawn_common.c @@ -137,7 +137,7 @@ static int SetAmbientCapabilities(const AppSpawningCtx *property) { const int caps[] = {CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH, CAP_FOWNER}; size_t capCount = sizeof(caps) / sizeof(caps[0]); - for (size_t i = 0;i < capCount; ++i) { + for (size_t i = 0; i < capCount; ++i) { if (SetAmbientCapability(caps[i]) != 0) { APPSPAWN_LOGE("set cap failed: %{public}d", caps[i]); return -1; @@ -160,7 +160,7 @@ APPSPAWN_STATIC int SetCapabilities(const AppSpawnMgr *content, const AppSpawnin capHeader.version = _LINUX_CAPABILITY_VERSION_3; capHeader.pid = 0; - struct __user_cap_data_struct capData[2]; // 2 is data number + struct __user_cap_data_struct capData[2]; isRet = memset_s(&capData, sizeof(capData), 0, sizeof(capData)) != EOK; APPSPAWN_CHECK(!isRet, return -EINVAL, "Failed to memset cap data"); @@ -195,10 +195,9 @@ APPSPAWN_STATIC int SetCapabilities(const AppSpawnMgr *content, const AppSpawnin capData[1].permitted = (__u32)(permitted >> BITLEN32); capData[0].effective = (__u32)(effective); capData[1].effective = (__u32)(effective >> BITLEN32); - - // set capabilities isRet = capset(&capHeader, &capData[0]) != 0; APPSPAWN_CHECK(!isRet, return -errno, "Failed to capset errno: %{public}d", errno); + #ifdef APPSPAWN_SUPPORT_NOSHAREFS if (!CheckAppMsgFlagsSet(property, APP_FLAGS_ISOLATED_SANDBOX_TYPE) && (IsAppSpawnMode(content) || IsNativeSpawnMode(content))) { @@ -558,7 +557,7 @@ APPSPAWN_STATIC int FilterAppSpawnTrace(AppSpawnMgr *content, AppSpawningCtx *pr APPSPAWN_LOGV("processName: %{public}s pid: %{public}d", processName, pid); FilterAppTrace(processName, pid); } else { - APPSPAWN_LOGV("processName is NULL"); + APPSPAWN_LOGI("processName is NULL"); } return 0; diff --git a/modules/common/appspawn_encaps.c b/modules/common/appspawn_encaps.c index 1d417e1debe68868270ade5ff5ce18fc44ffa96c..defceb6024569727376f1b851eebb07728177b82 100644 --- a/modules/common/appspawn_encaps.c +++ b/modules/common/appspawn_encaps.c @@ -77,7 +77,7 @@ APPSPAWN_STATIC int WriteEncapsInfo(int fd, AppSpawnEncapsBaseType encapsType, c break; } if (ret != 0) { - APPSPAWN_LOGE("Encaps the setup failed ret: %{public}d fd: %{public}d", ret, fd); + APPSPAWN_LOGE("Encaps the setup failed ret: %{public}d errno: %{public}d fd: %{public}d", ret, errno, fd); return ret; } return 0; @@ -126,17 +126,24 @@ APPSPAWN_STATIC int AddPermissionStrToValue(const char *valueStr, UserEncap *enc APPSPAWN_CHECK(valueStr != NULL, return APPSPAWN_ARG_INVALID, "Invalid string value"); uint32_t valueLen = strlen(valueStr) + 1; APPSPAWN_CHECK(valueLen > 1 && valueLen <= OH_ENCAPS_VALUE_MAX_LEN, return APPSPAWN_ARG_INVALID, - "String value len is invalied, len: %{public}u", valueLen); - char *value = (char *)calloc(1, valueLen); - APPSPAWN_CHECK(value != NULL, return APPSPAWN_SYSTEM_ERROR, "Failed to calloc value"); - - int ret = strcpy_s(value, valueLen, valueStr); - APPSPAWN_CHECK(ret == EOK, free(value); - return APPSPAWN_SYSTEM_ERROR, "Failed to copy string value"); - - encap->value.ptrValue = (void *)value; + "String value len is invalid, len: %{public}u", valueLen); + APPSPAWN_LOGV("valueStr:%{public}s", valueStr); + cJSON *valueJson = cJSON_Parse(valueStr); + APPSPAWN_CHECK(valueJson != NULL, return APPSPAWN_ERROR_UTILS_CREATE_JSON_FAIL, "Invalid valueStr"); + cJSON *firstItem = cJSON_GetArrayItem(valueJson, 0); + APPSPAWN_CHECK(firstItem != NULL && cJSON_IsString(firstItem), cJSON_Delete(valueJson); + return APPSPAWN_ARG_INVALID, "get first valueJson element failed"); + + const char *value = firstItem->valuestring; + valueLen = strlen(value) + 1; + APPSPAWN_LOGV("firstItem->valuestring:%{public}s", value); + + encap->value.ptrValue = (void *)strdup(value); + APPSPAWN_CHECK(encap->value.ptrValue != NULL, cJSON_Delete(valueJson); + return APPSPAWN_ERROR_UTILS_MEM_FAIL, "strdup value failed"); encap->valueLen = valueLen; encap->type = ENCAPS_CHAR_ARRAY; + cJSON_Delete(valueJson); return 0; } @@ -283,35 +290,40 @@ APPSPAWN_STATIC int AddPermissionItemToEncapsInfo(UserEncap *encap, cJSON *permi return 0; } -APPSPAWN_STATIC int AddMembersToEncapsInfo(cJSON *extInfoJson, UserEncaps *encapsInfo) +APPSPAWN_STATIC cJSON *GetEncapsPermissions(cJSON *extInfoJson, int *count) { + APPSPAWN_CHECK_LOGV(extInfoJson != NULL, return NULL, "Invalid extInfoJson"); + // Get ohos.encaps.count cJSON *countJson = cJSON_GetObjectItem(extInfoJson, APP_OHOS_ENCAPS_COUNT_KEY); - APPSPAWN_CHECK(countJson != NULL && cJSON_IsNumber(countJson), return APPSPAWN_ARG_INVALID, "Invalid countJson"); + APPSPAWN_CHECK(countJson != NULL && cJSON_IsNumber(countJson), return NULL, "Invalid countJson"); int encapsCount = countJson->valueint; // Check input count and permissions size cJSON *permissionsJson = cJSON_GetObjectItemCaseSensitive(extInfoJson, APP_OHOS_ENCAPS_PERMISSIONS_KEY); - APPSPAWN_CHECK(permissionsJson != NULL && cJSON_IsArray(permissionsJson), return APPSPAWN_ARG_INVALID, - "Invalid permissionsJson"); - int count = cJSON_GetArraySize(permissionsJson); - APPSPAWN_CHECK(count > 0 && count <= OH_ENCAPS_MAX_COUNT && encapsCount == count, return APPSPAWN_ARG_INVALID, - "Invalid args, encaps count: %{public}d, permission count: %{public}d", encapsCount, count); + APPSPAWN_CHECK(permissionsJson != NULL && cJSON_IsArray(permissionsJson), return NULL, "Invalid permissionsJson"); + *count = cJSON_GetArraySize(permissionsJson); + APPSPAWN_CHECK((*count) > 0 && (*count) <= OH_ENCAPS_MAX_COUNT && encapsCount == (*count), *count = 0; + return NULL, "Invalid args, encaps count: %{public}d, permission count: %{public}d", encapsCount, *count); - encapsInfo->encap = (UserEncap *)calloc(count + 1, sizeof(UserEncap)); - APPSPAWN_CHECK(encapsInfo->encap != NULL, return APPSPAWN_SYSTEM_ERROR, "Failed to calloc encap"); + return permissionsJson; +} + +APPSPAWN_STATIC int AddMembersToEncapsInfo(cJSON *permissionsJson, UserEncaps *encapsInfo, int count) +{ + APPSPAWN_CHECK_LOGV(permissionsJson != NULL, return 0, "Encaps not contains valid permissionsJson"); for (int i = 0; i < count; i++) { cJSON *permission = cJSON_GetArrayItem(permissionsJson, i); APPSPAWN_CHECK(permission != NULL, return APPSPAWN_ERROR_UTILS_DECODE_JSON_FAIL, - "Encaps get single permission failed") + "Encaps get single permission failed index %{public}d", i); cJSON *permissionItem = permission->child; APPSPAWN_CHECK(permissionItem != NULL, return APPSPAWN_ERROR_UTILS_DECODE_JSON_FAIL, - "Encaps get permission item failed") + "Encaps get permission item failed index %{public}d", i); if (AddPermissionItemToEncapsInfo(&encapsInfo->encap[i], permissionItem) != 0) { - APPSPAWN_LOGE("Add permission to encap failed"); + APPSPAWN_LOGE("Add permission to encap failed index %{public}d", i); return APPSPAWN_ERROR_UTILS_ADD_JSON_FAIL; } encapsInfo->encapsCount++; @@ -344,7 +356,7 @@ static int SpawnSetMaxPids(AppSpawningCtx *property, UserEncaps *encapsInfo) maxPidCount = SpawnGetMaxPids(property); } - APPSPAWN_CHECK(maxPidCount > 0 && maxPidCount < OH_APP_MAX_PIDS_NUM, return 0, + APPSPAWN_CHECK_LOGV(maxPidCount > 0 && maxPidCount < OH_APP_MAX_PIDS_NUM, return 0, "Don't need to set pid max count %{public}u. Use default pid max", maxPidCount); APPSPAWN_CHECK(encapsInfo->encapsCount < OH_ENCAPS_MAX_COUNT, return APPSPAWN_ARG_INVALID, "Encaps count is more than 64, cannot set permissions"); @@ -357,31 +369,35 @@ static int SpawnSetMaxPids(AppSpawningCtx *property, UserEncaps *encapsInfo) encapsInfo->encap[count].valueLen = sizeof(maxPidCount); encapsInfo->encap[count].type = ENCAPS_INT; encapsInfo->encapsCount++; + APPSPAWN_LOGV("Set max fork count: %{public}u, encapsCount: %{public}u", maxPidCount, encapsInfo->encapsCount); return 0; } APPSPAWN_STATIC int SpawnSetPermissions(AppSpawningCtx *property, UserEncaps *encapsInfo) { // Get Permissions obejct + int count = 0; cJSON *extInfoJson = GetJsonObjFromExtInfo(property, MSG_EXT_NAME_JIT_PERMISSIONS); - if (extInfoJson == NULL) { - APPSPAWN_LOGV("GetJsonObjFromExtInfo failed"); - return APPSPAWN_ARG_INVALID; - } + cJSON *permissionsJson = GetEncapsPermissions(extInfoJson, &count); + APPSPAWN_CHECK_LOGW(count >= 0 && count <= OH_ENCAPS_MAX_COUNT, count = 0, "Invalid count: %{public}d", count); - int ret = AddMembersToEncapsInfo(extInfoJson, encapsInfo); - if (ret != 0) { - APPSPAWN_LOGW("Add member to encaps failed, ret: %{public}d", ret); - cJSON_Delete(extInfoJson); - return ret; - } + int ret = 0; + do { + encapsInfo->encap = (UserEncap *)calloc(count + 1, sizeof(UserEncap)); + APPSPAWN_CHECK(encapsInfo->encap != NULL, ret = APPSPAWN_SYSTEM_ERROR; + break, "Failed to calloc encap"); + + ret = AddMembersToEncapsInfo(permissionsJson, encapsInfo, count); + if (ret != 0) { + APPSPAWN_LOGW("Add member to encaps failed, ret: %{public}d", ret); + } - ret = SpawnSetMaxPids(property, encapsInfo); - APPSPAWN_CHECK(ret == 0, cJSON_Delete(extInfoJson); - return ret, "Set max pids count to encaps failed"); + ret = SpawnSetMaxPids(property, encapsInfo); + APPSPAWN_CHECK(ret == 0, break, "Set max fork count to encaps failed, ret: %{public}d", ret); + } while (0); - cJSON_Delete(extInfoJson); - return 0; + APPSPAWN_ONLY_EXPER(extInfoJson != NULL, cJSON_Delete(extInfoJson)); + return ret; } APPSPAWN_STATIC int SpawnSetEncapsPermissions(AppSpawnMgr *content, AppSpawningCtx *property) @@ -415,8 +431,10 @@ APPSPAWN_STATIC int SpawnSetEncapsPermissions(AppSpawnMgr *content, AppSpawningC return 0; // Can't set permission encpas ability } - (void)WriteEncapsInfo(encapsFileFd, ENCAPS_PERMISSION_TYPE_MODE, &encapsInfo, OH_ENCAPS_DEFAULT_FLAG); - APPSPAWN_LOGV("Set encaps info finish"); + if (encapsInfo.encapsCount > 0) { + (void)WriteEncapsInfo(encapsFileFd, ENCAPS_PERMISSION_TYPE_MODE, &encapsInfo, OH_ENCAPS_DEFAULT_FLAG); + APPSPAWN_LOGV("Set encaps info finish, encapsCount: %{public}u", encapsInfo.encapsCount); + } FreeEncapsInfo(&encapsInfo); close(encapsFileFd); diff --git a/modules/common/appspawn_silk.c b/modules/common/appspawn_silk.c index 2f8d9141062478031e78286e85cd0aede4c30a75..c5e61d37d03582d75a58f30797b2dd0eb746e66f 100644 --- a/modules/common/appspawn_silk.c +++ b/modules/common/appspawn_silk.c @@ -110,7 +110,7 @@ APPSPAWN_STATIC bool ParseSilkConfig(const cJSON *root, struct SilkConfig *confi void LoadSilkConfig(void) { cJSON *root = GetJsonObjFromFile(SILK_JSON_CONFIG_PATH); - APPSPAWN_CHECK(root != NULL, return, "Failed to load silk config"); + APPSPAWN_CHECK_LOGV(root != NULL, return, "Failed to load silk config"); (void)ParseSilkConfig(root, &g_silkConfig); cJSON_Delete(root); } diff --git a/modules/native_adapter/BUILD.gn b/modules/native_adapter/BUILD.gn index e1819d51fbe798ea590241931008e3b239d39b84..c5fd69d70b70de5f5bbde852db52369a9965fecb 100644 --- a/modules/native_adapter/BUILD.gn +++ b/modules/native_adapter/BUILD.gn @@ -39,6 +39,7 @@ ohos_shared_library("nativespawn") { "hilog:libhilog", "init:libbegetutil", "napi:ace_napi", + "ipc:ipc_single", ] if (!defined(APPSPAWN_TEST)) { external_deps += [ "common_event_service:cesfwk_innerkits" ] diff --git a/modules/nweb_adapter/nwebspawn_adapter.cpp b/modules/nweb_adapter/nwebspawn_adapter.cpp index f2238082fa943da0c44eced96bd983c843d5323e..e520dd3e391effa416a782c9f15580b8e95eb959 100644 --- a/modules/nweb_adapter/nwebspawn_adapter.cpp +++ b/modules/nweb_adapter/nwebspawn_adapter.cpp @@ -86,7 +86,7 @@ static void UpdateAppWebEngineVersion(std::string& renderCmd) return; } auto version = static_cast(v); - OHOS::ArkWeb::setActiveWebEngineVersion(version); + OHOS::ArkWeb::SetActiveWebEngineVersionInner(version); // remove arg APP_ENGINE_VERSION_PREFIX size_t eraseLength = (posEnd == std::string::npos) ? diff --git a/modules/sandbox/modern/sandbox_debug_mode.c b/modules/sandbox/modern/sandbox_debug_mode.c index 7953b34a3d3aa1f11f815fa68a63aa9673be0c4b..54b9b9456875d7600aa0b71d9c4e5a9419be2875 100644 --- a/modules/sandbox/modern/sandbox_debug_mode.c +++ b/modules/sandbox/modern/sandbox_debug_mode.c @@ -384,7 +384,7 @@ static int MountDebugDirBySharefs(const SandboxContext *context, const AppSpawnS return 0; } -static int InstallDebugSandbox(AppSpawnMgr *content, AppSpawningCtx *property) +APPSPAWN_STATIC int InstallDebugSandbox(AppSpawnMgr *content, AppSpawningCtx *property) { APPSPAWN_CHECK(property != NULL && content != NULL, return APPSPAWN_ARG_INVALID, "Invalid appspawn client or property"); @@ -410,6 +410,8 @@ static int InstallDebugSandbox(AppSpawnMgr *content, AppSpawningCtx *property) APPSPAWN_CHECK_ONLY_EXPER(ret == 0, DeleteSandboxContext(&context); return ret); + APPSPAWN_LOGI("Set sandbox config %{public}s sandboxNsFlags 0x%{public}x", + context->rootPath, context->sandboxNsFlags); do { ret = MountDebugTmpConfig(context, sandboxCfg); APPSPAWN_CHECK_ONLY_EXPER(ret == 0, break); diff --git a/modules/sandbox/normal/sandbox_common.cpp b/modules/sandbox/normal/sandbox_common.cpp index 9eca40fcceac87c6e97377e583ce1b45db680cfa..0503c71acc67f50612debf0c734b31d0dc70fe37 100644 --- a/modules/sandbox/normal/sandbox_common.cpp +++ b/modules/sandbox/normal/sandbox_common.cpp @@ -160,7 +160,7 @@ int SandboxCommon::LoadAppSandboxConfigCJson(AppSpawnMgr *content) std::string isolatedPath = path + SandboxCommonDef::APP_ISOLATED_JSON_CONFIG; APPSPAWN_LOGI("LoadAppSandboxConfig %{public}s", isolatedPath.c_str()); sandboxCJsonRoot = GetJsonObjFromFile(isolatedPath.c_str()); - APPSPAWN_CHECK((sandboxCJsonRoot != nullptr && cJSON_IsObject(sandboxCJsonRoot)), continue, + APPSPAWN_CHECK_LOGW((sandboxCJsonRoot != nullptr && cJSON_IsObject(sandboxCJsonRoot)), continue, "Failed to load app data sandbox config %{public}s", isolatedPath.c_str()); StoreCJsonConfig(sandboxCJsonRoot, SandboxCommonDef::SANDBOX_ISOLATED_JSON_CONFIG); } @@ -507,8 +507,13 @@ bool SandboxCommon::IsCreateSandboxPathEnabled(cJSON *json, std::string srcPath) bool SandboxCommon::IsTotalSandboxEnabled(const AppSpawningCtx *appProperty) // CheckTotalSandboxSwitchStatus { - SandboxCommonDef::SandboxConfigType type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ? - SandboxCommonDef::SANDBOX_ISOLATED_JSON_CONFIG : SandboxCommonDef::SANDBOX_APP_JSON_CONFIG; + SandboxCommonDef::SandboxConfigType type; + if (appProperty == nullptr) { + type = SandboxCommonDef::SANDBOX_APP_JSON_CONFIG; + } else { + type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ? + SandboxCommonDef::SANDBOX_ISOLATED_JSON_CONFIG : SandboxCommonDef::SANDBOX_APP_JSON_CONFIG; + } for (auto& wholeConfig : GetCJsonConfig(type)) { // 获取 "common" 数组 @@ -900,9 +905,8 @@ std::string SandboxCommon::ConvertToRealPathWithPermission(const AppSpawningCtx AppSpawnMsgBundleInfo *info = reinterpret_cast(GetAppProperty(appProperty, TLV_BUNDLE_INFO)); AppSpawnMsgDacInfo *dacInfo = reinterpret_cast(GetAppProperty(appProperty, TLV_DAC_INFO)); - if (info == nullptr || dacInfo == nullptr) { - return ""; - } + APPSPAWN_CHECK((info != nullptr && dacInfo != nullptr), return "", "Invalid params"); + if (path.find(SandboxCommonDef::g_packageNameIndex) != std::string::npos) { std::string bundleNameWithIndex = info->bundleName; if (info->bundleIndex != 0) { diff --git a/modules/sandbox/normal/sandbox_core.cpp b/modules/sandbox/normal/sandbox_core.cpp index 524053a7d7bc984afe5f3965d20d1475c18c9704..ea47460d33e899971584fded47015ee6a65c0f25 100644 --- a/modules/sandbox/normal/sandbox_core.cpp +++ b/modules/sandbox/normal/sandbox_core.cpp @@ -150,63 +150,56 @@ std::string SandboxCore::GetSandboxPath(const AppSpawningCtx *appProperty, cJSON return sandboxPath; } -int32_t SandboxCore::DoDlpAppMountStrategy(const AppSpawningCtx *appProperty, const std::string &srcPath, - const std::string &sandboxPath, const std::string &fsType, unsigned long mountFlags) +int32_t SandboxCore::HandleDlpMount(const AppSpawnMsgDacInfo *dacInfo) { - AppSpawnMsgDacInfo *dacInfo = reinterpret_cast(GetAppProperty(appProperty, TLV_DAC_INFO)); - if (dacInfo == nullptr) { - return -1; - } - + std::string fusePath = "/mnt/data/" + std::to_string(dacInfo->uid / UID_BASE) + "/fuse"; // umount fuse path, make sure that sandbox path is not a mount point - umount2(sandboxPath.c_str(), MNT_DETACH); + umount2(fusePath.c_str(), MNT_DETACH); + + int32_t ret = SandboxCommon::CreateDirRecursive(fusePath, SandboxCommonDef::FILE_MODE); + APPSPAWN_CHECK(ret == 0, return APPSPAWN_SANDBOX_ERROR_MKDIR_FAIL, + "Create sandbox path failed, errno is %{public}d", errno); int fd = open("/dev/fuse", O_RDWR); - APPSPAWN_CHECK(fd != -1, return -EINVAL, "open /dev/fuse failed, errno is %{public}d", errno); + APPSPAWN_CHECK(fd > 0, return -EINVAL, "Open /dev/fuse failed, errno is %{public}d", errno); char options[SandboxCommonDef::OPTIONS_MAX_LEN]; - (void)sprintf_s(options, sizeof(options), "fd=%d," - "rootmode=40000,user_id=%u,group_id=%u,allow_other," - "context=\"u:object_r:dlp_fuse_file:s0\"," - "fscontext=u:object_r:dlp_fuse_file:s0", - fd, dacInfo->uid, dacInfo->gid); - - // To make sure destinationPath exist - (void)SandboxCommon::CreateDirRecursive(sandboxPath, SandboxCommonDef::FILE_MODE); + ret = sprintf_s(options, sizeof(options), "fd=%d," + "rootmode=40000,user_id=%u,group_id=%u,allow_other," + "context=\"u:object_r:dlp_fuse_file:s0\"," + "fscontext=u:object_r:dlp_fuse_file:s0", + fd, dacInfo->uid, dacInfo->gid); + APPSPAWN_CHECK(ret >= 0, close(fd); + return APPSPAWN_ERROR_UTILS_MEM_FAIL, "Make mount fuse option failed, errno is %{public}d", errno); #ifndef APPSPAWN_TEST - APPSPAWN_LOGV("Bind mount %{public}s to %{public}s '%{public}s' '%{public}lu' '%{public}s'", - srcPath.c_str(), sandboxPath.c_str(), fsType.c_str(), mountFlags, options); - int ret = mount(srcPath.c_str(), sandboxPath.c_str(), fsType.c_str(), mountFlags, options); + ret = mount("/dev/fuse", fusePath.c_str(), "fuse", + MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME | MS_LAZYTIME, options); APPSPAWN_CHECK(ret == 0, close(fd); - return ret, "DoDlpAppMountStrategy failed, bind mount %{public}s to %{public}s failed %{public}d", - srcPath.c_str(), sandboxPath.c_str(), errno); - - ret = mount(nullptr, sandboxPath.c_str(), nullptr, MS_SHARED, nullptr); + return ret, "Mount fuse failed %{public}s, errno: %{public}d", fusePath.c_str(), errno); + ret = mount(nullptr, fusePath.c_str(), nullptr, MS_SHARED, nullptr); APPSPAWN_CHECK(ret == 0, close(fd); - return ret, "errno is: %{public}d, private mount to %{public}s failed", errno, sandboxPath.c_str()); + return ret, "Shared mount %{public}s, errno: %{public}d", fusePath.c_str(), errno); #endif + /* set DLP_FUSE_FD */ #ifdef WITH_DLP SetDlpFuseFd(fd); #endif - return fd; + return 0; } -int32_t SandboxCore::HandleSpecialAppMount(const AppSpawningCtx *appProperty, const std::string &srcPath, - const std::string &sandboxPath, const std::string &fsType, unsigned long mountFlags) +bool SandboxCore::CheckDlpMount(const AppSpawningCtx *appProperty) { std::string bundleName = GetBundleName(appProperty); std::string processName = GetProcessName(appProperty); /* dlp application mount strategy */ /* dlp is an example, we should change to real bundle name later */ - if (bundleName.find(SandboxCommonDef::g_dlpBundleName) != std::string::npos && - processName.compare(SandboxCommonDef::g_dlpBundleName) == 0) { - if (!fsType.empty()) { - return DoDlpAppMountStrategy(appProperty, srcPath, sandboxPath, fsType, mountFlags); - } + if (!(bundleName.find(SandboxCommonDef::g_dlpBundleName) != std::string::npos && + processName.compare(SandboxCommonDef::g_dlpBundleName) == 0)) { + return false; } - return -1; + return true; } cJSON *SandboxCore::GetPrivateJsonInfo(const AppSpawningCtx *appProperty, cJSON *wholeConfig) @@ -554,11 +547,7 @@ int32_t SandboxCore::ProcessMountPoint(cJSON *mntPoint, MountPointProcessParams GetBoolValueFromJsonObj(mntPoint, SandboxCommonDef::g_mountSharedFlag, false) ? MS_SHARED : MS_SLAVE }; - /* if app mount failed for special strategy, we need deal with common mount config */ - int ret = HandleSpecialAppMount(params.appProperty, arg.srcPath, arg.destPath, arg.fsType, arg.mountFlags); - if (ret < 0) { - ret = SandboxCommon::DoAppSandboxMountOnce(params.appProperty, &arg); - } + int ret = SandboxCommon::DoAppSandboxMountOnce(params.appProperty, &arg); APPSPAWN_CHECK(ret == 0 || !SandboxCommon::IsMountSuccessful(mntPoint), #ifdef APPSPAWN_HISYSEVENT ReportMountFail(params.bundleName.c_str(), arg.srcPath, arg.destPath, errno); @@ -913,20 +902,23 @@ int32_t SandboxCore::SetSandboxProperty(AppSpawningCtx *appProperty, std::string int32_t SandboxCore::SetAppSandboxProperty(AppSpawningCtx *appProperty, uint32_t sandboxNsFlags) { - APPSPAWN_CHECK(appProperty != nullptr, return -1, "Invalid appspawn client"); - if (SandboxCommon::CheckBundleName(GetBundleName(appProperty)) != 0) { - return -1; + APPSPAWN_CHECK(appProperty != nullptr, return APPSPAWN_SANDBOX_INVALID, "Invalid appspawn client"); + const std::string bundleName = GetBundleName(appProperty); + if (SandboxCommon::CheckBundleName(bundleName) != 0) { + return APPSPAWN_SANDBOX_INVALID; } AppSpawnMsgDacInfo *dacInfo = reinterpret_cast(GetAppProperty(appProperty, TLV_DAC_INFO)); - APPSPAWN_CHECK(dacInfo != nullptr, return -1, "No dac info in msg app property"); + APPSPAWN_CHECK(dacInfo != nullptr, return APPSPAWN_SANDBOX_INVALID, "No dac info in msg app property"); - const std::string bundleName = GetBundleName(appProperty); - cJSON *tmpJson = nullptr; - std::string sandboxPackagePath = SandboxCommon::GetSandboxRootPath(appProperty, tmpJson); + std::string sandboxPackagePath = SandboxCommon::GetSandboxRootPath(appProperty, nullptr); SandboxCommon::CreateDirRecursiveWithClock(sandboxPackagePath.c_str(), SandboxCommonDef::FILE_MODE); - bool sandboxSharedStatus = SandboxCommon::IsPrivateSharedStatus(bundleName, appProperty) || - (CheckAppPermissionFlagSet(appProperty, static_cast(GetPermissionIndex(nullptr, - SandboxCommonDef::ACCESS_DLP_FILE_MODE.c_str()))) != 0); + + bool dlpStatus = (CheckAppPermissionFlagSet(appProperty, + static_cast(GetPermissionIndex(nullptr, SandboxCommonDef::ACCESS_DLP_FILE_MODE.c_str()))) != 0); + if (dlpStatus && CheckDlpMount(appProperty)) { + int ret = HandleDlpMount(dacInfo); + APPSPAWN_CHECK_ONLY_LOG(ret == 0, "Handle dlp mount failed"); + } // add pid to a new mnt namespace StartAppspawnTrace("EnableSandboxNamespace"); @@ -940,7 +932,7 @@ int32_t SandboxCore::SetAppSandboxProperty(AppSpawningCtx *appProperty, uint32_t // check app sandbox switch if (!SandboxCommon::IsTotalSandboxEnabled(appProperty) || !SandboxCommon::IsAppSandboxEnabled(appProperty)) { rc = DoSandboxRootFolderCreateAdapt(sandboxPackagePath); - } else if (!sandboxSharedStatus) { + } else { rc = DoSandboxRootFolderCreate(appProperty, sandboxPackagePath); } APPSPAWN_CHECK(rc == 0, return rc, "DoSandboxRootFolderCreate failed, %{public}s", bundleName.c_str()); @@ -953,7 +945,7 @@ int32_t SandboxCore::SetAppSandboxProperty(AppSpawningCtx *appProperty, uint32_t #ifndef APPSPAWN_TEST StartAppspawnTrace("ChangeCurrentDir"); - rc = ChangeCurrentDir(sandboxPackagePath, bundleName, sandboxSharedStatus); + rc = ChangeCurrentDir(sandboxPackagePath, bundleName, false); FinishAppspawnTrace(); APPSPAWN_CHECK(rc == 0, return rc, "change current dir failed"); APPSPAWN_LOGV("Change root dir success"); @@ -1040,7 +1032,7 @@ int32_t SandboxCore::SetAppSandboxPropertyNweb(AppSpawningCtx *appProperty, uint } APPSPAWN_CHECK(rc == 0, return rc, "DoSandboxRootFolderCreate failed, %{public}s", bundleName.c_str()); - // rendering process can be created by different apps, and the bundle names of these apps are different + // rendering process can be created by different apps, and the bundle names of these apps are different, // so we can't use the method SetPrivateAppSandboxProperty which mount dirs by using bundle name. rc = SetRenderSandboxPropertyNweb(appProperty, sandboxPackagePath); APPSPAWN_CHECK(rc == 0, return rc, "SetRenderSandboxPropertyNweb for %{public}s failed", bundleName.c_str()); diff --git a/modules/sandbox/normal/sandbox_core.h b/modules/sandbox/normal/sandbox_core.h index 1461b6fb81e5b74a52cc86f628221682d52813d5..8758e863c111e6c4d44b49d976bee245af39e4ea 100644 --- a/modules/sandbox/normal/sandbox_core.h +++ b/modules/sandbox/normal/sandbox_core.h @@ -85,10 +85,8 @@ private: static cJSON *GetFirstSubConfig(cJSON *parent, const char *key); // 处理dlpmanager挂载 - static int32_t DoDlpAppMountStrategy(const AppSpawningCtx *appProperty, const std::string &srcPath, - const std::string &sandboxPath, const std::string &fsType, unsigned long mountFlags); - static int32_t HandleSpecialAppMount(const AppSpawningCtx *appProperty, const std::string &srcPath, - const std::string &sandboxPath, const std::string &fsType, unsigned long mountFlags); + static int32_t HandleDlpMount(const AppSpawnMsgDacInfo *dacInfo); + static bool CheckDlpMount(const AppSpawningCtx *appProperty); // 处理应用私有挂载 static cJSON *GetPrivateJsonInfo(const AppSpawningCtx *appProperty, cJSON *wholeConfig); diff --git a/modules/sandbox/normal/sandbox_shared_mount.cpp b/modules/sandbox/normal/sandbox_shared_mount.cpp index e168faa5885cf710a9587ecfc827a0cfd9e53538..860af6a2937e6bff5a7b84e27533a42eda827de8 100644 --- a/modules/sandbox/normal/sandbox_shared_mount.cpp +++ b/modules/sandbox/normal/sandbox_shared_mount.cpp @@ -303,8 +303,15 @@ static int MountWithOther(const AppSpawningCtx *property, const AppDacInfo *info return APPSPAWN_ERROR_UTILS_MEM_FAIL; } #ifdef APPSPAWN_SUPPORT_NOSHAREFS + char nosharefsDocsDir[PATH_MAX_LEN] = {0}; + ret = snprintf_s(nosharefsDocsDir, PATH_MAX_LEN, PATH_MAX_LEN - 1, "/mnt/user/%u/nosharefs/docs", + info->uid / UID_BASE); + if (ret <= 0) { + APPSPAWN_LOGE("snprintf nosharefsDocsDir failed, errno %{public}d", errno); + return APPSPAWN_ERROR_UTILS_MEM_FAIL; + } SharedMountArgs arg = { - .srcPath = sharefsDocsDir, + .srcPath = nosharefsDocsDir, .destPath = storageUserPath, .fsType = nullptr, .mountFlags = MS_BIND | MS_REC, diff --git a/modules/sandbox/sandbox_dec.c b/modules/sandbox/sandbox_dec.c index 8e36ea2e4113757d97e0ab797eb7b2e865b14136..72c0d4f8ecc49ec8ae99545226d0338456ce4c48 100644 --- a/modules/sandbox/sandbox_dec.c +++ b/modules/sandbox/sandbox_dec.c @@ -21,6 +21,7 @@ #include #include "appspawn_utils.h" #include "appspawn_hook.h" +#include "appspawn_manager.h" static const char *g_decConstraintDir[] = { "/storage/Users", @@ -106,7 +107,7 @@ static int SetDenyConstraintDirs(AppSpawnMgr *content) const char *decFilename = "/dev/dec"; int fd = open(decFilename, O_RDWR); if (fd < 0) { - APPSPAWN_LOGE("open dec file fail."); + APPSPAWN_CHECK_ONLY_LOG(IsNativeSpawnMode(content) != 0, "open dec file fail."); return 0; } @@ -140,7 +141,7 @@ static int SetForcedPrefixDirs(AppSpawnMgr *content) const char *decFilename = "/dev/dec"; int fd = open(decFilename, O_RDWR); if (fd < 0) { - APPSPAWN_LOGE("open dec file fail."); + APPSPAWN_CHECK_ONLY_LOG(IsNativeSpawnMode(content) != 0, "open dec file fail."); return 0; } diff --git a/service/hnp/README_zh.md b/service/hnp/README_zh.md index 01e1188333db02c737ccd54026a0920ceeef4550..5ad862a3d0428d582a1d3e0a410687e728017019 100644 --- a/service/hnp/README_zh.md +++ b/service/hnp/README_zh.md @@ -59,8 +59,7 @@ hnp目录准备完成后,参考第4步在hap打包命令中用--hnp-path指定 2. 公有hnp包根路径的环境变量HNP_PUBLIC_HOME=/data/service/hnp,私有hnp包根路径的环境变量HNP_PRIVATE_HOME=/data/app。HNP_PRIVATE_HOME环境变量排序在HNP_PUBLIC_HOME前面,意味着如果存在同名二进制分别在公有hnp路径下和私有hnp路径下,优先执行私有hnp路径下二进制。 3. 公有hnp包可以被所有应用访问,私有hnp包只允许被安装该hnp包的hap应用访问。 4. 卸载hap应用会同步卸载该hap应用安装的所有hnp包,如果该hnp包中二进制正在被其他应用使用,则会导致hap应用卸载失败。 -5. Hap应用A和B安装相同公有hnp包(hnp.json文件中"name"和"version"字段相同)。后安装的应用会跳过该hnp包的安装。仅当hap应用A和B都被卸载时,该公有hnp包会被卸载。 -6. Hap应用A和B安装先后安装同名公有hnp包(hnp.json文件中"name"相同,但是"version"字段不同),则会尝试先卸载Hap应用A的hnp包,再安装Hap应用B的hnp包,如果Hap应用A的hnp包卸载失败会导致Hap应用B安装失败。 +5. Hap应用A和B安装先后安装同名公有hnp包(hnp.json文件中"name")。后安装的应B用会无法安装,需要卸载hap应用A或者将应用B中的公有hnp修改为私有hnp方可继续安装。 #### 2.1.3 hap包签名流程 diff --git a/service/hnp/installer/README_zh.md b/service/hnp/installer/README_zh.md index d06cda79743d787cb9f67e135deb054bc92611ad..182f31e2b3d15b51bf246a5b378208e55d0fafbb 100644 --- a/service/hnp/installer/README_zh.md +++ b/service/hnp/installer/README_zh.md @@ -136,10 +136,11 @@ a. 安装时发现已经有同款软件相同版本则跳过安装,返回安 b. 非强制安装模式下,安装时发现已经有同款软件不同版本会安装失败。 -b. 强制安装会将已安装的软件先卸载掉之后再安装当前新的软件。 +c. 强制安装会将已安装的软件先卸载掉之后再安装当前新的软件。 -c. 批量安装应用的hnp软件时如果中间安装出错,则直接退出安装流程返回,之前已安装的软件继续保留。 +d. 批量安装应用的hnp软件时如果中间安装出错,则直接退出安装流程返回,之前已安装的软件继续保留。 +e. 在安装公共HNP时,若新HNP的名称(hnp.json 中的 "name" 字段)与设备已存在HNP相同,或新HNP的软链接(hnp.json 中 links 下的 "target" 字段,若未配置则默认指向 HNP 包bin 目录下的文件)与已有软链接相同,则仅原有HNP对应的HAP可正常操作,其他HAP应用的安装将会失败。此时,卸载原HAP与HNP后,可尝试重新安装HNP。 3) 接口调用安装: diff --git a/standard/appspawn_kickdog.c b/standard/appspawn_kickdog.c index ef01677b8802e50df7c776abfa727d1e3bfed14c..600ac39590372ddba31bd5e6345abaf03479cacb 100644 --- a/standard/appspawn_kickdog.c +++ b/standard/appspawn_kickdog.c @@ -127,6 +127,7 @@ static int CheckKernelType(bool *isLinux) APPSPAWN_STATIC int SpawnKickDogStart(AppSpawnMgr *mgrContent) { APPSPAWN_CHECK(mgrContent != NULL, return 0, "content is null"); + APPSPAWN_CHECK_ONLY_EXPER(mgrContent->content.mode != MODE_FOR_NATIVE_SPAWN, return 0); APPSPAWN_CHECK((mgrContent->content.mode == MODE_FOR_APP_SPAWN) || (mgrContent->content.mode == MODE_FOR_NWEB_SPAWN) || (mgrContent->content.mode == MODE_FOR_HYBRID_SPAWN), return 0, "Mode %{public}u no need enable watchdog", mgrContent->content.mode); diff --git a/standard/appspawn_main.c b/standard/appspawn_main.c index ac4f7da8a7256a09e657bb61035d9222a2f825c1..bed93f4d47b12ee2e0017711ebee1234571addf8 100644 --- a/standard/appspawn_main.c +++ b/standard/appspawn_main.c @@ -73,8 +73,11 @@ static void CheckPreload(char *const argv[]) ssize_t nread = readlink("/proc/self/exe", buf, sizeof(buf) - 1); APPSPAWN_CHECK(nread != -1, return, "readlink fail: /proc/self/exe: %{public}d", errno); buf[nread] = 0; - ret = execv(buf, argv); - APPSPAWN_LOGE("execv fail: %{public}s: %{public}d: %{public}d", buf, errno, ret); + int result = strcmp(buf, "/system/bin/nativespawn"); + if (result != 0) { + ret = execv(buf, argv); + APPSPAWN_LOGE("execv fail: %{public}s: %{public}d: %{public}d", buf, errno, ret); + } } #ifndef NATIVE_SPAWN diff --git a/standard/appspawn_service.c b/standard/appspawn_service.c index 8a0a598931cb40ce3b9c529320b81ae0aa879681..51eeec66540926ef9b7cc94bdb8d9743cda96ca9 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -65,6 +65,11 @@ #define PIDFD_NONBLOCK O_NONBLOCK #endif +#if (defined(PRE_DLOPEN_ARKWEB_LIB) && !defined(ASAN_DETECTOR)) +#define MAX_DLCLOSE_COUNT 10 +#define LIB_ARKWEB_ENGINE "libarkweb_engine.so" +#endif + static void WaitChildTimeout(const TimerHandle taskHandle, void *context); static void ProcessChildResponse(const WatcherHandle taskHandle, int fd, uint32_t *events, const void *context); static void WaitChildDied(pid_t pid); @@ -441,8 +446,7 @@ static void OnReceiveRequest(const TaskHandle taskHandle, const uint8_t *buffer, connection->receiverCtx.incompleteMsg = NULL; int ret = 0; do { - APPSPAWN_LOGI("connectionId:%{public}u buffLen:%{public}d", - connection->connectionId, buffLen - currLen); + APPSPAWN_LOGI("connectionId:%{public}u buffLen:%{public}d", connection->connectionId, buffLen - currLen); ret = GetAppSpawnMsgFromBuffer(buffer + currLen, buffLen - currLen, &message, &connection->receiverCtx.msgRecvLen, &reminder); @@ -1115,6 +1119,7 @@ static void ProcessChildResponse(const WatcherHandle taskHandle, int fd, uint32_ static void NotifyResToParent(AppSpawnContent *content, AppSpawnClient *client, int result) { AppSpawningCtx *property = (AppSpawningCtx *)client; + APPSPAWN_CHECK(property != NULL && client != NULL, return, "invalid param"); int fd = property->forkCtx.fd[1]; if (fd >= 0) { (void)write(fd, &result, sizeof(result)); @@ -1605,7 +1610,7 @@ APPSPAWN_STATIC int AppspawpnDevicedebugKill(int pid, cJSON *args) "appspawn devicedebug process is not debuggable, pid=%{public}d", pid); APPSPAWN_LOGI("appspawn devicedebug debugable=%{public}d, pid=%{public}d, signal=%{public}d", - appInfo->isDebuggable, pid, (int)signal->valueint); + appInfo->isDebuggable, pid, signal->valueint); if (kill(pid, signal->valueint) != 0) { APPSPAWN_LOGE("appspawn devicedebug unable to kill process, pid: %{public}d ret %{public}d", pid, errno); @@ -1620,7 +1625,7 @@ APPSPAWN_STATIC int AppspawnDevicedebugDeal(const char* op, int pid, cJSON *args if (strcmp(op, "kill") == 0) { return AppspawpnDevicedebugKill(pid, args); } - APPSPAWN_LOGE("appspawn devicedebug op:%{public}s invaild", op); + APPSPAWN_LOGE("appspawn devicedebug op:%{public}s invalid", op); return -1; } @@ -1750,6 +1755,58 @@ APPSPAWN_STATIC void ProcessObserveProcessSignalMsg(AppSpawnConnection *connecti DeleteAppSpawnMsg(&message); } +#if (defined(PRE_DLOPEN_ARKWEB_LIB) && !defined(ASAN_DETECTOR)) +static bool IsNWebLibLoaded(Dl_namespace dlns) +{ + void* handler = dlopen_ns(&dlns, LIB_ARKWEB_ENGINE, RTLD_NOW | RTLD_NOLOAD); + if (handler) { + dlclose(handler); + return true; + } + return false; +} +#endif + +static void ProcessSpawnDlcloseMsg(AppSpawnConnection *connection, AppSpawnMsgNode *message) +{ + AppSpawnMsg* msg = &message->msgHeader; + APPSPAWN_LOGI("Recv ProcessSpawnDlcloseMsg message header magic: 0x%{public}x type: %{public}u" + "id: %{public}u len: %{public}u processName: %{public}s", + msg->magic, + msg->msgType, + msg->msgId, + msg->msgLen, + msg->processName); + +#if (defined(PRE_DLOPEN_ARKWEB_LIB) && !defined(ASAN_DETECTOR)) + Dl_namespace dlns; + if (dlns_get("nweb_ns", &dlns) != 0) { + APPSPAWN_LOGI("Failed to get nweb_ns"); + SendResponse(connection, msg, 0, 0); + return; + } + + void* webEngineHandle = dlopen_ns(&dlns, LIB_ARKWEB_ENGINE, RTLD_NOW | RTLD_NOLOAD); + if (!webEngineHandle) { + APPSPAWN_LOGE("FAILED to find %{public}s in appspawn %{public}s", LIB_ARKWEB_ENGINE, dlerror()); + SendResponse(connection, msg, 0, 0); + return; + } + + int cnt = MAX_DLCLOSE_COUNT; + do { + cnt--; + dlclose(webEngineHandle); + } while (cnt > 0 && IsNWebLibLoaded(dlns)); + + if (cnt == 0 && IsNWebLibLoaded(dlns)) { + SendResponse(connection, msg, -1, 0); + return; + } +#endif + SendResponse(connection, msg, 0, 0); +} + static void ProcessSpawnDlopenMsg(AppSpawnConnection *connection, AppSpawnMsgNode *message) { AppSpawnMsg* msg = &message->msgHeader; @@ -1782,12 +1839,12 @@ static void ProcessSpawnDlopenMsg(AppSpawnConnection *connection, AppSpawnMsgNod dlns_inherit(&dlns, &ndkns, "allow_all_shared_libs"); } - void* webEngineHandle = dlopen_ns(&dlns, "libarkweb_engine.so", RTLD_NOW | RTLD_GLOBAL); + void* webEngineHandle = dlopen_ns(&dlns, LIB_ARKWEB_ENGINE, RTLD_NOW | RTLD_GLOBAL); if (!webEngineHandle) { - APPSPAWN_LOGE("FAILED to dlopen libarkweb_engine.so in appspawn %{public}s", dlerror()); + APPSPAWN_LOGE("FAILED to dlopen %{public}s in appspawn %{public}s", LIB_ARKWEB_ENGINE, dlerror()); SendResponse(connection, msg, -1, 0); } else { - APPSPAWN_LOGI("SUCCESS to dlopen libarkweb_engine.so in appspawn"); + APPSPAWN_LOGI("SUCCESS to dlopen %{public}s in appspawn", LIB_ARKWEB_ENGINE); SendResponse(connection, msg, 0, 0); #ifndef OHOS_LITE ReclaimFileCache(); @@ -1858,6 +1915,10 @@ static void ProcessRecvMsg(AppSpawnConnection *connection, AppSpawnMsgNode *mess case MSG_OBSERVE_PROCESS_SIGNAL_STATUS: ProcessObserveProcessSignalMsg(connection, message); break; + case MSG_UNLOAD_WEBLIB_IN_APPSPAWN: + ProcessSpawnDlcloseMsg(connection, message); + DeleteAppSpawnMsg(&message); + break; case MSG_LOAD_WEBLIB_IN_APPSPAWN: ProcessSpawnDlopenMsg(connection, message); DeleteAppSpawnMsg(&message); diff --git a/test/BUILD.gn b/test/BUILD.gn index 7e399ae136a1dfb547b5420d456eee4eb05933af..22e12e97b8fd7ba3ae9465d288e616b9ccc64135 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -29,6 +29,7 @@ group("unittest") { deps += [ "unittest/app_spawn_standard_test:AppSpawn_ut" ] deps += [ "unittest/app_spawn_standard_test:AppSpawn_common_ut" ] deps += [ "unittest/app_spawn_standard_test:AppSpawn_coldrun_ut" ] + deps += [ "unittest/app_spawn_standard_test:AppSpawnDebugSandbox" ] } deps += [ "unittest/hnp_test:HnpTest" ] deps += [ "unittest/single_test/hnp_installer:hnp_installer_test" ] diff --git a/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.json b/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.json deleted file mode 100644 index a69713ef05f2d25440f98d8eefc5d5fbd6a71e8a..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.py b/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.py deleted file mode 100644 index 8ed54e46203ec044b2814f3d356e9cae69434c1d..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import time -from devicetest.core.test_case import TestCase, Step -from hypium import UiDriver -from aw import Common - - -class SubStartupAppspawnAtomservice0100(TestCase): - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - hap_info01, hap_info02 = [], [] - bundle_name = "com.atomicservice.5765880207854649689" - bundle_name_start = "+auid-ohosAnonymousUid+com.atomicservice.5765880207854649689" - hap_path = Common.sourcepath('atomicservice.hap', "sub_startup_appspawn_atomservice") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - - for path in ["base", "database"]: - for i in range(1, 5): - has_dir = self.driver.Storage.has_dir("/data/app/el%d/100/%s/%s" % (i, path, bundle_name)) - has_dir_login = self.driver.Storage.has_dir("/data/app/el%d/100/%s/%s" % (i, path, bundle_name_start)) - self.driver.Assert.equal(has_dir, True) - self.driver.Assert.equal(has_dir_login, False) - - log_has_dir = self.driver.Storage.has_dir("/data/app/el2/100/log/%s" % bundle_name) - log_has_dir_login = self.driver.Storage.has_dir("/data/app/el2/100/log/%s" % bundle_name_start) - self.driver.Assert.equal(log_has_dir, True) - self.driver.Assert.equal(log_has_dir_login, False) - - mnt_has_dir = self.driver.Storage.has_dir("/mnt/share/100/%s" % bundle_name) - mnt_has_dir_login = self.driver.Storage.has_dir("/mnt/share/100/%s" % bundle_name_start) - self.driver.Assert.equal(mnt_has_dir, True) - self.driver.Assert.equal(mnt_has_dir_login, False) - - self.driver.shell("aa start -a EntryAbility -b %s" % bundle_name) - for path in ["base", "database"]: - for i in range(1, 5): - has_dir_login = self.driver.Storage.has_dir("/data/app/el%d/100/%s/%s" % (i, path, bundle_name_start)) - self.driver.Assert.equal(has_dir_login, True) - - mnt_has_dir_login = self.driver.Storage.has_dir("/mnt/share/100/%s" % bundle_name_start) - self.driver.Assert.equal(mnt_has_dir_login, True) - - for i in range(1, 5): - hap_detail = self.driver.shell("ls -lZ ../data/app/el%d/100/%s" % (i, "base")).split("\n") - for hap in hap_detail[1:-2]: - if hap.split()[-1] == bundle_name: - hap_info01 = hap - if hap.split()[-1] == bundle_name_start: - hap_info02 = hap - for index in range(2, 5): - self.driver.Assert.equal(hap_info01.split()[index], hap_info02.split()[index]) - - hap_detail = self.driver.shell("ls -lZ ../mnt/share/100").split("\n") - for hap in hap_detail[1:-2]: - if hap.split()[-1] == bundle_name: - hap_info01 = hap - if hap.split()[-1] == bundle_name_start: - hap_info02 = hap - for index in range(2, 5): - self.driver.Assert.equal(hap_info01.split()[index], hap_info02.split()[index]) - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.uninstall_app("com.atomicservice.5765880207854649689") diff --git a/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.json b/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.json deleted file mode 100644 index c5a1372fea521480ac4de270230291d44b950fee..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.py b/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.py deleted file mode 100644 index 9001688ab2f637ed1daa3e847efc327c6b24c265..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import time -from devicetest.core.test_case import TestCase, Step -from hypium import UiDriver -from aw import Common - - -class SubStartupAppspawnAtomservice0300(TestCase): - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - bundle_name = "com.atomicservice.5765880207854649689" - bundle_name_start = "+auid-ohosAnonymousUid+com.atomicservice.5765880207854649689" - hap_path = Common.sourcepath('atomicservice.hap', "sub_startup_appspawn_atomservice") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - self.driver.shell("aa start -a EntryAbility -b %s" % bundle_name) - pid = self.driver.System.get_pid(bundle_name) - - for path in ["base", "database"]: - for i in range(1, 5): - result1 = self.driver.shell("ls ../proc/%d/root/data/storage/el%d/%s" % (pid, i, path)) - result2 = self.driver.shell("ls ../data/app/el%d/100/%s/%s" % (i, path, bundle_name_start)) - self.driver.Assert.equal(result1, result2) - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.uninstall_app(bundle_name) diff --git a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py index 036499cc18d94b43144c40e28986629a1c297306..d0c65b3f29b5b4b93ffb45c2a4d6f2a1e0055a37 100644 --- a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py +++ b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py @@ -42,11 +42,11 @@ class Substartupappspawncoldstart0100(TestCase): else: raise ValueError('设置冷启动全局参数失败!') Step("通过命令启动日历.................") - result = self.driver.shell("aa start -C -d 123456 -a MainAbility -b com.hmos.calendar") + result = self.driver.shell("aa start -C -d 123456 -a MainAbility -b com.calendar") sleep(3) self.driver.Assert.contains(result, "start ability successfully.", "通过命令启动日历失败!") Step("检查日历冷启动进程.................") - result_ps = self.driver.shell("ps -ef|grep com.hmos.calendar") + result_ps = self.driver.shell("ps -ef|grep com.calendar") result_ps = result_ps.split('\n')[0] Step("日历进程信息如下:" + str(result_ps)) if '"' in result_ps: @@ -54,6 +54,6 @@ class Substartupappspawncoldstart0100(TestCase): def teardown(self): Step("收尾工作.................") - pid = self.driver.System.get_pid('com.hmos.calendar') + pid = self.driver.System.get_pid('com.calendar') self.driver.shell("kill -9 " + str(pid)) diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json deleted file mode 100644 index b764571dcfdf67a148bfd6310512fdd2b5b0dcb8..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py deleted file mode 100644 index f958bb793252b58faea0bc494a0bba34ece81557..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0100(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('release.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - self.driver.AppManager.start_app(bundle_name) - pid1 = self.driver.System.get_pid(bundle_name) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - self.driver.shell("devicedebug kill -9 %d" % pid1) - pid2 = self.driver.System.get_pid(bundle_name) - self.driver.Assert.equal(pid1, pid2) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid1) - assert device_logger.check_log("appspawn devicedebug process is not debuggable, pid=%d" % pid1) - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json deleted file mode 100644 index cb9198c746feec4cd142a58be74f8ba2bdeedb30..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py deleted file mode 100644 index 3c84650580d678b803ef6286c38e7df20b822dbb..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0200(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - self.driver.AppManager.start_app(bundle_name) - pid1 = self.driver.System.get_pid(bundle_name) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - self.driver.shell("devicedebug kill -9 %d" % pid1) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid1) - assert device_logger.check_log("appspawn devicedebug debugable=1, pid=%d, signal=9" % pid1) - assert device_logger.check_log("devicedebug manager process exit. ret=0") - self.driver.AppManager.start_app(bundle_name) - pid2 = self.driver.System.get_pid(bundle_name) - self.driver.Assert.not_equal(pid1, pid2) - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json deleted file mode 100644 index e560671a212be51ebb45ee3a392cd21c95592c14..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py deleted file mode 100644 index 9d1359d36e917873e22f5418664943a6e96fa6a6..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - -SubStartupAppspawnDevicedebug0300(TestCase): - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - signal_lst = [1, 9, 11, 15, 64] - log_dict = {} - # 本地跑1-64的 但是由于太费时间,流水线跑signal_lst中这几个有代表性的就可以了 - for signal in signal_lst: # range(1, 65)替换signal_lst - self.driver.AppManager.start_app(bundle_name) - pid = self.driver.System.get_pid(bundle_name) - log_dict.update({signal: pid}) - self.driver.shell("devicedebug kill -%d %d" % (signal, pid)) - self.driver.AppManager.stop_app(bundle_name) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - for signal, pid in log_dict.items(): - assert device_logger.check_log("devicedebug cmd kill start signal[%d], pid[%d]" % (signal, pid)) - assert device_logger.check_log("appspawn devicedebug debugable=1, pid=%d, signal=%d" % (pid, signal)) - assert device_logger.check_log("devicedebug manager process exit. ret=0") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json deleted file mode 100644 index 9b0248bf81ca8671446934d04157d36d1123905c..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py deleted file mode 100644 index 023bb1226f6137f20697152418fa5878012f49eb..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0400(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - signal_lst = ["65", "0", "SIGKILL", "null", "undefined", "sigkill"] - for signal in signal_lst: - self.driver.AppManager.start_app(bundle_name) - pid1 = self.driver.System.get_pid(bundle_name) - self.driver.shell("devicedebug kill -%s %d" % (signal, pid1)) - pid2 = self.driver.System.get_pid(bundle_name) - self.driver.Assert.equal(pid1, pid2) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - for i in range(len(signal_lst)): - assert device_logger.check_log("devicedebug manager process start.") - assert device_logger.check_log("devicedebug manager process exit. ret=22") - assert device_logger.check_log("signal is 65 not in [1, 64]") - assert device_logger.check_log("signal is 0 not in [1, 64]", expect_match_times=len(signal_lst)-1) - - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json deleted file mode 100644 index eff74779ddd26d5b3738cda0f92f17e1a78604a0..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py deleted file mode 100644 index a16ae9e2d2b38f2fc6e6e2731477e6f06f5e0d70..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0500(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - self.driver.AppManager.start_app(bundle_name) - pid1 = self.driver.System.get_pid(bundle_name) - self.driver.shell("devicedebug kill %d" % pid1) - pid2 = self.driver.System.get_pid(bundle_name) - self.driver.Assert.equal(pid1, pid2) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("devicedebug manager process start.") - assert device_logger.check_log("devicedebug cmd operator num is 3 < 4") - assert device_logger.check_log("devicedebug manager process exit. ret=18") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json deleted file mode 100644 index acbcf0b7151d7bd1cd165e01da4ab8acc0aaa758..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py deleted file mode 100644 index 8446d1c52685bd120bc2596851f942b32b501634..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0600(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - pid = self.driver.System.get_pid("nwebspawn") - self.driver.shell("devicedebug kill -9 %d" % pid) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid) - assert device_logger.check_log("appspawn devicedebug process is not debuggable, pid=%d" % pid) - assert device_logger.check_log("devicedebug manager process exit. ret=218103838") - - def teardown(self): - Step("收尾工作.................") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json deleted file mode 100644 index 2fc5b2e47ef7f2ff348429474728a878898f19c9..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py deleted file mode 100644 index 6bc9541124f4f7cf506b004f2f1d7bba962225b2..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0700(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.exe_sys_cmd" - hap_path = Common.sourcepath('debug_fork.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - self.driver.AppManager.start_app(bundle_name) - result01 = self.driver.shell("ps -ef|grep exe_sys_cmd|grep -v grep").split("\n") - childprocess_pid = result01[1].split()[1] - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - self.driver.shell("devicedebug kill -9 %s" % childprocess_pid) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("appspawn devicedebug get app info unsuccess, pid=%s" % childprocess_pid) - assert device_logger.check_log("devicedebug manager process exit. ret=218103837") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json deleted file mode 100644 index aab5e2c2805dc36b8ef13a69af0a88a14bf61895..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py deleted file mode 100644 index f37c3217c7d7ef96188f1551ac69aad733412102..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0800(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - devicedebug_help_dict = [ - "devicedebug: 'aaa' is not a valid devicedebug command. See 'devicedebug help'.", - "usage: devicedebug ", - "These are common devicedebug commands list:", - " help list available commands", - " kill send a signal(1-64) to a process" - ] - result_dict = list(filter(lambda x: x != "\r", self.driver.shell("devicedebug aaa").split("\n"))) - result_dict = list(filter(None, result_dict)) - for result in result_dict: - self.driver.Assert.contains(devicedebug_help_dict, result.rstrip("\r")) - - def teardown(self): - Step("收尾工作.................") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json deleted file mode 100644 index 93b618704548e09bebfa9de86151bd64cd1cc8d2..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py deleted file mode 100644 index f7d2d29460882204f25ee4bea3b6b5317b519a63..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0900(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - devicedebug_help_dict = [ - "usage: devicedebug ", - "These are common devicedebug commands list:", - " help list available commands", - " kill send a signal(1-64) to a process" - ] - result_dict = list(filter(lambda x: x != "\r", self.driver.shell("devicedebug help").split("\n"))) - result_dict = list(filter(None, result_dict)) - for result in result_dict: - self.driver.Assert.contains(devicedebug_help_dict, result.rstrip("\r")) - - def teardown(self): - Step("收尾工作.................") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json b/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json deleted file mode 100644 index d2ef15d1b102c91ec8be8f87744eeb9f19b7e2c7..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_fd/SubStartupAppspawnFd0100.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py b/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py deleted file mode 100644 index d65e7ce41247a3f821073ea26369733521c5e494..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from time import sleep -from devicetest.core.test_case import Step, TestCase -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnFd0100(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - Step("安装测试hap.................") - sourpath = Common.sourcepath("fd.hap", "sub_startup_appspawn_fd") - Step(sourpath) - self.driver.AppManager.install_app(sourpath) - Step("设置系统参数.................") - self.driver.shell('param set persist.sys.abilityms.multi_process_model true') - Step("执行重启..........................") - self.driver.System.reboot() - sleep(3) - self.driver.System.wait_for_boot_complete() - Step("预置工作:检测屏幕是否亮.................") - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def test_step1(self): - self.d = UiExplorer(self.device1) - device_logger = DeviceLogger(self.d) - Step("设置关键字..........................") - device_logger.set_filter_string("ldprocessmanager:OtherProcess") - Step("开启日志..........................") - device_logger.start_log("testFile/Log/log.txt") - Step("打开测试hap.................") - self.driver.start_app("com.acts.childprocessmanager", "EntryAbility") - sleep(3) - Step("点击Start Child Process.................") - self.driver.touch(BY.text("Start Child Process")) - Step("点击Start Ark Process.................") - self.driver.touch(BY.text("Start Ark Process")) - sleep(10) - Step("停止日志..........................") - device_logger.stop_log() - Step("校验日志内容..........................") - Step("查看childprocessmanager服务pid..........................") - pid = self.driver.System.get_pid('com.acts.childprocessmanager:OtherProcess1') - result = self.driver.shell("ls -al /proc/%d/fd" % pid) - Step("步骤6:预期结果校验") - self.driver.Assert.contains(result, "/data/storage/el2/base/haps/entry/files/test.txt") - self.driver.Assert.contains(result, "/data/storage/el2/base/haps/entry/files/test2.txt") - - def teardown(self): - Step("收尾工作.................") - Step("收尾工作:卸载hap......................") - self.driver.AppManager.clear_app_data('com.acts.childprocessmanager') - self.driver.AppManager.uninstall_app('com.acts.childprocessmanager') - Step("恢复系统参数.................") - self.driver.hdc('param set persist.sys.abilityms.multi_process_model false') - Step("执行重启..........................") - self.driver.System.reboot() - sleep(3) - self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.py index da38e96ad381b27b8ccc5464f537fa29614b5492..0a0194339ca6a8787a782ff0747644e809c14197 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox0100(TestCase): def process(self): file_mgr - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.py index a34f716fad6f3d8ae56c393bd10d1a0caa488ad2..daf89fbc915c6d73ca2a3b48cc4425a0e43a3cea 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox0200(TestCase): def process(self): file_mgr - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.py index 5202c61e64d08e71abf5e2a4b15ee40fb4549b29..a1b1e96bd99500349ce852c49e409be97d043cb7 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox0300(TestCase): def process(self): file_mgr - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.py index ee46c8581eedff2a97a36bab5c296f1907fafe83..26a39493a1dc5c89590c76b873efc773a40b1af1 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox0400(TestCase): def process(self): file_mgr - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.py index 1d1439bd266b72cd56f204461e55aa2c4add18e3..3c1c873bdd0a0fd16ce2c368b1376109d49267b5 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.py @@ -45,7 +45,7 @@ class SubStartupAppspawnFilemgrSandbox0500(TestCase): def process(self): file_mgr count = 0 - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.py index 31f09ea342db91aa3757262f112bd52dcb8b38e7..e49149370143e59f8f7092720e50d3a5e95e9360 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox0600(TestCase): def process(self): file_mgr - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.py index 89c32be6b3a2f3d8e616d5d3f4647d7db01b7b3b..64725e22f8e0ecc8f4fc55960bf93cfc3813c0fb 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.py @@ -45,7 +45,7 @@ class SubStartupAppspawnFilemgrSandbox0700(TestCase): def process(self): file_mgr count = 0 - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.py index aa7f8abe04f7b7de29fc2ac21f329d4ba117a413..4ddfadbd7f6571c42c156f0c40d3b3f11ded4e06 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.py @@ -45,7 +45,7 @@ class SubStartupAppspawnFilemgrSandbox0800(TestCase): def process(self): file_mgr count = 0 - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.py index f3bb2136f81da847f7a3a86325bcbe876478ffcf..e0d16560bfa32d2eb8bfb3bf816c135658294506 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.py @@ -45,7 +45,7 @@ class SubStartupAppspawnFilemgrSandbox0900(TestCase): def process(self): file_mgr count = 0 - file_mgr = "com.hmos.filemanager" + file_mgr = "com.filemanager" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(file_mgr) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.py index e07743c3d75e6aef98f5184483dd25940569decd..a9890f385f4affd5c464bf0015ee56a81166f1b0 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox1000(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.py index f93a6d2d517bee94bb1c27904279a7594eefa598..0a81042ebef023d5368b40a760b43402fc1bd231 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox1100(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.py index f4066486cc369795d7111eb434b9accfda95c73d..2ef1db996ae89c45b9f997e5228cd38ca6e21aa7 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox1200(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.py index 215475b1baf755f614d8d651389469ef43f23017..6231fe7e82cddd97c07b0012bd2ab1fc8f0399b6 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox1300(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.py index 5902c943c26c272b7218c308a637063bb0e1b371..7803be0c802c9e99430dacc8b0cbe95ae99486e9 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox1400(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.py index 2fb69ff0477f4ffaa8952a1af640bf1eb79ff0e3..2a6326a17b246328d79fe17d70a2dd8980bcf16b 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox1500(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.py index 9e5905b8a3ce85dd1f6d80c2b36a14f06a79c16d..cde3680ad78c50156315ad2d800759b39a319f73 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.py @@ -45,7 +45,7 @@ class SubStartupAppspawnFilemgrSandbox1600(TestCase): def process(self): notepad count = 0 - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.py index 05b9ad55b7231778e39076e9881d3358d1639b70..e9d031955890b43ee89c02d73eb82eb57fccffe4 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox1700(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.py index 5c663660efa38d7c860ca8cf7c839589ea5e0de9..53eeb47525ce8e8be0f7c87db86fb7dba056a4af 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.py @@ -45,7 +45,7 @@ class SubStartupAppspawnFilemgrSandbox1800(TestCase): def process(self): notepad count = 0 - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.py index 640d9c261a9c2e144bdbb27769d311ef60daac14..cec6adb66f802a0c5e7b4a0dc814d9b4ae192124 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.py @@ -45,7 +45,7 @@ class SubStartupAppspawnFilemgrSandbox1900(TestCase): def process(self): notepad count = 0 - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") self.driver.AppManager.start_app(notepad) time.sleep(3) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.py index d68060d13accc2c582d50ce1c6b8953273a87009..e954c06d32499efef003728d24df7236330fd98a 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox2000(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.AppManager.start_app(notepad) time.sleep(3) pid = self.driver.System.get_pid(notepad) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.py index 990742ffba11797f11e2ef3ef370e6d896fa0e92..d977d931edab3dd9b37099318ac755fcacad9124 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox2100(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.AppManager.start_app(notepad) time.sleep(3) pid = self.driver.System.get_pid(notepad) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.py index e797ef7e6b6882ce3adeadfb8fa212f16227f9f8..2fbd8db1c19e92f6ef67659adc91f2df0f63a448 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox2200(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.AppManager.start_app(notepad) time.sleep(3) pid = self.driver.System.get_pid(notepad) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.py index 28db72b77116527bb47623855679490a8bc89797..4062169bd87b9e932d46734aef255818e921f748 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox2300(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.AppManager.start_app(notepad) time.sleep(3) pid = self.driver.System.get_pid(notepad) diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.py b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.py index 1c5f86776083006fe9dd94275aaf99f80a401dfa..61a324b6b2cdc4a4a7817d819f8f17dd38194088 100644 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.py +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.py @@ -44,7 +44,7 @@ class SubStartupAppspawnFilemgrSandbox2500(TestCase): def process(self): notepad - notepad = "com.hmos.notepad" + notepad = "com.notepad" self.driver.AppManager.start_app(notepad) time.sleep(3) pid = self.driver.System.get_pid(notepad) diff --git a/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.json b/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.json deleted file mode 100644 index 850e6d6a2a1ded8079bb6217fc0d5780b3af98ca..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device", - "label": "phone" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_ftpd/SubStartupAppspawnFtpd0100.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.py b/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.py deleted file mode 100644 index a2385b2dc46b2412ac0dd3cf6dd3c6ada2787336..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from devicetest.core.test_case import Step, TestCase - -from aw import Common - - -class SubStartupAppspawnFtpd0100(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - Step("设置系统参数sysctl -w kernel.xpm.xpm_mode=0..........................") - self.driver.hdc("target mount") - self.driver.shell("sed -i 's%/proc/sys/kernel/xpm/xpm_mode 4%/proc/sys/kernel/xpm/xpm_mode 0%g' /system/etc/init/key_enable.cfg") - self.driver.shell("reboot") - self.driver.System.wait_for_boot_complete() - set_result = self.driver.shell("sysctl -w kernel.xpm.xpm_mode=0") - self.driver.Assert.contains(set_result, "kernel.xpm.xpm_mode = 0") - Step("安装测试hap.................") - sourpath = Common.sourcepath("ftpd.hap", "sub_startup_appspawn_ftpd") - Step(sourpath) - self.driver.AppManager.install_app(sourpath) - Step("预置工作:检测屏幕是否亮.................") - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def test_step1(self): - Step("打开测试hap.................") - self.driver.start_app("com.ohos.myapplication", "EntryAbility") - Step("打开bftpd.................") - aa_resutl = self.driver.shell("aa process -b com.ohos.myapplication -a EntryAbility -D '/system/bin/bftpd -D -p 9021' -S") - self.driver.Assert.contains(aa_resutl, "start native process successfully") - Step("校验bftpd进程") - pid = self.driver.System.get_pid('bftpd') - - def teardown(self): - Step("收尾工作.................") - Step("收尾工作:卸载hap......................") - self.driver.AppManager.clear_app_data('com.ohos.myapplication') - self.driver.AppManager.uninstall_app('com.ohos.myapplication') - Step("恢复系统参数......................") - recovery_result = self.driver.shell("sysctl -w kernel.xpm.xpm_mode=4") - self.driver.Assert.contains(recovery_result, "kernel.xpm.xpm_mode = 4") diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0100.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0100.py index e9ebe3660f7ed10781beb92d14da841874014922..fea78abc69e921137f9ab44bead50dbcccf4ef47 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0100.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0100.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0200.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0200.py index 64f2ba3cf883f89dfb1b3892f0384dc4e0ab8a48..94df5ef8c9e3ee4a9b5b3d5411eb5a2cd1ed29ad 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0200.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0200.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0300.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0300.py index 32195b3941aff343fcd5bbb578e091cc4b967539..0cbc0e3eb56b5cb6c6b13350d277c40790f4c76a 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0300.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0300.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0400.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0400.py index 5f0c517349913a3b7fe74e5866851df63e7b562d..05c07a6092bd880e111481500dbc7f2547e54102 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0400.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0400.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0500.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0500.py index 3f9a7bfc905eccc10496dbb37d518cda32fb7dcf..3bcaac1e4aaceb19018579ad03a0dd0b631bb0a0 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0500.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0500.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0700.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0700.py index 5486dd660f3dbb8a9f2140c3f0bde38559df014f..387c4c3ddd4a23efd49db4af843d04c9863ea5d8 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0700.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0700.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0900.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0900.py index af214e5421b7a2705409b29a4e5c11997670d3ed..427097fca177600a9b70eb746c8ed347db708f88 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0900.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_0900.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1000.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1000.py index 93161e242263537eb03fd14456d743e97a51975d..9e0a418de6de9ce3109798802c65be116678a49c 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1000.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1000.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1100.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1100.py index e31c666312a3b1a310a11334224b09a3d96ff0b2..879a01497312a15919b07ff45b2c879d0a35745f 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1100.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1100.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1200.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1200.py index 531003651bdafebbf96b9b84c1b096f6c17862a3..8773b0bc4be35ee5504f3d2393ad51c3f6f4d99e 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1200.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1200.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1300.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1300.py index ffb58b3e876b22f085d351aae23b85f7513360be..0c65799e6ff09f765626556b6a69c007d882fa11 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1300.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1300.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1400.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1400.py index 5d72bc5bdb6d82e1e7df3b7b5df72a4cc691e790..00a0c4f25f6d091722d7241cabfb415b88882c24 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1400.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1400.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1500.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1500.py index 63c6344dcc15834726572034eaaff3d0e63843fb..606387c25476d86dcb5ff3f4f02ceb1c2018b899 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1500.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1500.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1600.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1600.py index 4c20f740443892961d52e0b2d3b9befaf53574d8..3223b60a62a3682a5abae14322b697b5eef17857 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1600.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1600.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1700.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1700.py index 474485a7a3d58ca83c2e42527c426b1f467411e3..8c88da567b7d2b7107977e4a8500e2d1cf0aac3e 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1700.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1700.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1800.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1800.py index a99c2ab6f487d4931ce8830f31c43377fc919bb3..14145410c7b4fbc57db195921976a376570d7185 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1800.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1800.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1900.py b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1900.py index 3ea853e4d3de3bc7a9d10a31737d3f8afed178f7..e6670b74334cb5aec6c8a09238b9165606692ac1 100644 --- a/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1900.py +++ b/test/autotest/sub_startup_appspawn_nativespawn/sub_startup_appspawn_nativespawn_1900.py @@ -1,4 +1,6 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/mock/app_spawn_stub.h b/test/mock/app_spawn_stub.h index 5abe32760896ef46cc6b547f81a4c3accd6e16ae..3d4e12ef248d10c3a753b93f1fba0dd850ba53b8 100644 --- a/test/mock/app_spawn_stub.h +++ b/test/mock/app_spawn_stub.h @@ -136,7 +136,8 @@ void SetSystemEnv(void); void RunAppSandbox(const char *ptyName); HOOK_MGR *GetAppSpawnHookMgr(void); int SpawnKickDogStart(AppSpawnMgr *mgrContent); -int AddMembersToEncapsInfo(cJSON *extInfoJson, UserEncaps *encapsInfo); +cJSON *GetEncapsPermissions(cJSON *extInfoJson, int *count); +int AddMembersToEncapsInfo(cJSON *extInfoJson, UserEncaps *encapsInfo, int count); int SpawnSetPermissions(AppSpawningCtx *property, UserEncaps *encapsInfo); int AddPermissionItemToEncapsInfo(UserEncap *encap, cJSON *permissionItem); void FreeEncapsInfo(UserEncaps *encapsInfo); diff --git a/test/moduletest/appspawn_client_test.cpp b/test/moduletest/appspawn_client_test.cpp index 3e285594d1223717493d74d07f41e4eaa0a7f917..8e2960f18f9cff99749f6c7b20fb5750416b2ae7 100644 --- a/test/moduletest/appspawn_client_test.cpp +++ b/test/moduletest/appspawn_client_test.cpp @@ -67,7 +67,6 @@ static AppSpawnReqMsgHandle CreateMsg(AppSpawnClientHandle handle, const char *b static const char *permissions[] = { "ohos.permission.MANAGE_PRIVATE_PHOTOS", - "ohos.permission.FILE_CROSS_APP", "ohos.permission.ACTIVATE_THEME_PACKAGE", "ohos.permission.GET_WALLPAPER", }; diff --git a/test/moduletest/appspawn_test_cmder.cpp b/test/moduletest/appspawn_test_cmder.cpp index f24498216b418ba2a90bc0dfc4e707484bf3f1ec..b1bca7767dafee2bf7dbbb90fb10e2a9d305d68e 100644 --- a/test/moduletest/appspawn_test_cmder.cpp +++ b/test/moduletest/appspawn_test_cmder.cpp @@ -56,7 +56,6 @@ static const std::string g_defaultAppInfo = "{ \ },\ \"permission\" : [\ \"ohos.permission.MANAGE_PRIVATE_PHOTOS\",\ - \"ohos.permission.FILE_CROSS_APP\",\ \"ohos.permission.ACTIVATE_THEME_PACKAGE\"\ ],\ \"internet-permission\" : {\ diff --git a/test/moduletest/test_app_info.json b/test/moduletest/test_app_info.json index 549e4699e261abbb79d734862da9133dd40a9c4b..bf584d895c93db43ee97bf6214977bc1702ca0b1 100644 --- a/test/moduletest/test_app_info.json +++ b/test/moduletest/test_app_info.json @@ -14,7 +14,6 @@ }, "permission": [ "ohos.permission.MANAGE_PRIVATE_PHOTOS", - "ohos.permission.FILE_CROSS_APP", "ohos.permission.ACTIVATE_THEME_PACKAGE" ], "internet-permission": { diff --git a/test/unittest/app_spawn_client_test/BUILD.gn b/test/unittest/app_spawn_client_test/BUILD.gn index 3b3932f688b2acc1fb7fafbd7855e20e43a59580..dd62ab1364bfef8352f12d86bf206eab0be1dfac 100644 --- a/test/unittest/app_spawn_client_test/BUILD.gn +++ b/test/unittest/app_spawn_client_test/BUILD.gn @@ -40,7 +40,6 @@ ohos_unittest("AppSpawn_client_ut") { "${appspawn_path}/modules/common", "${appspawn_path}/modules/sandbox", "${appspawn_path}/modules/sandbox/normal", - "${appspawn_path}/modules/sandbox/modern", "${appspawn_path}/modules/module_engine/include", "${appspawn_path}/modules/sysevent", "${appspawn_innerkits_path}/client", diff --git a/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp b/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp index 4fa5b75fb165ede5509aafe9a5ee7934e0053776..8c1c0a8f0241b9a375c606b5abb3df2e52729862 100644 --- a/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp +++ b/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp @@ -193,7 +193,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_001, TestSize.Level0) ret = AppSpawnReqMsgSetAppFlag(reqHandle, MAX_FLAGS_INDEX); ASSERT_NE(ret, 0); - ret = APPSPAWN_ARG_INVALID; AppSpawnReqMsgNode *reqNode = (AppSpawnReqMsgNode *)reqHandle; APPSPAWN_CHECK(reqNode != nullptr, break, "Invalid reqNode"); APPSPAWN_CHECK(reqNode->msgFlags != nullptr, break, "Invalid reqNode"); @@ -208,9 +207,7 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_001, TestSize.Level0) uint32_t result = (reqNode->msgFlags->flags[index] & bits) == bits; ASSERT_EQ(result == 1, 1); } - ret = 0; } while (0); - ASSERT_EQ(ret, 0); AppSpawnReqMsgFree(reqHandle); AppSpawnClientDestroy(clientHandle); } @@ -231,7 +228,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_002, TestSize.Level0) reqHandle = g_testHelper.CreateMsg(clientHandle, MSG_APP_SPAWN, 1); APPSPAWN_CHECK(reqHandle != INVALID_REQ_HANDLE, break, "Failed to create req %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); @@ -243,11 +239,10 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_002, TestSize.Level0) APPSPAWN_CHECK(info->gidCount == 2, break, "Invalid gidCount %{public}d", info->gidCount); // 2 default APPSPAWN_CHECK(info->gidTable[1] == g_testHelper.GetTestGidGroup() + 1, break, "Invalid uid %{public}d", info->gidTable[1]); - ret = 0; } while (0); - ASSERT_EQ(ret, 0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); + ASSERT_EQ(ret, 0); } /** @@ -271,7 +266,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_003, TestSize.Level0) reqHandle = g_testHelper.CreateMsg(clientHandle, MSG_APP_SPAWN, 1); APPSPAWN_CHECK(reqHandle != INVALID_REQ_HANDLE, break, "Failed to create req %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); void *tlvValue = GetAppProperty(property, TLV_BUNDLE_INFO); @@ -282,12 +276,11 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_003, TestSize.Level0) APPSPAWN_LOGV("info->bundleName %{public}s", info->bundleName); APPSPAWN_CHECK(strcmp(info->bundleName, processName.c_str()) == 0, break, "Invalid bundleName %{public}s", info->bundleName); - ret = 0; } while (0); - ASSERT_EQ(ret, 0); g_testHelper.SetDefaultTestData(); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); + ASSERT_EQ(ret, 0); } /** @@ -313,7 +306,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_004, TestSize.Level0) ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_RENDER_CMD, renderCmd); APPSPAWN_CHECK(ret == 0, break, "Failed to add render cmd %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); DumpAppSpawnMsg(property->message); @@ -323,7 +315,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_004, TestSize.Level0) APPSPAWN_LOGV("info->bundleName %{public}s", renderCmdMsg); APPSPAWN_CHECK(strcmp(renderCmdMsg, renderCmd) == 0, break, "Invalid renderCmd %{public}s", renderCmd); - ret = 0; } while (0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); @@ -352,7 +343,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_025, TestSize.Level0) ret = AppSpawnReqMsgAddFd(reqHandle, fdname, fd); APPSPAWN_CHECK(ret == 0, break, "Failed to add fd %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); DumpAppSpawnMsg(property->message); @@ -360,7 +350,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_025, TestSize.Level0) char *recvFdName = reinterpret_cast(GetAppPropertyExt(property, MSG_EXT_NAME_APP_FD, &len)); APPSPAWN_CHECK(strcmp(recvFdName, fdname) == 0, break, "Invalid fdname %{public}s", fdname); - ret = 0; } while (0); close(fd); DeleteAppSpawningCtx(property); @@ -389,7 +378,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_005, TestSize.Level0) ret = AppSpawnReqMsgSetAppOwnerId(reqHandle, ownerId); APPSPAWN_CHECK(ret == 0, break, "Failed to add owner %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); void *tlvValue = GetAppProperty(property, TLV_OWNER_INFO); @@ -397,11 +385,10 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_005, TestSize.Level0) APPSPAWN_CHECK(owner != nullptr, break, "Can not find owner cmd in msg"); APPSPAWN_LOGV("owner->ownerId %{public}s", owner->ownerId); APPSPAWN_CHECK(strcmp(owner->ownerId, ownerId) == 0, break, "Invalid ownerId %{public}s", ownerId); - ret = 0; } while (0); - ASSERT_EQ(ret, 0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); + ASSERT_EQ(ret, 0); } /** @@ -423,7 +410,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_006, TestSize.Level0) ret = AppSpawnReqMsgSetAppInternetPermissionInfo(reqHandle, 101, 102); // 101 102 test APPSPAWN_CHECK(ret == 0, break, "Failed to add owner %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); void *tlvValue = GetAppProperty(property, TLV_INTERNET_INFO); @@ -433,11 +419,10 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_006, TestSize.Level0) break, "Invalid setAllowInternet %{public}d", interInfo->setAllowInternet); APPSPAWN_CHECK(101 == interInfo->allowInternet, // 101 test break, "Invalid allowInternet %{public}d", interInfo->allowInternet); - ret = 0; } while (0); - ASSERT_EQ(ret, 0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); + ASSERT_EQ(ret, 0); } /** @@ -460,7 +445,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_007, TestSize.Level0) ret = AppSpawnReqMsgSetAppDomainInfo(reqHandle, 1, apl); APPSPAWN_CHECK(ret == 0, break, "Failed to add domain %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); void *tlvValue = GetAppProperty(property, TLV_DOMAIN_INFO); @@ -469,11 +453,10 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_007, TestSize.Level0) APPSPAWN_CHECK(1 == domainInfo->hapFlags, break, "Invalid hapFlags %{public}d", domainInfo->hapFlags); APPSPAWN_LOGV("Test apl: %{public}s", domainInfo->apl); APPSPAWN_CHECK(strcmp(domainInfo->apl, apl) == 0, break, "Invalid apl %{public}s", domainInfo->apl); - ret = 0; } while (0); - ASSERT_EQ(ret, 0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); + ASSERT_EQ(ret, 0); } /** @@ -495,18 +478,16 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_008, TestSize.Level0) ret = AppSpawnReqMsgSetAppAccessToken(reqHandle, 12345678); // 12345678 APPSPAWN_CHECK(ret == 0, break, "Failed to add access token %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); void *tlvValue = GetAppProperty(property, TLV_ACCESS_TOKEN_INFO); AppSpawnMsgAccessToken *tokenInfo = static_cast(tlvValue); APPSPAWN_CHECK(tokenInfo != nullptr, break, "Can not find owner cmd in msg"); APPSPAWN_CHECK(12345678 == tokenInfo->accessTokenIdEx, break, "Invalid accessTokenIdEx"); - ret = 0; } while (0); - ASSERT_EQ(ret, 0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); + ASSERT_EQ(ret, 0); } /** @@ -545,7 +526,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_009, TestSize.Level0) ret = AppSpawnReqMsgSetAppAccessToken(reqHandle, 12345678); // 12345678 APPSPAWN_CHECK(ret == 0, break, "Failed to add access token %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); uint32_t tlvLen = 0; @@ -554,7 +534,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_009, TestSize.Level0) APPSPAWN_CHECK(tlvLen == testData.size(), break, "Invalid tlv len %{public}u", tlvLen); APPSPAWN_CHECK(strncmp(reinterpret_cast(tlvValue), testData.data(), testData.size()) == 0, break, "Invalid ext tlv %{public}s ", reinterpret_cast(tlvValue + testDataLen)); - ret = 0; } while (0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); @@ -597,7 +576,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_010, TestSize.Level0) ret = AppSpawnReqMsgSetAppAccessToken(reqHandle, 12345678); // 12345678 APPSPAWN_CHECK(ret == 0, break, "Failed to add access token %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); uint32_t tlvLen = 0; @@ -606,7 +584,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_010, TestSize.Level0) APPSPAWN_CHECK(tlvLen == testData.size(), break, "Invalid tlv len %{public}u", tlvLen); APPSPAWN_CHECK(strncmp(reinterpret_cast(tlvValue), testData.data(), testData.size()) == 0, break, "Invalid ext tlv %{public}s ", reinterpret_cast(tlvValue + testDataLen)); - ret = 0; } while (0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); @@ -649,7 +626,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_011, TestSize.Level0) ret = AppSpawnReqMsgSetAppAccessToken(reqHandle, 12345678); // 12345678 APPSPAWN_CHECK(ret == 0, break, "Failed to add access token %{public}s", APPSPAWN_SERVER_NAME); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); uint32_t tlvLen = 0; @@ -658,7 +634,6 @@ HWTEST_F(AppSpawnClientTest, App_Client_Msg_011, TestSize.Level0) APPSPAWN_CHECK(tlvLen == testData.size(), break, "Invalid tlv len %{public}u", tlvLen); APPSPAWN_CHECK(strncmp(reinterpret_cast(tlvValue), testData.data(), testData.size()) == 0, break, "Invalid ext tlv %{public}s ", reinterpret_cast(tlvValue + testDataLen)); - ret = 0; } while (0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); @@ -1199,7 +1174,7 @@ HWTEST_F(AppSpawnClientTest, App_Spawn_Permission_006, TestSize.Level0) // for old sandbox, only one config #ifdef APPSPAWN_SANDBOX_NEW int max = GetMaxPermissionIndex(clientHandle); - EXPECT_EQ(max, 0); + EXPECT_EQ(max, sizeof(g_spawnerPermissionList) / sizeof(g_spawnerPermissionList[0])); int index = GetPermissionIndex(clientHandle, nullptr); EXPECT_EQ(index, INVALID_PERMISSION_INDEX); diff --git a/test/unittest/app_spawn_client_test/app_spawn_interface_test.cpp b/test/unittest/app_spawn_client_test/app_spawn_interface_test.cpp index 005db33db56ffdc94d118f2a1dfc404c3891373d..0a387a8ecd9b5b8e94b1005f5b63f46fa5128141 100644 --- a/test/unittest/app_spawn_client_test/app_spawn_interface_test.cpp +++ b/test/unittest/app_spawn_client_test/app_spawn_interface_test.cpp @@ -617,7 +617,7 @@ HWTEST_F(AppSpawnInterfaceTest, App_SpawnListenFdSet_001, TestSize.Level0) ret = SpawnListenFdSet(pipefd[1]); EXPECT_EQ(ret, 0); - + close(pipefd[0]); close(pipefd[1]); } @@ -646,7 +646,7 @@ HWTEST_F(AppSpawnInterfaceTest, Native_SpawnListenFdSet_001, TestSize.Level0) ret = NativeSpawnListenFdSet(pipefd[1]); EXPECT_EQ(ret, 0); - + close(pipefd[0]); close(pipefd[1]); } diff --git a/test/unittest/app_spawn_standard_test/BUILD.gn b/test/unittest/app_spawn_standard_test/BUILD.gn index c1624c89753c5908494bd982cbd058e05e5dd3bd..024c3d972e0a70eada0567ef0cd5f7e2ea6d52e9 100644 --- a/test/unittest/app_spawn_standard_test/BUILD.gn +++ b/test/unittest/app_spawn_standard_test/BUILD.gn @@ -137,10 +137,13 @@ ohos_unittest("AppSpawn_ut") { "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_mount_test.cpp", "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_test.cpp", "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_sandboxmgr_test.cpp", + "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_debug_mode.cpp", ] defines += [ "APPSPAWN_SANDBOX_NEW" ] } else { - sources += [ "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_sandbox_test.cpp" ] + sources += [ + "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_sandbox_test.cpp", + ] } configs = [ "${appspawn_path}:appspawn_config" ] @@ -215,6 +218,103 @@ ohos_unittest("AppSpawn_ut") { } } +ohos_unittest("AppSpawnDebugSandbox") { + module_out_path = "appspawn/appspawn" + cflags = [ "-Dprivate=public" ] + if (appspawn_unittest_coverage) { + cflags += [ "--coverage" ] + ldflags = [ "--coverage" ] + cflags_cc = [ "--coverage" ] + } + deps = [] + defines = [ + "APPSPAWN_BASE_DIR=\"/data/appspawn_ut\"", + "APPSPAWN_LABEL=\"APPSPAWN_UT\"", + "APPSPAWN_TEST", + "APPSPAWN_CLIENT", + "APPSPAWN_DEBUG", + "DEBUG_BEGETCTL_BOOT", + "USER_TIMER_TO_CHECK", + "OHOS_DEBUG", + ] + + include_dirs = [ + "${appspawn_path}", + "${appspawn_path}/common", + "${appspawn_path}/standard", + "${appspawn_innerkits_path}/client", + "${appspawn_innerkits_path}/permission", + "${appspawn_path}/test/mock", + "${appspawn_path}/test/unittest", + "${appspawn_path}/util/include", + "${appspawn_path}/modules/module_engine/include", + "${appspawn_path}/modules/sandbox", + "${appspawn_path}/modules/sandbox/normal" + ] + + sources = [ + "${appspawn_path}/util/src/appspawn_utils.c", + "${appspawn_path}/modules/modulemgr/appspawn_modulemgr.c", + "${appspawn_path}/standard/appspawn_msgmgr.c", + "${appspawn_path}/common/appspawn_trace.cpp", + "${appspawn_innerkits_path}/permission/appspawn_mount_permission.c", + ] + + if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { + defines += [ "APPSPAWN_SANDBOX_NEW" ] + } else { + sources += [ + "${appspawn_path}/test/unittest/app_spawn_standard_test/app_spawn_sandbox_debug_mode.cpp", + "${appspawn_path}/test/mock/lib_func_mock/lib_func_mock.cpp", + "${appspawn_path}/modules/sandbox/sandbox_dec.c", + "${appspawn_path}/modules/sandbox/appspawn_permission.c", + "${appspawn_path}/modules/sandbox/normal/sandbox_shared_mount.cpp", + "${appspawn_path}/modules/sandbox/normal/appspawn_sandbox_manager.cpp", + "${appspawn_path}/modules/sandbox/normal/sandbox_common.cpp", + ] + include_dirs += [ "${appspawn_path}/test/mock/lib_func_mock" ] + } + + configs = [ "${appspawn_path}:appspawn_config" ] + external_deps = [ + "cJSON:cjson", + "c_utils:utils", + "config_policy:configpolicy_util", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbegetutil", + "googletest:gmock_main", + ] + + if (target_cpu == "arm64" || target_cpu == "x86_64" || + target_cpu == "riscv64") { + defines += [ "APPSPAWN_64" ] + } + + if (build_selinux) { + defines += [ "WITH_SELINUX" ] + external_deps += [ + "selinux:libselinux", + "selinux_adapter:libhap_restorecon", + ] + } + + if (appspawn_report_event) { + defines += [ "REPORT_EVENT" ] + external_deps += [ "hisysevent:libhisysevent" ] + sources += [ + "${appspawn_path}/modules/sysevent/appspawn_hisysevent.cpp", + "${appspawn_path}/modules/sysevent/event_reporter.cpp", + "${appspawn_path}/modules/sysevent/hisysevent_adapter.cpp", + ] + } + + if (dlp_permission_enable) { + cflags_cc = [ "-DWITH_DLP" ] + external_deps += [ "dlp_permission_service:libdlp_fuse" ] + } +} + ohos_unittest("AppSpawn_coldrun_ut") { module_out_path = "appspawn/appspawn" cflags = [ "-Dprivate=public" ] @@ -309,10 +409,6 @@ ohos_unittest("AppSpawn_coldrun_ut") { ] sources += appspawn_sandbox_src - if (appspawn_use_encaps == true) { - sources += [ "${appspawn_path}/modules/common/appspawn_encaps.c" ] - } - # add stub include_dirs += [ "${appspawn_path}/test/mock" ] sources += [ diff --git a/test/unittest/app_spawn_standard_test/app_spawn_appmgr_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_appmgr_test.cpp index fa67228060a6b406a018121dffb19883cef297f7..f648c1d1728f3dcc102afef2ff29ccc6b3e342b1 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_appmgr_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_appmgr_test.cpp @@ -956,14 +956,6 @@ HWTEST_F(AppSpawnAppMgrTest, App_Spawn_AppSpawningCtx_Msg_003, TestSize.Level0) ret = CheckAppPermissionFlagSet(nullptr, j); EXPECT_EQ(0, ret); } - uint32_t result[MAX_FLAGS_INDEX] = {0}; - result[0] = 0; - result[1] = 1; - result[3] = 1; - for (int j = 0; j < MAX_FLAGS_INDEX; j++) { - ret = CheckAppMsgFlagsSet(appCtx, j); - EXPECT_EQ(result[j], ret); - } DeleteAppSpawningCtx(appCtx); DeleteAppSpawnMgr(mgr); } diff --git a/test/unittest/app_spawn_standard_test/app_spawn_cgroup_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_cgroup_test.cpp index 5f7d4e9413126a7302cb97f45cffb8c02648a7a8..b89fc1626a793e0ecb682696b854c37ac6537033 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_cgroup_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_cgroup_test.cpp @@ -90,7 +90,6 @@ HWTEST_F(AppSpawnCGroupTest, App_Spawn_CGroup_001, TestSize.Level0) APPSPAWN_CHECK(ret == 0, break, "Failed to get real path errno: %{public}d", errno); APPSPAWN_CHECK(strstr(path, "200") != nullptr && strstr(path, "33") != nullptr && strstr(path, name) != nullptr, break, "Invalid path: %s", path); - ret = 0; } while (0); if (appInfo) { free(appInfo); @@ -165,8 +164,7 @@ HWTEST_F(AppSpawnCGroupTest, App_Spawn_CGroup_003, TestSize.Level0) content = AppSpawnCreateContent(APPSPAWN_SOCKET_NAME, path, sizeof(path), MODE_FOR_APP_SPAWN); APPSPAWN_CHECK_ONLY_EXPER(content != nullptr, break); - ProcessMgrHookExecute(STAGE_SERVER_APP_DIED, content, appInfo); - ret = 0; + ret = ProcessMgrHookExecute(STAGE_SERVER_APP_DIED, content, appInfo); } while (0); if (appInfo) { free(appInfo); @@ -227,8 +225,7 @@ HWTEST_F(AppSpawnCGroupTest, App_Spawn_CGroup_005, TestSize.Level0) content = AppSpawnCreateContent(APPSPAWN_SOCKET_NAME, path, sizeof(path), MODE_FOR_NWEB_SPAWN); APPSPAWN_CHECK_ONLY_EXPER(content != nullptr, break); - ProcessMgrHookExecute(STAGE_SERVER_APP_DIED, content, appInfo); - ret = 0; + ret = ProcessMgrHookExecute(STAGE_SERVER_APP_DIED, content, appInfo); } while (0); if (appInfo) { free(appInfo); diff --git a/test/unittest/app_spawn_standard_test/app_spawn_child_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_child_test.cpp index 4552f66efecee86f1523be2e5be83f048a8a4ae2..3c863d40d5aabd04dde05c05306f319f5f30911c 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_child_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_child_test.cpp @@ -1228,7 +1228,6 @@ HWTEST_F(AppSpawnChildTest, App_Spawn_Cold_Run_001, TestSize.Level0) // set cold start flags AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_COLD_BOOT); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); @@ -1243,7 +1242,6 @@ HWTEST_F(AppSpawnChildTest, App_Spawn_Cold_Run_001, TestSize.Level0) // child run in TestRunChildProcessor RegChildLooper(content, TestRunChildProcessor); content->runAppSpawn(content, args->argc, args->argv); - ret = 0; } while (0); if (args) { free(args); @@ -1269,7 +1267,6 @@ HWTEST_F(AppSpawnChildTest, App_Spawn_Cold_Run_002, TestSize.Level0) // set cold start flags AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_COLD_BOOT); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); @@ -1285,7 +1282,6 @@ HWTEST_F(AppSpawnChildTest, App_Spawn_Cold_Run_002, TestSize.Level0) // child run in TestRunChildProcessor RegChildLooper(content, TestRunChildProcessor); content->runAppSpawn(content, args->argc, args->argv); - ret = 0; } while (0); if (args) { free(args); @@ -1318,7 +1314,6 @@ HWTEST_F(AppSpawnChildTest, App_Spawn_Cold_Run_003, TestSize.Level0) AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ASANENABLED); AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_GWP_ENABLED_FORCE); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); @@ -1334,7 +1329,6 @@ HWTEST_F(AppSpawnChildTest, App_Spawn_Cold_Run_003, TestSize.Level0) // child run in TestRunChildProcessor RegChildLooper(content, TestRunChildProcessor); content->runAppSpawn(content, args->argc, args->argv); - ret = 0; } while (0); if (args) { free(args); @@ -1367,7 +1361,6 @@ HWTEST_F(AppSpawnChildTest, App_Spawn_Cold_Run_004, TestSize.Level0) AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ASANENABLED); AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_GWP_ENABLED_NORMAL); - ret = APPSPAWN_ARG_INVALID; property = g_testHelper.GetAppProperty(clientHandle, reqHandle); APPSPAWN_CHECK_ONLY_EXPER(property != nullptr, break); @@ -1386,7 +1379,6 @@ HWTEST_F(AppSpawnChildTest, App_Spawn_Cold_Run_004, TestSize.Level0) RegChildLooper(content, TestRunChildProcessor); content->runAppSpawn(content, args->argc, args->argv); property = nullptr; - ret = 0; } while (0); if (args) { free(args); diff --git a/test/unittest/app_spawn_standard_test/app_spawn_cold_run_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_cold_run_test.cpp index 77d3fcce0c2b13110fcaaf8f50793dc187a0d246..879123e851c778ab316e80bca258ee2145004c27 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_cold_run_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_cold_run_test.cpp @@ -140,16 +140,15 @@ HWTEST_F(AppSpawnColdRunTest, App_Spawn_Cold_Run_001, TestSize.Level0) // set cold start flags AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_COLD_BOOT); - ret = -1; + int msgRet = -1; node->flags |= STUB_NEED_CHECK; node->arg = reinterpret_cast(HandleExecvStub); AppSpawnResult result = {}; - ret = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); + msgRet = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); APPSPAWN_LOGV("App_Spawn_Cold_Run_001 Kill pid %{public}d %{public}d", result.pid, result.result); - if (ret == 0 && result.pid > 0) { + if (msgRet == 0 && result.pid > 0) { kill(result.pid, SIGKILL); } - ret = 0; } while (0); AppSpawnClientDestroy(clientHandle); ASSERT_EQ(ret, 0); @@ -168,16 +167,15 @@ HWTEST_F(AppSpawnColdRunTest, App_Spawn_Cold_Run_002, TestSize.Level0) // set cold start flags AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_COLD_BOOT); - ret = -1; + int msgRet = -1; node->flags |= STUB_NEED_CHECK; node->arg = reinterpret_cast(HandleExecvStub); AppSpawnResult result = {}; - ret = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); + msgRet = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); APPSPAWN_LOGV("App_Spawn_Cold_Run_002 Kill pid %{public}d %{public}d", result.pid, result.result); - if (ret == 0 && result.pid > 0) { + if (msgRet == 0 && result.pid > 0) { kill(result.pid, SIGKILL); } - ret = 0; } while (0); AppSpawnClientDestroy(clientHandle); node->flags &= ~STUB_NEED_CHECK; @@ -202,16 +200,15 @@ HWTEST_F(AppSpawnColdRunTest, App_Spawn_Cold_Run_003, TestSize.Level0) // set cold start flags AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_COLD_BOOT); - ret = -1; + int msgRet = -1; node->flags |= STUB_NEED_CHECK; node->arg = reinterpret_cast(ExecvAbortStub); AppSpawnResult result = {}; - ret = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); + msgRet = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); APPSPAWN_LOGV("App_Spawn_Cold_Run_003 Kill pid %{public}d %{public}d", result.pid, result.result); - if (ret == 0 && result.pid > 0) { + if (msgRet == 0 && result.pid > 0) { kill(result.pid, SIGKILL); } - ret = 0; } while (0); AppSpawnClientDestroy(clientHandle); node->flags &= ~STUB_NEED_CHECK; @@ -235,16 +232,15 @@ HWTEST_F(AppSpawnColdRunTest, App_Spawn_Cold_Run_004, TestSize.Level0) // set cold start flags AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_COLD_BOOT); - ret = -1; + int msgRet = -1; node->flags |= STUB_NEED_CHECK; node->arg = reinterpret_cast(ExecvTimeoutStub); AppSpawnResult result = {}; - ret = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); + msgRet = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); APPSPAWN_LOGV("App_Spawn_Cold_Run_004 Kill pid %{public}d %{public}d", result.pid, result.result); - if (ret == 0 && result.pid > 0) { + if (msgRet == 0 && result.pid > 0) { kill(result.pid, SIGKILL); } - ret = 0; } while (0); AppSpawnClientDestroy(clientHandle); node->flags &= ~STUB_NEED_CHECK; @@ -262,9 +258,9 @@ HWTEST_F(AppSpawnColdRunTest, App_Spawn_Cold_Run_005, TestSize.Level0) appProperty.message->msgHeader.msgLen = 1024; char msg[] = "test-xxx-xxx"; appProperty.message->buffer = (uint8_t *)msg; - AppSpawnClient client = {0, 1}; struct ListNode node; - appProperty.client = client; + appProperty.client.id = 0; + appProperty.client.flags = 1; appProperty.node = node; appProperty.forkCtx.fd[0] = 0; appProperty.forkCtx.fd[1] = 1; @@ -275,8 +271,8 @@ HWTEST_F(AppSpawnColdRunTest, App_Spawn_Cold_Run_005, TestSize.Level0) AppSpawnMgr spawnMgr; spawnMgr.content = content; - ret = AppSpawnColdStartApp(&content, &client); - ASSERT_EQ(ret, APPSPAWN_SYSTEM_ERROR); + ret = AppSpawnColdStartApp(&content, &appProperty.client); + ASSERT_EQ(ret, 0); free(appProperty.message); } } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/app_spawn_standard_test/app_spawn_common_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_common_test.cpp index 266cb7beae1c362dcfa3a8b6c408db3199bafdce..6f028823babe7eba2b42b635d40632eb5f7a82ba 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_common_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_common_test.cpp @@ -761,7 +761,8 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_003, TestSize.Level0) APPSPAWN_CHECK(reqHandle != INVALID_REQ_HANDLE, break, "Failed to create req %{public}s", APPSPAWN_SERVER_NAME); const char *permissions = "{\"name\":\"Permissions\",\"ohos.encaps.count\":0,\"permissions\":" - "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225},{\"ohos.permission.string\":\"test\"}," + "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225}," + "{\"ohos.permission.string\":\"{\\\"key\\\":\\\"value\\\"}\"}," "{\"ohos.permission.array\":[1,2,3,4,5]}]}"; ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_JIT_PERMISSIONS, reinterpret_cast(const_cast(permissions)), strlen(permissions) + 1); @@ -775,7 +776,8 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_003, TestSize.Level0) ret = SpawnSetPermissions(property, &encapsInfo); } while (0); - EXPECT_EQ(ret, APPSPAWN_ARG_INVALID); + EXPECT_EQ(ret, 0); + EXPECT_EQ(encapsInfo.encapsCount, 0); DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); FreeEncapsInfo(&encapsInfo); @@ -815,41 +817,47 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_004, TestSize.Level0) HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_005, TestSize.Level0) { UserEncaps encapsInfo = {0}; - int ret = AddMembersToEncapsInfo(NULL, &encapsInfo); - EXPECT_EQ(ret, APPSPAWN_ARG_INVALID); + int ret = AddMembersToEncapsInfo(NULL, &encapsInfo, 0); + EXPECT_EQ(ret, 0); } HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_006, TestSize.Level0) { const char encapsJsonStr[] = "{\"name\":\"Permissions\",\"ohos.encaps.count\":5,\"permissions\":" - "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225},{\"ohos.permission.string\":\"test\"}," + "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225}," + "{\"ohos.permission.string\":\"{\\\"key\\\":\\\"value\\\"}\"}," "{\"ohos.permission.array\":[1,2,3,4,5]}]}"; cJSON *encapsJson = cJSON_Parse(encapsJsonStr); EXPECT_NE(encapsJson, nullptr); - cJSON *permissions = cJSON_GetObjectItemCaseSensitive(encapsJson, "permissions"); - EXPECT_NE(permissions, nullptr); - cJSON *emptyItem = cJSON_CreateObject(); - EXPECT_TRUE(cJSON_AddItemToArray(permissions, emptyItem)); - UserEncaps encapsInfo = {0}; - int ret = AddMembersToEncapsInfo(encapsJson, &encapsInfo); - EXPECT_EQ(ret, APPSPAWN_ERROR_UTILS_DECODE_JSON_FAIL); + int count = 0; + cJSON *permissions = GetEncapsPermissions(encapsJson, &count); + EXPECT_EQ(permissions, nullptr); + EXPECT_EQ(count, 0); cJSON_Delete(encapsJson); - FreeEncapsInfo(&encapsInfo); } HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_007, TestSize.Level0) { const char encapsJsonStr[] = "{\"name\":\"Permissions\",\"ohos.encaps.count\":4,\"permissions\":" - "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225},{\"ohos.permission.string\":\"test\"}," - "{\"ohos.permission.array\":[1,\"abc\",3,4,5]}]}"; + "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225}," + "{\"ohos.permission.string\":\"{\\\"key\\\":\\\"value\\\"}\"}," + "{\"ohos.permission.array\":[1,\"{\\\"key\\\":\\\"value\\\"}\",3,4,5]}]}"; cJSON *encapsJson = cJSON_Parse(encapsJsonStr); EXPECT_NE(encapsJson, nullptr); + int count = 0; + cJSON *permissions = GetEncapsPermissions(encapsJson, &count); + EXPECT_NE(permissions, nullptr); + EXPECT_EQ(count, 4); + UserEncaps encapsInfo = {0}; - int ret = AddMembersToEncapsInfo(encapsJson, &encapsInfo); + encapsInfo.encap = (UserEncap *)calloc(count, sizeof(UserEncap)); + EXPECT_NE(encapsInfo.encap, nullptr); + int ret = AddMembersToEncapsInfo(permissions, &encapsInfo, count); EXPECT_EQ(ret, APPSPAWN_ERROR_UTILS_ADD_JSON_FAIL); + EXPECT_EQ(encapsInfo.encapsCount, 3); cJSON_Delete(encapsJson); FreeEncapsInfo(&encapsInfo); @@ -989,7 +997,8 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_014, TestSize.Level0) HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_015, TestSize.Level0) { // key len = 64 + "\0" - const char permissionItemStr[] = "{\"ohos.permission.strarrayabcdefghijklmnopqrstuvwxyzaaaaaaaaaaaaaa\":\"abc\"}"; + const char permissionItemStr[] = "{\"ohos.permission.strarrayabcdefghijklmnopqrstuvwxyzaaaaaaaaaaaaaa\":" + "\"{\\\"key\\\":\\\"value\\\"}\"}"; cJSON *permissionItem = cJSON_Parse(permissionItemStr); EXPECT_NE(permissionItem, nullptr); @@ -1006,7 +1015,8 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_015, TestSize.Level0) HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_016, TestSize.Level0) { // key len = 63 + "\0" - const char permissionItemStr[] = "{\"ohos.permission.strarrayabcdefghijklmnopqrstuvwxyzaaaaaaaaaaaaa\":\"abc\"}"; + const char permissionItemStr[] = "{\"ohos.permission.strarrayabcdefghijklmnopqrstuvwxyzaaaaaaaaaaaaa\":" + "\"{\\\"key\\\":\\\"value\\\"}\"}"; cJSON *permissionItem = cJSON_Parse(permissionItemStr); EXPECT_NE(permissionItem, nullptr); @@ -1062,12 +1072,12 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_019, TestSize.Level0) cJSON *encapsJson = cJSON_Parse(encapsJsonStr); EXPECT_NE(encapsJson, nullptr); - UserEncaps encapsInfo = {0}; - int ret = AddMembersToEncapsInfo(encapsJson, &encapsInfo); - EXPECT_EQ(ret, APPSPAWN_ARG_INVALID); + int count = 0; + cJSON *permissions = GetEncapsPermissions(encapsJson, &count); + EXPECT_EQ(permissions, nullptr); + EXPECT_EQ(count, 0); cJSON_Delete(encapsJson); - FreeEncapsInfo(&encapsInfo); } HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_020, TestSize.Level0) @@ -1079,12 +1089,12 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_020, TestSize.Level0) cJSON *encapsJson = cJSON_Parse(encapsJsonStr); EXPECT_NE(encapsJson, nullptr); - UserEncaps encapsInfo = {0}; - int ret = AddMembersToEncapsInfo(encapsJson, &encapsInfo); - EXPECT_EQ(ret, APPSPAWN_ARG_INVALID); + int count = 0; + cJSON *permissions = GetEncapsPermissions(encapsJson, &count); + EXPECT_EQ(permissions, nullptr); + EXPECT_EQ(count, 0); cJSON_Delete(encapsJson); - FreeEncapsInfo(&encapsInfo); } HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_021, TestSize.Level0) @@ -1225,12 +1235,12 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_029, TestSize.Level0) cJSON *encapsJson = cJSON_Parse(encapsJsonStr); EXPECT_NE(encapsJson, nullptr); - UserEncaps encapsInfo = {0}; - int ret = AddMembersToEncapsInfo(encapsJson, &encapsInfo); - EXPECT_EQ(ret, APPSPAWN_ARG_INVALID); + int count = 0; + cJSON *permissions = GetEncapsPermissions(encapsJson, &count); + EXPECT_EQ(permissions, nullptr); + EXPECT_EQ(count, 0); cJSON_Delete(encapsJson); - FreeEncapsInfo(&encapsInfo); } HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_030, TestSize.Level0) @@ -1248,7 +1258,8 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_030, TestSize.Level0) APPSPAWN_CHECK(reqHandle != INVALID_REQ_HANDLE, break, "Failed to create req %{public}s", APPSPAWN_SERVER_NAME); const char *permissions = "{\"name\":\"Permissions\",\"ohos.encaps.count\":4,\"permissions\":" - "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225},{\"ohos.permission.string\":\"test\"}," + "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225}," + "{\"ohos.permission.string\":\"{\\\"key\\\":\\\"value\\\"}\"}," "{\"ohos.permission.array\":[1,2,3,4,5]}]}"; ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_JIT_PERMISSIONS, reinterpret_cast(const_cast(permissions)), strlen(permissions) + 1); @@ -1284,7 +1295,8 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_031, TestSize.Level0) APPSPAWN_CHECK(reqHandle != INVALID_REQ_HANDLE, break, "Failed to create req %{public}s", APPSPAWN_SERVER_NAME); const char *permissions = "{\"name\":\"Permissions\",\"ohos.encaps.count\":4,\"permissions\":" - "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225},{\"ohos.permission.string\":\"test\"}," + "[{\"ohos.permission.bool\":true},{\"ohos.permission.int\":3225}," + "{\"ohos.permission.string\":\"{\\\"key\\\":\\\"value\\\"}\"}," "{\"ohos.permission.array\":[1,2,3,4,5]}]}"; ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_JIT_PERMISSIONS, reinterpret_cast(const_cast(permissions)), strlen(permissions) + 1); @@ -1471,7 +1483,7 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_SetCapabilities, TestSize.Level0) // create msg ret = AppSpawnClientInit(NWEBSPAWN_SERVER_NAME, &clientHandle); APPSPAWN_CHECK(ret == 0, break, "Failed to create reqMgr %{public}s", NWEBSPAWN_SERVER_NAME); - reqHandle = g_testHelper.CreateMsg(clientHandle, MSG_APP_SPAWN, 0); + reqHandle = g_testHelper.CreateMsg(clientHandle, MSG_SPAWN_NATIVE_PROCESS, 0); APPSPAWN_CHECK(reqHandle != INVALID_REQ_HANDLE, break, "Failed to create req %{public}s", NWEBSPAWN_SERVER_NAME); property = g_testHelper.GetAppProperty(clientHandle, reqHandle); @@ -1483,5 +1495,4 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_SetCapabilities, TestSize.Level0) DeleteAppSpawnMgr(mgr); ASSERT_EQ(ret, 0); } - } // namespace OHOS diff --git a/test/unittest/app_spawn_standard_test/app_spawn_kickdog_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_kickdog_test.cpp index 7b7760b3f2dbcc8f675c94a8531f2b838bee4a41..5706afbf64a64371a76db7a8bb19b8496fde29b9 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_kickdog_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_kickdog_test.cpp @@ -43,7 +43,7 @@ static int CheckFileContent(const char *filePath, const char *targetStr) char buf[100]; if (filePath == nullptr) { - printf("para invaild\n"); + printf("para invalid\n"); return -1; } diff --git a/test/unittest/app_spawn_standard_test/app_spawn_sandbox_debug_mode.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_debug_mode.cpp index 5b4c5d40f755c325c96f8fec883c820e94e0e03c..c8cea6191bbbff50e3dc019ffea3874902eaff9b 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_sandbox_debug_mode.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_debug_mode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025-2025 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_debug_mode.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_debug_mode.cpp index 04396530ace616249e7019c55741bf04439fc0be..396d0855994893c35d0f5581020b47e38a6d28b0 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_debug_mode.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_debug_mode.cpp @@ -46,7 +46,7 @@ extern "C" { } namespace OHOS { -AppSpawnTestHelper g_testHelper; +static AppSpawnTestHelper g_testHelper; class AppSpawnDebugSandboxTest : public testing::Test { public: static void SetUpTestCase() {} @@ -80,7 +80,7 @@ static AppSpawningCtx *AppSpawnDebugSandboxTestCreateAppSpawningCtx(int base) return nullptr; } -static SandboxContext *AppSpawnDebugSandboxTestGetSandboxContext(const AppSpawningCtx *property, int newbspawn) +static SandboxContext *AppSpawnDebugSandboxTestGetSandboxContext(const AppSpawningCtx *property, int nwebspawn) { AppSpawnMsgFlags *msgFlags = (AppSpawnMsgFlags *)GetAppProperty(property, TLV_MSG_FLAGS); APPSPAWN_CHECK(msgFlags != nullptr, return nullptr, "No msg flags in msg %{public}s", GetProcessName(property)); @@ -88,7 +88,7 @@ static SandboxContext *AppSpawnDebugSandboxTestGetSandboxContext(const AppSpawni SandboxContext *context = GetSandboxContext(); APPSPAWN_CHECK(context != nullptr, return nullptr, "Failed to get context"); - context->nwebspawn = newbspawn; + context->nwebspawn = nwebspawn; context->bundleName = GetBundleName(property); context->bundleHasWps = strstr(context->bundleName, "wps") != nullptr; context->dlpBundle = strcmp(GetProcessName(property), "com.ohos.dlpmanager") == 0; @@ -104,7 +104,7 @@ static SandboxContext *AppSpawnDebugSandboxTestGetSandboxContext(const AppSpawni /** * @tc.name: InstallDebugSandbox_ShouldReturnInvalidArg_WhenPropertyIsNull - * @tc.desc: 测试当 property 为NULL 时, 函数应返回 APPSPAWN_ARG_INVAILD. + * @tc.desc: 测试当 property 为 NULL 时,函数应返回 APPSPAWN_ARG_INVALID. * @tc.number: InstallDebugSandboxTest_001 */ HWTEST_F(AppSpawnDebugSandboxTest, ATC_InstallDebugSandbox_ShouldReturnInvalidArg_WhenPropertyIsNull, TestSize.Level0) @@ -119,7 +119,7 @@ HWTEST_F(AppSpawnDebugSandboxTest, ATC_InstallDebugSandbox_ShouldReturnInvalidAr /** * @tc.name: InstallDebugSandbox_ShouldReturnInvalidArg_WhenContentIsNull - * @tc.desc: 测试当 content 为NULL 时, 函数应返回 APPSPAWN_ARG_INVAILD. + * @tc.desc: 测试当 content 为 NULL 时,函数应返回 APPSPAWN_ARG_INVALID. * @tc.number: InstallDebugSandboxTest_002 */ HWTEST_F(AppSpawnDebugSandboxTest, ATC_InstallDebugSandbox_ShouldReturnInvalidArg_WhenContentIsNull, TestSize.Level0) @@ -137,7 +137,7 @@ HWTEST_F(AppSpawnDebugSandboxTest, ATC_InstallDebugSandbox_ShouldReturnInvalidAr * @tc.desc: 测试当不在开发者模式时,函数应返回 0. * @tc.number: InstallDebugSandboxTest_003 */ -HWTEST_F(AppSpawnDebugSandboxTest, ATC_InstallDebugSandbox_ShouldReturnZero_WhenNotDeveloperMode, TestSize.Level0) +HWTEST_F(AppSpawnDebugSandboxTest, InstallDebugSandbox_ShouldReturnZero_WhenNotDeveloperMode, TestSize.Level0) { AppSpawnMgr *mgr = CreateAppSpawnMgr(MODE_FOR_APP_SPAWN); AppSpawningCtx *property = AppSpawnDebugSandboxTestCreateAppSpawningCtx(0); @@ -167,11 +167,11 @@ HWTEST_F(AppSpawnDebugSandboxTest, ATC_InstallDebugSandbox_ShouldReturnZero_When /** * @tc.name: InstallDebugSandbox_ShouldReturnSandboxInvalid_WhenSandboxConfigNotFound - * @tc.desc: 测试当找不到沙箱配置时,函数3应返回 APPSPAWN_SANDBOX_INVALID. + * @tc.desc: 测试当找不到沙箱配置时,函数应返回 APPSPAWN_SANDBOX_INVALID. * @tc.number: InstallDebugSandboxTest_005 */ HWTEST_F(AppSpawnDebugSandboxTest, - ATC_InstallDebugSandbox_ShouldReturnSandboxInvalid_WhenSandboxConfigNotFound, TestSize.Level0) + InstallDebugSandbox_ShouldReturnSandboxInvalid_WhenSandboxConfigNotFound, TestSize.Level0) { AppSpawnMgr *mgr = CreateAppSpawnMgr(MODE_FOR_APP_SPAWN); AppSpawningCtx *property = AppSpawnDebugSandboxTestCreateAppSpawningCtx(1); @@ -185,11 +185,11 @@ HWTEST_F(AppSpawnDebugSandboxTest, /** * @tc.name: InstallDebugSandbox_ShouldReturnSystemError_WhenSandboxContextIsNull - * @tc.desc: 测试当沙箱上下文获取失败时,函数应返回 APPSPAWN_SYSTEM_ERROR + * @tc.desc: 测试当沙箱上下文获取失败时,函数应返回 APPSPAWN_SYSTEM_ERROR. * @tc.number: InstallDebugSandboxTest_006 */ HWTEST_F(AppSpawnDebugSandboxTest, - ATC_InstallDebugSandbox_ShouldReturnSystemError_WhenSandboxContextIsNull, TestSize.Level0) + InstallDebugSandbox_ShouldReturnSystemError_WhenSandboxContextIsNull, TestSize.Level0) { AppSpawnMgr *mgr = CreateAppSpawnMgr(MODE_FOR_APP_SPAWN); AppSpawningCtx *property = AppSpawnDebugSandboxTestCreateAppSpawningCtx(1); @@ -201,4 +201,5 @@ HWTEST_F(AppSpawnDebugSandboxTest, // delete DeleteAppSpawningCtx(property); DeleteAppSpawnMgr(mgr); +} } \ No newline at end of file diff --git a/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_test.cpp index 92bc3010541e21ef0b9679b3ecdb3835450e54a6..2fc9eecd283036102f6f0bdb84f9152d2e0815e3 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_test.cpp @@ -677,7 +677,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Variable_009, TestSize.Level0) HWTEST_F(AppSpawnSandboxTest, App_Spawn_Permission_01, TestSize.Level0) { AppSpawnSandboxCfg *sandbox = nullptr; - int ret = -1; do { sandbox = CreateAppSpawnSandbox(EXT_DATA_APP_SANDBOX); APPSPAWN_CHECK_ONLY_EXPER(sandbox != nullptr, break); @@ -699,13 +698,12 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Permission_01, TestSize.Level0) const SandboxPermissionNode *node = GetPermissionNodeInQueue(&sandbox->permissionQueue, permission); APPSPAWN_CHECK_ONLY_EXPER(node == nullptr, break); node = GetPermissionNodeInQueue(nullptr, permission); + ASSERT_NE(node, nullptr); APPSPAWN_CHECK_ONLY_EXPER(node == nullptr, break); - ret = 0; } while (0); if (sandbox != nullptr) { sandbox->extData.freeNode(&sandbox->extData); } - ASSERT_EQ(ret, 0); } static int ProcessTestExpandConfig(const SandboxContext *context, @@ -915,18 +913,16 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_ExpandCfg_04, TestSize.Level0) HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_001, TestSize.Level0) { AppSpawnSandboxCfg *sandbox = nullptr; - int ret = -1; do { sandbox = CreateAppSpawnSandbox(EXT_DATA_APP_SANDBOX); APPSPAWN_CHECK_ONLY_EXPER(sandbox != nullptr, break); LoadAppSandboxConfig(sandbox, EXT_DATA_APP_SANDBOX); sandbox->extData.dumpNode(&sandbox->extData); - ret = 0; } while (0); + ASSERT_NE(sandbox, nullptr); if (sandbox != nullptr) { sandbox->extData.freeNode(&sandbox->extData); } - ASSERT_EQ(ret, 0); } /** @@ -970,7 +966,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_002, TestSize.Level0) pathNode = reinterpret_cast(GetNextSandboxMountPathNode(section, &pathNode->sandboxNode)); ASSERT_EQ(pathNode != nullptr, 1); ASSERT_EQ(pathNode->category, MOUNT_TMP_FUSE); - ret = 0; } while (0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); @@ -985,7 +980,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_002, TestSize.Level0) HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_003, TestSize.Level0) { AppSpawnSandboxCfg *sandbox = nullptr; - int ret = -1; do { sandbox = CreateAppSpawnSandbox(EXT_DATA_APP_SANDBOX); APPSPAWN_CHECK_ONLY_EXPER(sandbox != nullptr, break); @@ -1018,12 +1012,10 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_003, TestSize.Level0) ASSERT_EQ(linkNode != nullptr, 1); ASSERT_EQ(linkNode->checkErrorFlag == 0, 1); ASSERT_EQ((linkNode->destMode & (S_IRUSR | S_IWOTH | S_IRWXU)) == (S_IRUSR | S_IWOTH | S_IRWXU), 1); - ret = 0; } while (0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); } - ASSERT_EQ(ret, 0); } /** @@ -1033,7 +1025,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_003, TestSize.Level0) HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_004, TestSize.Level0) { AppSpawnSandboxCfg *sandbox = nullptr; - int ret = -1; do { sandbox = CreateAppSpawnSandbox(EXT_DATA_APP_SANDBOX); APPSPAWN_CHECK_ONLY_EXPER(sandbox != nullptr, break); @@ -1067,12 +1058,10 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_004, TestSize.Level0) ASSERT_EQ(linkNode != nullptr, 1); ASSERT_EQ(linkNode->checkErrorFlag == 0, 1); ASSERT_EQ((linkNode->destMode & (S_IRUSR | S_IWOTH | S_IRWXU)) == (S_IRUSR | S_IWOTH | S_IRWXU), 1); - ret = 0; } while (0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); } - ASSERT_EQ(ret, 0); } /** @@ -1082,7 +1071,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_004, TestSize.Level0) HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_005, TestSize.Level0) { AppSpawnSandboxCfg *sandbox = nullptr; - int ret = -1; do { sandbox = CreateAppSpawnSandbox(EXT_DATA_APP_SANDBOX); APPSPAWN_CHECK_ONLY_EXPER(sandbox != nullptr, break); @@ -1108,12 +1096,10 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_005, TestSize.Level0) ASSERT_EQ(pathNode->checkErrorFlag == 1, 1); // set ASSERT_EQ((pathNode->destMode & (S_IRUSR | S_IWOTH | S_IRWXU)) == (S_IRUSR | S_IWOTH | S_IRWXU), 1); ASSERT_EQ((pathNode->appAplName != nullptr) && (strcmp(pathNode->appAplName, "system") == 0), 1); - ret = 0; } while (0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); } - ASSERT_EQ(ret, 0); } /** @@ -1123,7 +1109,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_005, TestSize.Level0) HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_006, TestSize.Level0) { AppSpawnSandboxCfg *sandbox = nullptr; - int ret = -1; do { sandbox = CreateAppSpawnSandbox(EXT_DATA_APP_SANDBOX); APPSPAWN_CHECK_ONLY_EXPER(sandbox != nullptr, break); @@ -1148,12 +1133,10 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_cfg_006, TestSize.Level0) ASSERT_EQ(pathNode != nullptr, 1); ASSERT_EQ(strcmp(pathNode->source, "/data/app/el5//base/") == 0, 1); ASSERT_EQ(strcmp(pathNode->target, "/base") == 0, 1); - ret = 0; } while (0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); } - ASSERT_EQ(ret, 0); } /** * @brief 沙盒执行,能执行到对应的检查项,并且检查通过 @@ -1309,9 +1292,7 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_mount_003, TestSize.Level0) ret = MountSandboxConfigs(sandbox, property, 0); ASSERT_NE(ret, 0); ASSERT_NE(stub->result, 0); - ret = 0; } while (0); - ASSERT_EQ(ret, 0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); } @@ -1412,7 +1393,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_mount_005, TestSize.Level0) ret = MountSandboxConfigs(sandbox, property, 0); ASSERT_NE(ret, 0); ASSERT_NE(stub->result, 0); - ret = 0; } while (0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); @@ -1420,7 +1400,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_mount_005, TestSize.Level0) stub->flags &= ~STUB_NEED_CHECK; DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); - ASSERT_EQ(ret, 0); } /** @@ -1470,7 +1449,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_mount_006, TestSize.Level0) ret = MountSandboxConfigs(sandbox, property, 0); ASSERT_NE(ret, 0); // do not check result ASSERT_NE(stub->result, 0); - ret = 0; } while (0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); @@ -1478,7 +1456,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_mount_006, TestSize.Level0) stub->flags &= ~STUB_NEED_CHECK; DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); - ASSERT_EQ(ret, 0); } /** @@ -1526,7 +1503,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_mount_007, TestSize.Level0) ret = MountSandboxConfigs(sandbox, property, 0); ASSERT_NE(ret, 0); ASSERT_NE(stub->result, 0); - ret = 0; } while (0); if (sandbox) { DeleteAppSpawnSandbox(sandbox); @@ -1534,7 +1510,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_mount_007, TestSize.Level0) stub->flags &= ~STUB_NEED_CHECK; DeleteAppSpawningCtx(property); AppSpawnClientDestroy(clientHandle); - ASSERT_EQ(ret, 0); } /** diff --git a/test/unittest/app_spawn_standard_test/app_spawn_sandbox_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_test.cpp index 1d488af14a3f2d4cebd995b58ed1d161feeacd34..0434a39c731c6c7599c8e4af874293e90ea7f11f 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_sandbox_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_test.cpp @@ -652,7 +652,7 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_26, TestSize.Level0) cJSON *j_config2 = cJSON_Parse(mJsconfig2.c_str()); ASSERT_NE(j_config2, nullptr); int32_t ret = AppSpawn::SandboxCore::DoSandboxFileCommonBind(appProperty, j_config2); - EXPECT_NE(ret, 0); + EXPECT_EQ(ret, 0); cJSON_Delete(j_config2); DeleteAppSpawningCtx(appProperty); @@ -866,7 +866,7 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_31, TestSize.Level0) cJSON *j_config2 = cJSON_Parse(mJsconfig2.c_str()); ASSERT_NE(j_config2, nullptr); ret = AppSpawn::SandboxCore::DoAllMntPointsMount(appProperty, j_config2, nullptr); - EXPECT_NE(ret, 0); + EXPECT_EQ(ret, 0); cJSON_Delete(j_config1); cJSON_Delete(j_config2); @@ -1747,9 +1747,8 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_dec_02, TestSize.Level0) int decPathSize = mountConfig.decPaths.size(); EXPECT_EQ(decPathSize, 0); } - EXPECT_EQ(ret, 0); } while (0); - + EXPECT_EQ(ret, 0); cJSON_Delete(j_config); DeleteAppSpawningCtx(appProperty); } @@ -1793,7 +1792,6 @@ HWTEST_F(AppSpawnSandboxTest, App_Spawn_Sandbox_dec_03, TestSize.Level0) } EXPECT_EQ(ret, 0); } while (0); - cJSON_Delete(j_config); DeleteAppSpawningCtx(appProperty); } @@ -2440,4 +2438,136 @@ HWTEST_F(AppSpawnSandboxTest, Handle_Flag_Point_PreInstall_Shell_Hap_002, TestSi EXPECT_EQ(res, 0); DeleteAppSpawningCtx(appProperty); } + +/** + * @tc.name: Handle_Dlp_Mount_01 + * @tc.desc: Test mounting the fuse directory in dlpmanager. + * @tc.type: FUNC + */ +HWTEST_F(AppSpawnSandboxTest, Handle_Dlp_Mount_01, TestSize.Level0) +{ + AppSpawningCtx *spawningCtx = GetTestAppProperty(); + ASSERT_EQ(spawningCtx != nullptr, 1); + AppSpawnMsgDacInfo *dacInfo = reinterpret_cast(GetAppProperty(spawningCtx, TLV_DAC_INFO)); + ASSERT_EQ(dacInfo != nullptr, 1); + + int32_t ret = AppSpawn::SandboxCore::HandleDlpMount(dacInfo); + + DeleteAppSpawningCtx(spawningCtx); +} + +/** + * @tc.name: Check_Dlp_Mount_01 + * @tc.desc: Verify whether it is necessary to execute the mount of dlpmanager, when is dlpmanager. + * @tc.type: FUNC + */ +HWTEST_F(AppSpawnSandboxTest, Check_Dlp_Mount_01, TestSize.Level0) +{ + g_testHelper.SetProcessName("com.ohos.dlpmanager"); + AppSpawningCtx *spawningCtx = GetTestAppProperty(); + ASSERT_EQ(spawningCtx != nullptr, 1); + + bool ret = AppSpawn::SandboxCore::CheckDlpMount(spawningCtx); + EXPECT_EQ(ret, true); + + DeleteAppSpawningCtx(spawningCtx); +} + +/** + * @tc.name: Check_Dlp_Mount_02 + * @tc.desc: Verify whether it is necessary to execute the mount of dlpmanager, when is not dlpmanager. + * @tc.type: FUNC + */ +HWTEST_F(AppSpawnSandboxTest, Check_Dlp_Mount_02, TestSize.Level0) +{ + g_testHelper.SetProcessName("com.ohos.notepad"); + AppSpawningCtx *spawningCtx = GetTestAppProperty(); + ASSERT_EQ(spawningCtx != nullptr, 1); + + bool ret = AppSpawn::SandboxCore::CheckDlpMount(spawningCtx); + EXPECT_EQ(ret, false); + + DeleteAppSpawningCtx(spawningCtx); +} + +/** + * @tc.name: Set_App_Sandbox_Property_For_Dlp_01 + * @tc.desc: When dlpStatus is true and CheckDlpMount is true. + * @tc.type: FUNC + */ +HWTEST_F(AppSpawnSandboxTest, Set_App_Sandbox_Property_For_Dlp_01, TestSize.Level0) +{ + g_testHelper.SetTestGid(1000); + g_testHelper.SetTestUid(1000); + g_testHelper.SetProcessName("com.ohos.dlpmanager"); + std::vector &permissions = g_testHelper.GetPermissions(); + permissions.push_back("ohos.permission.ACCESS_DLP_FILE"); + + AppSpawningCtx *spawningCtx = GetTestAppProperty(); + ASSERT_EQ(spawningCtx != nullptr, 1); + bool ret = AppSpawn::SandboxCore::SetAppSandboxProperty(spawningCtx, CLONE_NEWPID); + EXPECT_EQ(ret, false); + + DeleteAppSpawningCtx(spawningCtx); +} + +/** + * @tc.name: Set_App_Sandbox_Property_For_Dlp_02 + * @tc.desc: When dlpStatus is true and CheckDlpMount is false. + * @tc.type: FUNC + */ +HWTEST_F(AppSpawnSandboxTest, Set_App_Sandbox_Property_For_Dlp_02, TestSize.Level0) +{ + g_testHelper.SetTestGid(1000); + g_testHelper.SetTestUid(1000); + g_testHelper.SetProcessName("com.ohos.notepad"); + std::vector &permissions = g_testHelper.GetPermissions(); + permissions.push_back("ohos.permission.ACCESS_DLP_FILE"); + + AppSpawningCtx *spawningCtx = GetTestAppProperty(); + ASSERT_EQ(spawningCtx != nullptr, 1); + bool ret = AppSpawn::SandboxCore::SetAppSandboxProperty(spawningCtx, CLONE_NEWPID); + EXPECT_EQ(ret, false); + + DeleteAppSpawningCtx(spawningCtx); +} + +/** + * @tc.name: Set_App_Sandbox_Property_For_Dlp_03 + * @tc.desc: When dlpStatus is false and CheckDlpMount is true. + * @tc.type: FUNC + */ +HWTEST_F(AppSpawnSandboxTest, Set_App_Sandbox_Property_For_Dlp_03, TestSize.Level0) +{ + g_testHelper.SetTestGid(1000); + g_testHelper.SetTestUid(1000); + g_testHelper.SetProcessName("com.ohos.dlpmanager"); + + AppSpawningCtx *spawningCtx = GetTestAppProperty(); + ASSERT_EQ(spawningCtx != nullptr, 1); + bool ret = AppSpawn::SandboxCore::SetAppSandboxProperty(spawningCtx, CLONE_NEWPID); + EXPECT_EQ(ret, false); + + DeleteAppSpawningCtx(spawningCtx); +} + +/** + * @tc.name: Set_App_Sandbox_Property_For_Dlp_04 + * @tc.desc: When dlpStatus is false and CheckDlpMount is true. + * @tc.type: FUNC + */ +HWTEST_F(AppSpawnSandboxTest, Set_App_Sandbox_Property_For_Dlp_04, TestSize.Level0) +{ + g_testHelper.SetTestGid(1000); + g_testHelper.SetTestUid(1000); + g_testHelper.SetProcessName("com.ohos.notepad"); + + AppSpawningCtx *spawningCtx = GetTestAppProperty(); + ASSERT_EQ(spawningCtx != nullptr, 1); + bool ret = AppSpawn::SandboxCore::SetAppSandboxProperty(spawningCtx, CLONE_NEWPID); + EXPECT_EQ(ret, false); + + DeleteAppSpawningCtx(spawningCtx); +} + } // namespace OHOS diff --git a/test/unittest/app_spawn_standard_test/app_spawn_sandboxmgr_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandboxmgr_test.cpp index 1f736325f2171b9ff1fdf2ce2baa5a075843f295..219854ad59007fdfed09ef447e9aa5a007602e88 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_sandboxmgr_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_sandboxmgr_test.cpp @@ -724,7 +724,7 @@ HWTEST_F(AppSpawnSandboxMgrTest, App_Spawn_Permission_003, TestSize.Level0) #else // nweb no permission, so max = 0 max = GetMaxPermissionIndex(clientHandle); - EXPECT_EQ(max, 0); + EXPECT_EQ(max, sizeof(g_spawnerPermissionList) / sizeof(g_spawnerPermissionList[0])); #endif AppSpawnClientDestroy(clientHandle); } diff --git a/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp index 6a920439b95c77717a9215bbb45be3601ef1ea85..47ce99fe6b5641caf632e577934fa7bf192d0b60 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp @@ -552,13 +552,11 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_Msg_002, TestSize.Level0) ret = testServer->CreateSendMsg(buffer, MSG_APP_SPAWN, msgLen, {}); APPSPAWN_CHECK(ret == 0, break, "Failed to create msg %{public}s", testServer->GetDefaultTestAppBundleName()); - ret = -1; int len = write(socketId, buffer.data(), msgLen - 10); // 10 APPSPAWN_CHECK(len > 0, break, "Failed to send msg %{public}s", testServer->GetDefaultTestAppBundleName()); // recv timeout len = RecvMsg(socketId, buffer.data(), buffer.size()); APPSPAWN_CHECK(len <= 0, break, "Failed to recv msg len: %{public}d", len); - ret = 0; } while (0); if (socketId >= 0) { CloseClientSocket(socketId); @@ -687,7 +685,6 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_Msg_005, TestSize.Level0) ret = respMsg->result.result; (void)RecvMsg(socketId, buffer2.data(), buffer2.size()); } while (0); - ret = 0; // test for case if (socketId >= 0) { CloseClientSocket(socketId); } @@ -1185,4 +1182,50 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_ConvertEnvValue_001, TestSize.Level0) EXPECT_EQ(strcmp(outEnv, "/path/to/lib/envtest"), 0); EXPECT_EQ(unsetenv("ENV_TEST_VALUE"), 0); } + +/** + * @brief 向appspawn发送MSG_LOAD_WEBLIB_IN_APPSPAWN类型的消息,传入任意包名 + * + */ +HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_LOAD_WEBLIB_IN_APPSPAWN_001, TestSize.Level0) +{ + int ret = 0; + AppSpawnClientHandle clientHandle = nullptr; + do { + ret = AppSpawnClientInit(APPSPAWN_SERVER_NAME, &clientHandle); + APPSPAWN_CHECK(ret == 0, break, "Failed to create client %{public}s", APPSPAWN_SERVER_NAME); + + AppSpawnReqMsgHandle reqHandle; + ret = AppSpawnReqMsgCreate(MSG_LOAD_WEBLIB_IN_APPSPAWN, "com.example.myapplication", &reqHandle); + AppSpawnResult result = {}; + ret = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); + APPSPAWN_CHECK(ret == 0, break, "Failed to send MSG_LOAD_WEBLIB_IN_APPSPAWN, ret %{public}d", ret); + } while (0); + + AppSpawnClientDestroy(clientHandle); + ASSERT_EQ(ret, 0); +} + +/** + * @brief 向appspawn发送MSG_UNLOAD_WEBLIB_IN_APPSPAWN类型的消息,传入任意包名 + * + */ +HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_UNLOAD_WEBLIB_IN_APPSPAWN_001, TestSize.Level0) +{ + int ret = 0; + AppSpawnClientHandle clientHandle = nullptr; + do { + ret = AppSpawnClientInit(APPSPAWN_SERVER_NAME, &clientHandle); + APPSPAWN_CHECK(ret == 0, break, "Failed to create client %{public}s", APPSPAWN_SERVER_NAME); + + AppSpawnReqMsgHandle reqHandle; + ret = AppSpawnReqMsgCreate(MSG_UNLOAD_WEBLIB_IN_APPSPAWN, "com.example.myapplication", &reqHandle); + AppSpawnResult result = {}; + ret = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); + APPSPAWN_CHECK(ret == 0, break, "Failed to send MSG_UNLOAD_WEBLIB_IN_APPSPAWN, ret %{public}d", ret); + } while (0); + + AppSpawnClientDestroy(clientHandle); + ASSERT_EQ(ret, 0); +} } // namespace OHOS diff --git a/test/unittest/app_spawn_standard_test/nweb_spawn_service_test.cpp b/test/unittest/app_spawn_standard_test/nweb_spawn_service_test.cpp index ccc8bcfd64fae564e6e1044551a209db42f4e397..7ef20cf1b9b00040808f3c748765dff4cd80bac4 100644 --- a/test/unittest/app_spawn_standard_test/nweb_spawn_service_test.cpp +++ b/test/unittest/app_spawn_standard_test/nweb_spawn_service_test.cpp @@ -265,13 +265,11 @@ HWTEST_F(NWebSpawnServiceTest, NWeb_Spawn_Msg_002, TestSize.Level0) ret = testServer->CreateSendMsg(buffer, MSG_APP_SPAWN, msgLen, {}); APPSPAWN_CHECK(ret == 0, break, "Failed to create msg %{public}s", testServer->GetDefaultTestAppBundleName()); - ret = -1; int len = write(socketId, buffer.data(), msgLen - 10); // 10 APPSPAWN_CHECK(len > 0, break, "Failed to send msg %{public}s", testServer->GetDefaultTestAppBundleName()); // recv timeout len = RecvMsg(socketId, buffer.data(), buffer.size()); APPSPAWN_CHECK(len <= 0, break, "Failed to recv msg len: %{public}d", len); - ret = 0; } while (0); if (socketId >= 0) { CloseClientSocket(socketId); diff --git a/test/unittest/app_spawn_test_helper.cpp b/test/unittest/app_spawn_test_helper.cpp index b85686d7c65dfa27957c62b257b3e730260a2825..61f730e1d7a4aaa6a20be5dd134aa3e9103c569c 100644 --- a/test/unittest/app_spawn_test_helper.cpp +++ b/test/unittest/app_spawn_test_helper.cpp @@ -58,6 +58,14 @@ uint32_t AppSpawnTestServer::serverId = 0; static int TestChildLoopRun(AppSpawnContent *content, AppSpawnClient *client) { APPSPAWN_LOGV("ChildLoopRun ..."); + AppSpawningCtx *property = (AppSpawningCtx *)client; + APPSPAWN_CHECK(content != NULL && property != NULL, return 0, "invlid param in clearEnv"); + int fd = property->forkCtx.fd[1]; + property->forkCtx.fd[1] = -1; + APPSPAWN_CHECK(fd >= 0, return 0, "invalid fd for notify parent"); + int ret = 0; + (void)write(fd, &ret, sizeof(ret)); + (void)close(fd); sleep(1); return 0; } diff --git a/test/unittest/app_spawn_test_helper.h b/test/unittest/app_spawn_test_helper.h index 4c9bfc33e483151c5b637c5657e6ee6e621320e8..4190f7575f7296b9cdaa2cd62b8647c203d33ec8 100644 --- a/test/unittest/app_spawn_test_helper.h +++ b/test/unittest/app_spawn_test_helper.h @@ -115,7 +115,7 @@ public: int CreateSocket(int type = 0); int CreateSendMsg(std::vector &buffer, uint32_t msgType, uint32_t &msgLen, const std::vector &addTlvFuncs); - const std::vector &GetPermissions() + std::vector &GetPermissions() { return permissions_; } @@ -149,7 +149,6 @@ private: int fdArg = -1; std::vector permissions_ = { const_cast("ohos.permission.MANAGE_PRIVATE_PHOTOS"), - const_cast("ohos.permission.FILE_CROSS_APP"), const_cast("ohos.permission.ACTIVATE_THEME_PACKAGE"), const_cast("ohos.permission.GET_WALLPAPER"), const_cast("ohos.permission.FILE_ACCESS_MANAGER") diff --git a/util/include/appspawn_error.h b/util/include/appspawn_error.h index ba0c73506fef0d3902737db8ad36d1ab3bb758cc..f3258678a4e2abebac61925f76f5a020bb6d6a60 100644 --- a/util/include/appspawn_error.h +++ b/util/include/appspawn_error.h @@ -84,12 +84,12 @@ typedef enum { typedef enum { APPSPAWN_ERROR_MSG_TO_LONG = DECLARE_APPSPAWN_ERRORCODE(APPSPAWN_SPAWNER, APPSPAWN_UTILS_COMMON, 0x0000), - APPSPAWN_ERROR_MSG_INVAILD, + APPSPAWN_ERROR_MSG_INVALID, } SpawnerErrorCode; typedef enum { - SANDBOX_ERROR_ARGS_INVAILD = DECLARE_APPSPAWN_ERRORCODE(APPSPAWN_SANDBOX, APPSPAWN_SANDBOX_COMMON, 0x0000), - SANDBOX_ERROR_MSG_INVAILD, + SANDBOX_ERROR_ARGS_INVALID = DECLARE_APPSPAWN_ERRORCODE(APPSPAWN_SANDBOX, APPSPAWN_SANDBOX_COMMON, 0x0000), + SANDBOX_ERROR_MSG_INVALID, } SandboxErrorCode; #ifdef __cplusplus