From 7d124fe1627a92aaafa0b62c5946424dc840dfdc Mon Sep 17 00:00:00 2001 From: fan-jingle Date: Fri, 1 Aug 2025 15:56:30 +0800 Subject: [PATCH 01/21] =?UTF-8?q?fix:=20ipc=E7=BC=96=E8=AF=91=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fan-jingle --- modules/native_adapter/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/native_adapter/BUILD.gn b/modules/native_adapter/BUILD.gn index e1819d51..c5fd69d7 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" ] -- Gitee From 7138f54926ebfb286c3c77d126d3dc0b30c81b72 Mon Sep 17 00:00:00 2001 From: chennuo Date: Mon, 18 Aug 2025 10:32:13 +0800 Subject: [PATCH 02/21] fix bugs:nosharefsDocsDir Signed-off-by: chennuo --- modules/sandbox/normal/sandbox_shared_mount.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/sandbox/normal/sandbox_shared_mount.cpp b/modules/sandbox/normal/sandbox_shared_mount.cpp index e168faa5..860af6a2 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, -- Gitee From 76a725d356966a19e90d7540d90e7d6df32b0d76 Mon Sep 17 00:00:00 2001 From: wanglei Date: Tue, 19 Aug 2025 02:45:30 +0000 Subject: [PATCH 03/21] =?UTF-8?q?=E8=A1=A5=E5=85=85UT=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanglei --- .../app_spawn_service_test.cpp | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) 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 6a920439..f0441dcd 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 @@ -1185,4 +1185,54 @@ 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类型的消息,传入arkweb包名 + * + */ +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); + + char bundleName[64] = {0}; + ret = GetParameter("persist.arkwebcore.package_name", "", bundleName, 64); + APPSPAWN_CHECK(ret == 0, break, "Failed to get arkweb bundleName"); + + AppSpawnReqMsgHandle reqHandle; + ret = AppSpawnReqMsgCreate(MSG_LOAD_WEBLIB_IN_APPSPAWN, bundleName, &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_LOAD_WEBLIB_IN_APPSPAWN类型的消息,传入空字符串 + * + */ +HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_LOAD_WEBLIB_IN_APPSPAWN_002, 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, "", &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); +} } // namespace OHOS -- Gitee From 47c18a424c7eb71c709a8a65bd911200a80afb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=B5=A9?= Date: Mon, 18 Aug 2025 16:14:02 +0800 Subject: [PATCH 04/21] modify res MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨浩 --- common/appspawn_server.c | 13 +++++++----- modules/ace_adapter/ace_adapter.cpp | 20 ++++++++++++++++--- standard/appspawn_service.c | 1 + .../app_spawn_cold_run_test.cpp | 8 ++++---- test/unittest/app_spawn_test_helper.cpp | 8 ++++++++ 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/common/appspawn_server.c b/common/appspawn_server.c index 2b7b2cea..c1d41ccd 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/modules/ace_adapter/ace_adapter.cpp b/modules/ace_adapter/ace_adapter.cpp index eb42eacd..e38f114d 100644 --- a/modules/ace_adapter/ace_adapter.cpp +++ b/modules/ace_adapter/ace_adapter.cpp @@ -220,6 +220,20 @@ 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}u %{public}zd", client->id, written); +} + APPSPAWN_STATIC int RunChildThread(const AppSpawnMgr *content, const AppSpawningCtx *property) { std::string checkExit; @@ -230,10 +244,10 @@ APPSPAWN_STATIC int RunChildThread(const AppSpawnMgr *content, const AppSpawning 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 +279,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/standard/appspawn_service.c b/standard/appspawn_service.c index 8a0a5989..5f9bceb9 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -1115,6 +1115,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)); 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 77d3fcce..ebc0e292 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 @@ -262,9 +262,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 +275,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_test_helper.cpp b/test/unittest/app_spawn_test_helper.cpp index b85686d7..61f730e1 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; } -- Gitee From 72d453db5da0543e922c3892f99fc6ecc3cb67ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Wed, 20 Aug 2025 11:17:36 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- .../sub_startup_appspawn_cgroups_0100.json | 14 --- .../sub_startup_appspawn_cgroups_0100.py | 75 ------------- .../sub_startup_appspawn_cgroups_0200.json | 14 --- .../sub_startup_appspawn_cgroups_0200.py | 73 ------------ .../sub_startup_appspawn_cgroups_0300.json | 14 --- .../sub_startup_appspawn_cgroups_0300.py | 73 ------------ .../sub_startup_appspawn_coldstart_0100.json | 15 --- .../sub_startup_appspawn_coldstart_0100.py | 59 ---------- ...startup_appspawn_coldstartablity_0100.json | 15 --- ...b_startup_appspawn_coldstartablity_0100.py | 61 ---------- ...startup_appspawn_coldstartablity_0200.json | 15 --- ...b_startup_appspawn_coldstartablity_0200.py | 60 ---------- .../sub_startup_appspawn_debughap_0100.json | 14 --- .../sub_startup_appspawn_debughap_0100.py | 64 ----------- .../sub_startup_appspawn_debughap_0200.json | 14 --- .../sub_startup_appspawn_debughap_0200.py | 64 ----------- .../sub_startup_appspawn_debughap_0300.json | 14 --- .../sub_startup_appspawn_debughap_0300.py | 79 ------------- .../sub_startup_appspawn_debughap_0500.json | 14 --- .../sub_startup_appspawn_debughap_0500.py | 64 ----------- .../sub_startup_appspawn_debughap_0600.json | 15 --- .../sub_startup_appspawn_debughap_0600.py | 64 ----------- .../sub_startup_appspawn_debughap_0700.json | 15 --- .../sub_startup_appspawn_debughap_0700.py | 78 ------------- .../sub_startup_appspawn_debughap_0800.json | 14 --- .../sub_startup_appspawn_debughap_0800.py | 104 ------------------ .../sub_startup_appspawn_debughap_0900.json | 14 --- .../sub_startup_appspawn_debughap_0900.py | 64 ----------- .../sub_startup_appspawn_fd_0100.json | 14 --- .../sub_startup_appspawn_fd_0100.py | 83 -------------- ...startup_appspawn_filemgr_sandbox_0100.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0100.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_0200.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0200.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_0300.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0300.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_0400.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0400.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_0500.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0500.py | 64 ----------- ...startup_appspawn_filemgr_sandbox_0600.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0600.py | 59 ---------- ...startup_appspawn_filemgr_sandbox_0700.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0700.py | 63 ----------- ...startup_appspawn_filemgr_sandbox_0800.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0800.py | 63 ----------- ...startup_appspawn_filemgr_sandbox_0900.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_0900.py | 63 ----------- ...startup_appspawn_filemgr_sandbox_1000.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1000.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_1100.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1100.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_1200.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1200.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_1300.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1300.py | 59 ---------- ...startup_appspawn_filemgr_sandbox_1400.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1400.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_1500.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1500.py | 61 ---------- ...startup_appspawn_filemgr_sandbox_1600.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1600.py | 64 ----------- ...startup_appspawn_filemgr_sandbox_1700.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1700.py | 59 ---------- ...startup_appspawn_filemgr_sandbox_1800.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1800.py | 64 ----------- ...startup_appspawn_filemgr_sandbox_1900.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_1900.py | 64 ----------- ...startup_appspawn_filemgr_sandbox_2000.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_2000.py | 57 ---------- ...startup_appspawn_filemgr_sandbox_2100.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_2100.py | 57 ---------- ...startup_appspawn_filemgr_sandbox_2200.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_2200.py | 58 ---------- ...startup_appspawn_filemgr_sandbox_2300.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_2300.py | 57 ---------- ...startup_appspawn_filemgr_sandbox_2500.json | 14 --- ...b_startup_appspawn_filemgr_sandbox_2500.py | 57 ---------- .../sub_startup_appspawn_ftpd_0100.json | 15 --- .../sub_startup_appspawn_ftpd_0100.py | 64 ----------- ..._startup_appspawn_nativedmscheck_0100.json | 12 -- ...ub_startup_appspawn_nativedmscheck_0100.py | 62 ----------- ..._startup_appspawn_nativedmscheck_0200.json | 12 -- ...ub_startup_appspawn_nativedmscheck_0200.py | 67 ----------- ..._startup_appspawn_nativedmscheck_0300.json | 12 -- ...ub_startup_appspawn_nativedmscheck_0300.py | 80 -------------- ..._startup_appspawn_nativedmscheck_0400.json | 12 -- ...ub_startup_appspawn_nativedmscheck_0400.py | 90 --------------- .../sub_startup_appspawn_nativepack_0100.json | 12 -- .../sub_startup_appspawn_nativepack_0100.py | 78 ------------- .../sub_startup_appspawn_nativepack_0200.json | 12 -- .../sub_startup_appspawn_nativepack_0200.py | 68 ------------ .../sub_startup_appspawn_nativepack_0300.json | 12 -- .../sub_startup_appspawn_nativepack_0300.py | 77 ------------- .../sub_startup_appspawn_nativepack_0400.json | 12 -- .../sub_startup_appspawn_nativepack_0400.py | 77 ------------- .../sub_startup_appspawn_nativepack_0500.json | 12 -- .../sub_startup_appspawn_nativepack_0500.py | 88 --------------- .../sub_startup_appspawn_nativepack_0600.json | 12 -- .../sub_startup_appspawn_nativepack_0600.py | 86 --------------- .../sub_startup_appspawn_nativeprocess.json | 20 ---- .../sub_startup_appspawn_nativeprocess.py | 41 ------- ...sub_startup_appspawn_nativeprocess_0100.py | 39 ------- ...sub_startup_appspawn_nativeprocess_0200.py | 42 ------- ...sub_startup_appspawn_nativeprocess_0400.py | 39 ------- ...sub_startup_appspawn_nativeprocess_0500.py | 39 ------- ...sub_startup_appspawn_nativeprocess_0600.py | 42 ------- ...b_startup_appspawn_nativesandbox_0100.json | 12 -- ...sub_startup_appspawn_nativesandbox_0100.py | 84 -------------- ...b_startup_appspawn_nativesandbox_0200.json | 13 --- ...sub_startup_appspawn_nativesandbox_0200.py | 84 -------------- ...b_startup_appspawn_supplementary_0100.json | 14 --- ...sub_startup_appspawn_supplementary_0100.py | 59 ---------- ...b_startup_appspawn_supplementary_0200.json | 14 --- ...sub_startup_appspawn_supplementary_0200.py | 62 ----------- ...b_startup_appspawn_ubsanvariable_0100.json | 13 --- ...sub_startup_appspawn_ubsanvariable_0100.py | 77 ------------- ...b_startup_appspawn_ubsanvariable_0200.json | 13 --- ...sub_startup_appspawn_ubsanvariable_0200.py | 75 ------------- ...b_startup_appspawn_ubsanvariable_0300.json | 13 --- ...sub_startup_appspawn_ubsanvariable_0300.py | 75 ------------- 121 files changed, 4915 deletions(-) delete mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json delete mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py delete mode 100644 test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json delete mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py delete mode 100644 test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.py delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.json delete mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.py delete mode 100644 test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_ftpd/sub_startup_appspawn_ftpd_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json delete mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py delete mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json delete mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json delete mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py delete mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json delete mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py delete mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py delete mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py delete mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py delete mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json delete mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json delete mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json deleted file mode 100644 index 2e315add..00000000 --- a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_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_cgroups/Substartupappspawncgroups0100.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py deleted file mode 100644 index 0e24a7f9..00000000 --- a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py +++ /dev/null @@ -1,75 +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 importFunction1, SpecificFunction2 - -from aw import Common - -class Substartupappspawncgroups0100(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 - 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.shell("power-shell setmode 602") - - def process(self): - hap_path = Common.sourcepath('ForkTest1.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") - bundle_name - bundle_name = "com.example.exe_sys_cmd" - 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) - pid = self.driver.System.get_pid(bundle_name) - result1 = self.driver.shell("ps -ef | grep %s" % bundle_name) - cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" %(bundle_name, pid)).split() - count = 0 - for i in cgroup1: - self.driver.Assert.contains(result1.split(), i) - if result1.count(i) == 2: - count += 1 - self.driver.Assert.equal(count, 1) - result2 = self.driver.shell("kill -9 %d" % pid) - self.driver.Assert.equal(result2, '') - result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) - self.driver.Assert.equal(result3, '') - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json deleted file mode 100644 index 26a1000e..00000000 --- a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_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_cgroups/Substartupappspawncgroups0200.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py deleted file mode 100644 index e11d33c4..00000000 --- a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py +++ /dev/null @@ -1,73 +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 SomeClass, some_function - -from aw import Common - - -class Substartupappspawncgroups0200(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 - 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.shell("power-shell timeout -o 86400000") - - def process(self): - hap_path = Common.sourcepath('ForkTest2.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") - bundle_name = "com.example.exe_sys_cmd" - 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) - pid = self.driver.System.get_pid(bundle_name) - result1 = self.driver.shell("ps -ef | grep %s" % bundle_name) - count = 0 - for i in cgroup1: - self.driver.Assert.contains(result1.split(), i) - if result1.count(i) == 3: - count += 1 - self.driver.Assert.equal(count, 1) - result2 = self.driver.shell("kill -9 %d" % pid) - self.driver.Assert.equal(result2, '') - result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) - self.driver.Assert.equal(result3, '') - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.uninstall_app("com.example.exe_sys_cmd") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json deleted file mode 100644 index 1be0bf2f..00000000 --- a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_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_cgroups/Substartupappspawncgroups0300.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py deleted file mode 100644 index da0bcc97..00000000 --- a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py +++ /dev/null @@ -1,73 +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 HypiumClass, HypiumFunction - -from aw import Common - - -class Substartupappspawncgroups0300(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 - 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.shell("power-shell timeout -o 86400000") - - def process(self): - hap_path = Common.sourcepath('ForkTest3.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") - bundle_name = "com.example.exe_sys_cmd" - 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) - pid = self.driver.System.get_pid(bundle_name) - result1 = self.driver.shell("ps -ef |grep %s" % bundle_name) - count = 0 - for i in cgroup1: - self.driver.Assert.contains(result1.split(), i) - if result1.count(i) == 2: - count += 1 - self.driver.Assert.equal(count, 2) - result2 = self.driver.shell("kill -9 %d" % pid) - self.driver.Assert.equal(result2, '') - result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) - self.driver.Assert.equal(result3, '') - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.uninstall_app("com.example.exe_sys_cmd") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json deleted file mode 100644 index 49136690..00000000 --- a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_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_coldstart/Substartupappspawncoldstart0100.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 036499cc..00000000 --- a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py +++ /dev/null @@ -1,59 +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 import HypiumFunction1, HypiumFunction - - -class Substartupappspawncoldstart0100(TestCase): - - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - 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) - - def test_step1(self): - Step("设置冷启动全局参数.................") - result = self.driver.shell('param set startup.appspawn.cold.boot 1') - sleep(3) - if "Set parameter startup.appspawn.cold.boot 1 success" in result: - pass - else: - raise ValueError('设置冷启动全局参数失败!') - Step("通过命令启动日历.................") - result = self.driver.shell("aa start -C -d 123456 -a MainAbility -b com.hmos.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 = result_ps.split('\n')[0] - Step("日历进程信息如下:" + str(result_ps)) - if '"' in result_ps: - throw std::logic_error("日进程信息中包含非法字符 \"") - - def teardown(self): - Step("收尾工作.................") - pid = self.driver.System.get_pid('com.hmos.calendar') - self.driver.shell("kill -9 " + str(pid)) - diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json deleted file mode 100644 index 0a585dcc..00000000 --- a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_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_coldstartablity/Substartupappspawncoldstartablity0100.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py deleted file mode 100644 index da2d64dc..00000000 --- a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.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. - -from time import sleep -from devicetest.core.test_case import Step, TestCase -from hyp import HypiumClass1, HypiumClass2, HypiumFunction1 - -from aw import Common - - -class Substartupappspawncoldstartablity0100(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - 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("asan-enable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") - 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.example.myapplication", "EntryAbility") - sleep(3) - pid = self.driver.System.get_pid('com.example.myapplication') - Step(pid) - Step("校验hap应用的maps.................") - result = self.driver.shell('cat ' + os.path.join('/proc', str(pid), 'maps') + '|grep libclang.asan.so') - Step(result) - self.driver.Assert.contains(result, '/system/lib64/libclang_rt.asan.so') - self.driver.Assert.contains(result, 'anon:libclang_rt.asan.so.bss') - - def teardown(self): - Step("收尾工作.................") - Step("收尾工作:卸载hap......................") - self.driver.AppManager.clear_app_data('com.example.myapplication') - self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json deleted file mode 100644 index 0e9342a4..00000000 --- a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.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_coldstartablity/Substartupappspawncoldstartablity0200.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py deleted file mode 100644 index 04fc5b10..00000000 --- a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py +++ /dev/null @@ -1,60 +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 hyp import HypiumClass1, HypiumClass2, HypiumFunction1 - -from aw import Common - - -class Substartupappspawncoldstartablity0200(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - 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("asan-disable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") - 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.example.myapplication", "EntryAbility") - sleep(3) - pid = self.driver.System.get_pid('com.example.myapplication') - Step(pid) - Step("校验hap应用的maps.................") - Step(result) - self.driver.Assert.equal(result, '') - - - def teardown(self): - Step("收尾工作.................") - Step("收尾工作:卸载hap......................") - self.driver.AppManager.clear_app_data('com.example.myapplication') - self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json deleted file mode 100644 index 1fd513bc..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_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_debughap/SubStartupAppspawnDebughap0100.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py deleted file mode 100644 index a429b69f..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_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. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnDebughap0100(TestCase): - - def __init__(self, controllers): - 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): - Step("安装测试hap并打开") - bundle_name = "com.example.release" - hap_path = Common.sourcepath('release.hap', "sub_startup_appspawn_debughap") - 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) - - release_has = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s" % bundle_name) - self.driver.Assert.equal(release_has, False) - - 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_debughap/sub_startup_appspawn_debughap_0200.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json deleted file mode 100644 index 66713d04..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_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_debughap/SubStartupAppspawnDebughap0200.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py deleted file mode 100644 index dec704a0..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.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. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnDebughap0200(TestCase): - - def __init__(self, controllers): - 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): - Step("安装测试hap并打开") - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - 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("param set startup.appspawn.sandbox.debughap true") - self.driver.AppManager.start_app(bundle_name) - - result = self.driver.shell("ls /mnt/debug/100/debug_hap").split() - self.driver.Assert.contains(result, bundle_name) - - 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_debughap/sub_startup_appspawn_debughap_0300.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json deleted file mode 100644 index 4918b0b9..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_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_debughap/SubStartupAppspawnDebughap0300.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py deleted file mode 100644 index fb7609b2..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py +++ /dev/null @@ -1,79 +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.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnDebughap0300(TestCase): - - def __init__(self, controllers): - 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): - Step("安装测试hap并打开") - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - 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("param set startup.appspawn.sandbox.debughap true") - self.driver.AppManager.start_app(bundle_name) - - sandbox_list = [] - mount_dict = list(filter(None, self.driver.shell("mount|grep %s" % bundle_name).split("\n"))) - for mount in mount_dict: - if mount.split()[2].startswith("/mnt/debug"): - sandbox_list.append(mount.split()[2]) - else: - pass - - for i in range(1, 5): - for path in ["base", "database"]: - self.driver.Assert.contains(sandbox_list, "/mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" - % (bundle_name, i, path)) - - list01 = ["el2/share", "el2/log", "el1/bundle", "el2/auth_groups", "el2/distributedfiles"] - for path in list01: - self.driver.Assert.contains(sandbox_list, "/mnt/debug/100/debug_hap/%s/data/storage/%s" - % (bundle_name, path)) - - 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_debughap/sub_startup_appspawn_debughap_0500.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json deleted file mode 100644 index a8e1e788..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_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_debughap/SubStartupAppspawnDebughap0500.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py deleted file mode 100644 index e410e953..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.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. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnDebughap0500(TestCase): - - def __init__(self, controllers): - 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): - Step("安装测试hap并打开") - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") - 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) - - result = self.driver.shell("ls -Z /mnt/debug/100/debug_hap").split("\n") - self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % bundle_name) - - 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_debughap/sub_startup_appspawn_debughap_0600.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json deleted file mode 100644 index 7a19d9b4..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device", - "label": "" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0600.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py deleted file mode 100644 index 446185f8..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.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. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnDebughap0600(TestCase): - - def __init__(self, controllers): - 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): - Step("安装测试hap并打开") - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") - 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) - - result = self.driver.shell("ls /mnt/debug/100/debug_hap").split() - self.driver.Assert.contains(result, bundle_name) - - 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_debughap/sub_startup_appspawn_debughap_0700.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json deleted file mode 100644 index 5538e209..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.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_debughap/SubStartupAppspawnDebughap0700.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py deleted file mode 100644 index e19ac7fd..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py +++ /dev/null @@ -1,78 +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.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnDebughap0700(TestCase): - - def __init__(self, controllers): - 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) - - self.driver.hdc("target mount") - self.driver.shell("mv /system/etc/init/init_dec.cfg /system/etc/init/init_dec.cfg_bak") - cfg_path = Common.sourcepath('init_dec.cfg', "sub_startup_appspawn_debughap") - self.driver.push_file(cfg_path, "/system/etc/init") - self.driver.System.reboot() - # 解锁屏幕 - 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并打开") - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") - 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("param set startup.appspawn.sandbox.debughap true") - self.driver.AppManager.start_app(bundle_name) - - has_dir = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s" % bundle_name) - self.driver.Assert.equal(has_dir, True) - result = self.driver.shell("ls /mnt/debug/100/debug_hap/%s" % bundle_name) - self.driver.Assert.contains(result, "Operation not permitted") - - def teardown(self): - Step("收尾工作.................") - self.driver.hdc("target mount") - self.driver.shell("mv /system/etc/init/init_dec.cfg_bak /system/etc/init/init_dec.cfg") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.System.reboot() - self.driver.System.wait_for_boot_complete() - self.driver.shell("param set startup.appspawn.sandbox.debughap true") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json deleted file mode 100644 index d17ff07f..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_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_debughap/SubStartupAppspawnDebughap0800.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py deleted file mode 100644 index 7974ad11..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.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 os -import time -from devicetest.core.test_case import TestCase, Step -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnDebughap0800(TestCase): - - def __init__(self, controllers): - 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): - Step("安装测试hap并打开") - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") - 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) - - for i in range(1, 5): - for path in {"database", "base"}: - mac_path = self.driver.Storage.has_dir("/data/app/el%d/100/%s/%s" % (i, path, bundle_name)) - sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" - % (bundle_name, i, path)) - self.driver.Assert.equal(mac_path, sandbox_path) - - if mac_path is True: - mac_path_content = self.driver.shell("ls /data/app/el%d/100/%s/%s" % (i, path, bundle_name)) - sandbox_path_content = self.driver.shell("ls /mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" - % (bundle_name, i, path)) - self.driver.Assert.equal(mac_path_content, sandbox_path_content) - - path_dict = { - "/mnt/hmdfs/100/non_account/merge_view/data": "el2/auth_groups", - "/mnt/hmdfs/100/account/merge_view/data": "el2/distributedfiles", - "/data/app/el2/100/log": "el2/log", - "/data/app/el1/bundle/public": "el1/bundle", - "/mnt/share/100": "el2/share" - } - - for mac, sandbox in path_dict.items(): - if mac != "/mnt/hmdfs/100/non_account/merge_view/data": - mac_path = self.driver.Storage.has_dir("%s/%s" % (mac, bundle_name)) - sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/%s" - % (bundle_name, sandbox)) - self.driver.Assert.equal(mac_path, sandbox_path) - if mac_path is True: - mac_path_content = self.driver.shell("ls %s/%s" % (mac, bundle_name)) - sandbox_path_content = self.driver.shell( - "ls /mnt/debug/100/debug_hap/%s/data/storage/%s" % (bundle_name, sandbox)) - self.driver.Assert.equal(mac_path_content, sandbox_path_content) - else: - mac_path = self.driver.Storage.has_dir("%s" % mac) - sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/%s" - % (bundle_name, sandbox)) - self.driver.Assert.equal(mac_path, sandbox_path) - if mac_path is True: - mac_path_content = self.driver.shell("ls %s" % mac) - sandbox_path_content = self.driver.shell("ls /mnt/debug/100/debug_hap/%s/data/storage/%s" - % (bundle_name, sandbox)) - self.driver.Assert.equal(mac_path_content, sandbox_path_content) - - 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_debughap/sub_startup_appspawn_debughap_0900.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json deleted file mode 100644 index ab601307..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_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_debughap/SubStartupAppspawnDebughap0900.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py deleted file mode 100644 index 67a388ef..00000000 --- a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.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. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -class SubStartupAppspawnDebughap0900(TestCase): - - def __init__(self, controllers): - 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): - Step("安装测试hap并打开") - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") - 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) - - result = self.driver.shell("ls -Z /mnt/debug/100") - self.driver.Assert.contains(result, "u:object_r:sharefs:s0 debug_hap") - - 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_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 d2ef15d1..00000000 --- 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 d65e7ce4..00000000 --- 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.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.json deleted file mode 100644 index 2b59544a..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0100.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index da38e96a..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0100(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 - 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): - file_mgr - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - result = self.driver.shell("ls /proc/%d/root/storage" % pid).split() - content = ["External", "Users", "hmdfs"] - for i in content: - self.driver.Assert.contains(result, i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.json deleted file mode 100644 index 494b8688..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0200.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index a34f716f..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0200(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 - 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): - file_mgr - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser" % pid).split() - content = ["Desktop", "Documents", "Download", "appdata"] - for i in content: - self.driver.Assert.contains(result, i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.json deleted file mode 100644 index d3d2775c..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0300.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 5202c61e..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0300(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 - 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): - file_mgr - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata" % pid) - content = ["el1", "el2"] - for i in content: - self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.json deleted file mode 100644 index 39d21ea1..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0400.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index ee46c858..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0400(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 - 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): - file_mgr - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata/el2" % pid) - content = ["base", "distributedfiles", "cloud"] - for i in content: - self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.json deleted file mode 100644 index 603a7825..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0500.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 1d1439bd..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.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. - -import time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0500(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 - 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): - file_mgr - count = 0 - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - for i in range(1, 3): - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el%d/base" % (pid, i)).split() - for bundle_name in result: - if "com." in bundle_name or "com.ohos" in bundle_name: - count += 1 - self.driver.Assert.greater(count, 0) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.json deleted file mode 100644 index 4e801c20..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0600.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 31f09ea3..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.py +++ /dev/null @@ -1,59 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0600(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 - 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): - file_mgr - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata/el1" % pid) - self.driver.Assert.contains(result, "u:object_r:sharefs:s0 base") - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.json deleted file mode 100644 index 8f16be1a..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0700.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 89c32be6..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.py +++ /dev/null @@ -1,63 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0700(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 - 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): - file_mgr - count = 0 - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el2/distributedfiles" % pid,).split() - for bundle_name in result: - if "com." in bundle_name or "com.ohos" in bundle_name: - count += 1 - self.driver.Assert.greater(count, 0) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.json deleted file mode 100644 index 80bd2cf2..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0800.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index aa7f8abe..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.py +++ /dev/null @@ -1,63 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0800(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 - 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): - file_mgr - count = 0 - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el2/cloud" % pid,).split() - for bundle_name in result: - if "com." in bundle_name or "com.ohos" in bundle_name: - count += 1 - self.driver.Assert.greater(count, 0) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.json deleted file mode 100644 index 0c444897..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0900.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index f3bb2136..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.py +++ /dev/null @@ -1,63 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox0900(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 - 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): - file_mgr - count = 0 - file_mgr = "com.hmos.filemanager" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(file_mgr) - time.sleep(3) - pid = self.driver.System.get_pid(file_mgr) - result = self.driver.shell("ls -Z /proc/%d/root/storage" % pid,).split() - for i in result: - if "sharefs" in i: - count += 1 - self.driver.Assert.equal(count, 0) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(file_mgr) - self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.json deleted file mode 100644 index 56838555..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1000.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index e07743c3..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1000(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage" % pid) - content = ["External", "Users", "hmdfs"] - for i in content: - self.driver.Assert.contains(result, i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.json deleted file mode 100644 index 071a6565..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1100.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index f93a6d2d..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1100(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser" % pid) - content = ["Desktop", "Documents", "Download", "appdata"] - for i in content: - self.driver.Assert.contains(result, i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.json deleted file mode 100644 index 1cdcdb7d..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1200.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index f4066486..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1200(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls -Z /proc/%d/root/storage" % pid) - content = ["External", "hmdfs", "Users"] - for i in content: - self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.json deleted file mode 100644 index 6a974dd2..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1300.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 215475b1..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.py +++ /dev/null @@ -1,59 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1300(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls -Z /proc/%d/root/storage/Users" % pid).rsplit("\n") - self.driver.Assert.equal(result[0], "u:object_r:sharefs:s0 currentUser") - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.json deleted file mode 100644 index 6be9d12e..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1400.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 5902c943..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1400(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata" % pid).split() - content = ["el1", "el2"] - for i in content: - self.driver.Assert.contains(result, i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.json deleted file mode 100644 index 3b303104..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1500.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 2fb69ff0..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.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 time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1500(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata/el2" % pid) - content = ["base", "distributedfiles", "cloud"] - for i in content: - self.driver.Assert.contains(result, "sharefs_appdata_file:s0 %s" % i) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.json deleted file mode 100644 index cc7e90ae..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1600.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 9e5905b8..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.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. - -import time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1600(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 - 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): - notepad - count = 0 - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - for i in range(1, 3): - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el%d/base" % (pid, i)).split() - for bundle_name in result: - if "com." in bundle_name or "com.ohos" in bundle_name: - count += 1 - self.driver.Assert.greater(count, 0) - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.json deleted file mode 100644 index 987cdcae..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1700.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 05b9ad55..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.py +++ /dev/null @@ -1,59 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1700(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata/el1" % pid).split("\n") - self.driver.Assert.equal(result[0], "u:object_r:sharefs_appdata_file:s0 base") - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.json deleted file mode 100644 index 93278ccf..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1800.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 5c663660..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.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. - -import time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1800(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 - 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): - notepad - count = 0 - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el2/distributedfiles" % pid).split() - for bundle_name in result: - if "com." in bundle_name or "com.ohos" in bundle_name: - count += 1 - self.driver.Assert.greater(count, 0) - - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.json deleted file mode 100644 index c6034bb5..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1900.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 640d9c26..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.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. - -import time -from devicetest.core.test_case import TestCase, Step -from hypium import FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox1900(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 - 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): - notepad - count = 0 - notepad = "com.hmos.notepad" - self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el2/cloud" % pid).split() - for bundle_name in result: - if "com." in bundle_name or "com.ohos" in bundle_name: - count += 1 - self.driver.Assert.greater(count, 0) - - - def teardown(self): - Step("收尾工作.................") - self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.json deleted file mode 100644 index b2533830..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2000.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index d68060d1..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.py +++ /dev/null @@ -1,57 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox2000(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser" % pid) - self.driver.Assert.contains(result, "Operation not permitted") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.json deleted file mode 100644 index d4d8580c..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2100.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 990742ff..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.py +++ /dev/null @@ -1,57 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox2100(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata" % pid) - self.driver.Assert.contains(result, "Operation not permitted") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.json deleted file mode 100644 index d204b6d2..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2200.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index e797ef7e..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.py +++ /dev/null @@ -1,58 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox2200(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - for i in range(1, 3): - result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el%d" % (pid, i)) - self.driver.Assert.contains(result, "Operation not permitted") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.json deleted file mode 100644 index c1f9ef72..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2300.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 28db72b7..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.py +++ /dev/null @@ -1,57 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox2300(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage/External" % pid) - self.driver.Assert.contains(result, "Operation not permitted") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.json deleted file mode 100644 index b89444cb..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.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_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2500.py" - ] - } -} \ No newline at end of file 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 deleted file mode 100644 index 1c5f8677..00000000 --- a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.py +++ /dev/null @@ -1,57 +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 FilemgrSandbox, Appspawn, SubStartup - - -class SubStartupAppspawnFilemgrSandbox2500(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 - 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): - notepad - notepad = "com.hmos.notepad" - self.driver.AppManager.start_app(notepad) - time.sleep(3) - pid = self.driver.System.get_pid(notepad) - result = self.driver.shell("ls /proc/%d/root/storage/hmdfs" % pid) - self.driver.Assert.contains(result, "Operation not permitted") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.clear_app_data(notepad) - self.driver.AppManager.stop_app(notepad) \ No newline at end of file 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 850e6d6a..00000000 --- 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 a2385b2d..00000000 --- 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_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json deleted file mode 100644 index c467494b..00000000 --- a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0100.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py deleted file mode 100644 index a3f4c191..00000000 --- a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.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 time -from devicetest.core.test_case import TestCase, Step, CheckPoint -from devicetest.core.test_case import Step, TestCase -from hypium.model import UiParam, WindowFilter -import os - - -class SubStartupAppspawnNativedmscheck0100(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:唤醒屏幕.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - - def test_step1(self): - Step("步骤1:创建公有hnp存放目录") - self.driver.shell("mkdir -p data/no_sign/public") - Step("步骤2:导入安装包文件hnp") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - hnp = os.path.abspath(os.path.join( - os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/no_sign/hnpsample.hnp')) - hap = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), - 'SUB_STARTUP_APPSPAWN_NATIVE/no_sign/entry-default-signedArm64.hap')) - self.driver.push_file(hnp, "data/no_sign/public/") - self.driver.push_file(hap, "data/no_sign") - Step("步骤3:执行安装命令") - result = self.driver.shell( - "hnp install -u 100 -p wechat_sign -i /data/no_sign -s /data/no_sign/entry-default-signedArm64-test11.hap -a arm64 -f") - Step("步骤4:预期结果校验") - self.driver.Assert.contains(result, "hnp uninstall start now! name=hnpsample") - self.driver.Assert.contains(result, "native manager process exit. ret=8393475") - - def teardown(self): - self.driver.shell("rm -rf data/no_sign") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json deleted file mode 100644 index 676d65fa..00000000 --- a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0200.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py deleted file mode 100644 index 6e495429..00000000 --- a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py +++ /dev/null @@ -1,67 +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, CheckPoint -from devicetest.core.test_case import Step, TestCase -from hypium.model import UiParam, WindowFilter -import os - - -class SubStartupAppspawnNativedmscheck0200(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:唤醒屏幕.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - - def test_step1(self): - Step("步骤1:创建公有hnp存放目录") - self.driver.shell("mkdir -p data/wechat_sign/public") - Step("步骤2:导入安装包文件hnp") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - hnp = os.path.abspath(os.path.join( - os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/hnpsample.hnp')) - hap = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), - 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) - self.driver.push_file(hnp, "data/wechat_sign/public/") - self.driver.push_file(hap, "data/wechat_sign") - Step("步骤3:执行安装命令") - result1 = self.driver.shell( - "hnp install -u 100 -p wechat_sign -i /data/wechat_sign -s /data/wechat_sign/entry-default-signedArm64-test11.hap -a arm64 -f") - Step("步骤4:预期结果校验") - public = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/") - self.driver.Assert.contains(public, "hnpsample.org") - result = self.driver.shell("cat /data/service/el1/startup/hnp_info.json") - self.driver.Assert.contains(result, "wechat_sign") - self.driver.Assert.contains(result1, "native manager process exit. ret=0") - self.driver.Assert.contains(result1, "hnp install start now! src file=/data/wechat_sign/public/hnpsample.hnp, dst path=/data/app/el1/bundle/100/hnppublic") - - def teardown(self): - self.driver.shell("rm -rf data/sign") - self.driver.shell("hnp uninstall -u 100 -p wechat_sign") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json deleted file mode 100644 index 7edfe4b8..00000000 --- a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0300.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py deleted file mode 100644 index 54d9d5e7..00000000 --- a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py +++ /dev/null @@ -1,80 +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, CheckPoint -from devicetest.core.test_case import Step, TestCase -from hypium.action.os_hypium.device_logger import DeviceLogger -from hypium.model import UiParam, WindowFilter -import os - - -class SubStartupAppspawnNativedmscheck0300(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:唤醒屏幕.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('开启DEBUG日志') - self.driver.shell("hilog -b I -D 0xC02C11") - self.driver.shell("hilog -b DEBUG -T APPSPAWN") - self.driver.shell("hilog -b D -D 0xDC02C11") - self.driver.shell("hilog -G 16M") - host.shell('hdc shell "hilog -r"') - - def test_step1(self): - Step("步骤1:安装私有路径hap包") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - hap1 = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), - 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signedArm64Pri-test.hap')) - hap2 = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), - 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signed-hnpselinux.hap')) - self.driver.install_app(hap1) - self.driver.install_app(hap2) - Step("步骤2:过滤日志") - device_logger = DeviceLogger(self.driver) - device_logger.set_filter_string("MY_TAG") - Step("步骤3:开始抓取日志") - device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) - Step("步骤4:打开测试应用") - self.driver.start_app("com.example.hnpselinuxtestapplication", "EntryAbility") - time.sleep(60) - Step("步骤4:关闭日志") - device_logger.stop_log() - time.sleep(4) - device_logger.check_log('Open public cfg file to read failed, errno=[2]') - device_logger.check_log('Open public cfg file to write failed, errno=[2]') - device_logger.check_log('Open private cfg file to read failed, errno=[2]') - device_logger.check_log('Open private cfg file to write failed, errno=[2]') - - def teardown(self): - Step("收尾工作:删除hap") - self.driver.uninstall_app("com.example.hnp_test") - self.driver.uninstall_app("com.example.hnpselinuxtestapplication") - self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json deleted file mode 100644 index 1aafb7c2..00000000 --- a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0400.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py deleted file mode 100644 index 2cdbd51e..00000000 --- a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py +++ /dev/null @@ -1,90 +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, CheckPoint -from devicetest.core.test_case import Step, TestCase -from hypium.action.os_hypium.device_logger import DeviceLogger -from hypium.model import UiParam, WindowFilter -import os - - -class SubStartupAppspawnNativedmscheck0400(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:唤醒屏幕.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('开启DEBUG日志') - self.driver.shell("hilog -b I -D 0xC02C11") - self.driver.shell("hilog -b DEBUG -T APPSPAWN") - self.driver.shell("hilog -b D -D 0xDC02C11") - self.driver.shell("hilog -G 16M") - host.shell('hdc shell "hilog -r"') - - def test_step1(self): - Step("步骤1:安装私有路径hap包") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - hap1 = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), - 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signedArm64-test.hap')) - hap2 = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), - 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signed-hnpselinux.hap')) - self.driver.install_app(hap1) - self.driver.install_app(hap2) - Step("步骤2:过滤日志") - device_logger = DeviceLogger(self.driver) - device_logger.set_filter_string("MY_TAG") - Step("步骤3:开始抓取日志") - device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) - Step("步骤4:打开测试应用") - self.driver.start_app("com.example.hnpselinuxtestapplication", "EntryAbility") - time.sleep(60) - Step("步骤4:关闭日志") - device_logger.stop_log() - time.sleep(4) - Step("识别设备型号...............................") - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - if ("HYM" in device or "HAD" in device): - device_logger.check_log("cfg file content:") - device_logger.check_log("[This is hnp sample config file.].") - device_logger.check_log("cfg file end") - device_logger.check_log('Open public cfg file to write failed, errno=[13]') - else: - device_logger.check_log('Open public cfg file to read failed, errno=[2]') - device_logger.check_log('Open public cfg file to write failed, errno=[2]') - device_logger.check_log('Open private cfg file to read failed, errno=[2]') - device_logger.check_log('Open private cfg file to write failed, errno=[2]') - - def teardown(self): - Step("收尾工作:删除hap") - self.driver.uninstall_app("com.example.hnp_test") - self.driver.uninstall_app("com.example.hnpselinuxtestapplication") - self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json deleted file mode 100644 index a8e61cc2..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0100.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py deleted file mode 100644 index 60b3688b..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py +++ /dev/null @@ -1,78 +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 hypium.model import UiParam, WindowFilter -import os -import time - - -class SubStartupAppspawnNativepack0100(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('预置工作:新增一个123.txt文件') - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample')) - with open(file + "\\lib\\123.txt", "a+") as f1: - f1.write("12345678hdaskheiwoi4eliqwkldsajoejqooiudsisa") - - def test_step1(self): - Step("获取bat文件路径") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) - Step("执行bat文件") - host.shell(bat) - Step("复制压缩文件") - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) - sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) - file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) - file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) - host.shell("copy "+file1 + " " + file2) - Step("步骤7:解压hnpsample.zip文件") - host.unzip_file(file2, out) - Step("步骤8:比较2个文件内容是否一致") - time.sleep(1) - dif1 = f.read() - with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - dif1 = f.read() - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - with open(sample + "\\lib\\123.txt") as f: - dif1 = f.read() - with open(out + "\\sample\\lib\\123.txt") as f: - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - - def teardown(self): - Step("收尾工作:删除out目录文件") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json deleted file mode 100644 index f42ce0d5..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0200.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py deleted file mode 100644 index 1a38d824..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py +++ /dev/null @@ -1,68 +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 hypium.model import UiParam, WindowFilter -import os -import time - - -class SubStartupAppspawnNativepack0200(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - - def test_step1(self): - Step("获取bat文件路径") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) - Step("执行bat文件") - host.shell(bat) - Step("复制压缩文件") - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) - sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) - file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) - file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) - host.shell("copy "+file1 + " " + file2) - Step("步骤7:解压hnpsample.zip文件") - host.unzip_file(file2, out) - Step("步骤8:比较2个文件内容是否一致") - time.sleep(1) - dif1 = f.read() - with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - dif1 = f.read() - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - - def teardown(self): - Step("收尾工作:删除out目录文件") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json deleted file mode 100644 index 376a9a5f..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0300.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py deleted file mode 100644 index 9a1631cc..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py +++ /dev/null @@ -1,77 +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 hypium.model import UiParam, WindowFilter -import os -import time - - -class SubStartupAppspawnNativepack0300(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('预置工作:修改打包的文件') - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample')) - with open(file+"\\cfg\\hnpsample.cfg", "a") as f1: - f1.write("weuhriqj82hs9九jisapojhwkeioqw8321093nskjdlajejnphoneklv") - time.sleep(2) - - def test_step1(self): - Step("获取bat文件路径") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) - Step("执行bat文件") - host.shell(bat) - Step("复制压缩文件") - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) - sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) - file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) - file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) - host.shell("copy "+file1 + " " + file2) - Step("步骤7:解压hnpsample.zip文件") - host.unzip_file(file2, out) - Step("步骤8:比较2个文件内容是否一致") - time.sleep(1) - dif1 = f.read() - with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - dif1 = f.read() - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - - def teardown(self): - Step("收尾工作:删除out目录文件") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) - file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) - with open(file + "\\cfg\\hnpsample.cfg", "w") as f1: - f1.write("This is hnp sample config file.") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json deleted file mode 100644 index b615cf06..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0400.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py deleted file mode 100644 index ed43fa77..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py +++ /dev/null @@ -1,77 +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 hypium.model import UiParam, WindowFilter -import os -import time - - -class SubStartupAppspawnNativepack0400(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - - def test_step1(self): - Step("步骤1:添加读写权限") - self.driver.hdc("target mount") - Step("步骤2:导入打包所需的文件到设备data/usr目录") - self.driver.shell("mkdir data/usr") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) - file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) - self.driver.hdc("hdc file send " + file1 + " /data") - self.driver.hdc("hdc file send " + file2 + " /data/usr") - Step("步骤3:添加权限") - self.driver.shell("chmod +x /data/hnpcli") - Step("步骤4:执行打包命令") - self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") - Step("步骤5:复制hnp文件为zip文件") - self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") - Step("步骤6:导出生成的zip包到本地") - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) - self.driver.hdc("hdc file recv /data/hnpsample.zip "+out) - Step("步骤7:解压hnpsample.zip文件") - Step("步骤8:比较2个文件内容是否一致") - time.sleep(1) - with open(file2+"\\cfg\\hnpsample.cfg") as f: - dif1 = f.read() - with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - dif1 = f.read() - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - - def teardown(self): - Step("收尾工作:删除out目录文件") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) - self.driver.shell("rm -rf /data/hnpsample.zip") - self.driver.shell("rm -rf /data/hnpsample.hnp") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json deleted file mode 100644 index ecdac029..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0500.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py deleted file mode 100644 index a50cf5e1..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.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 time - -from devicetest.core.test_case import Step, TestCase -from hypium.model import UiParam, WindowFilter -import os - - -class SubStartupAppspawnNativepack0500(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('预置工作:设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('预置工作:修改打包的文件') - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) - with open(file+"\\cfg\\hnpsample.cfg", "a") as f1: - f1.write("weuhriqj82hs9九jisapojhwkeioqw8321093nskjdlajejnphoneklv") - time.sleep(2) - - def test_step1(self): - Step("步骤1:添加读写权限") - self.driver.hdc("target mount") - Step("步骤2:导入打包所需的文件到设备data/usr目录") - self.driver.shell("mkdir data/usr") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) - file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) - self.driver.hdc("hdc file send " + file1 + " /data") - self.driver.hdc("hdc file send " + file2 + " /data/usr") - Step("步骤3:添加权限") - self.driver.shell("chmod +x /data/hnpcli") - Step("步骤4:执行打包命令") - self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") - Step("步骤5:复制hnp文件为zip文件") - self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") - Step("步骤6:导出生成的zip包到本地") - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) - self.driver.hdc("hdc file recv /data/hnpsample.zip " + out) - Step("步骤7:解压hnpsample.zip文件") - host.unzip_file(out + "\\hnpsample.zip", out) - Step("步骤8:比较2个文件内容是否一致") - time.sleep(1) - dif1 = f.read() - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - dif1 = f.read() - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - - def teardown(self): - Step("收尾工作:删除&修改相关文件") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) - self.driver.shell("rm -rf /data/hnpsample.zip") - self.driver.shell("rm -rf /data/hnpsample.hnp") - file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) - with open(file + "\\cfg\\hnpsample.cfg", "w") as f1: - f1.write("This is hnp sample config file.") - - diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json deleted file mode 100644 index 434e339a..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0600.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py deleted file mode 100644 index 49a7f75c..00000000 --- a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.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 time - -from devicetest.core.test_case import Step, TestCase -from hypium.model import UiParam, WindowFilter -import os - - -class SubStartupAppspawnNativepack0600(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('预置工作:设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('预置工作:新增一个123.txt文件') - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) - f1.write("12345678hdaskheiwoi4eliqwkldsajoejqooiudsisa") - - def test_step1(self): - Step("步骤1:添加读写权限") - self.driver.hdc("target mount") - Step("步骤2:导入打包所需的文件到设备data/usr目录") - self.driver.shell("mkdir data/usr") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) - file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) - self.driver.hdc("hdc file send " + file1 + " /data") - self.driver.hdc("hdc file send " + file2 + " /data/usr") - Step("步骤3:添加权限") - self.driver.shell("chmod +x /data/hnpcli") - Step("步骤4:执行打包命令") - self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") - Step("步骤5:复制hnp文件为zip文件") - self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") - Step("步骤6:导出生成的zip包到本地") - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) - self.driver.hdc("hdc file recv /data/hnpsample.zip " + out) - Step("步骤7:解压hnpsample.zip文件") - host.unzip_file(out + "\\hnpsample.zip", out) - Step("步骤8:比较2个文件内容是否一致") - time.sleep(1) - dif1 = f.read() - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - dif1 = f.read() - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - dif1 = f.read() - with open(out + "\\sample\\lib\\123.txt") as f: - dif2 = f.read() - self.driver.Assert.equal(dif1, dif2) - - def teardown(self): - Step("收尾工作:删除相关文件") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) - file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) - self.driver.shell("rm -rf /data/hnpsample.zip") - self.driver.shell("rm -rf /data/hnpsample.hnp") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json deleted file mode 100644 index 8c1a9c37..00000000 --- a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "description": "Config for OpenHarmony app test suites", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTestSuite", - "testsuite": "sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py", - "suitecases": [ - "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0100.py", - "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0200.py", - "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0300.py", - "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0400.py", - "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0500.py", - "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0600.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py deleted file mode 100644 index 3ef49829..00000000 --- a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py +++ /dev/null @@ -1,41 +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 -from devicetest.core.suite.test_suite import TestSuite -from aw import Common - - -class SubStartupAppspawnNativeprocess(TestSuite): - - def setup(self): - Step("TestCase: setup") - self.driver = UiDriver(self.device1) - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - Step("导入配置文件.................") - self.driver.hdc("target mount") - sourpath = Common.sourcepath("AppSpawnTest", "sub_startup_appspawn_nativeprocess") - destpath = "/data/AppSpawnTest" - self.driver.push_file(sourpath, destpath) - sleep(3) - Step("给测试文件AppSpawnTest可执行权限.................") - self.driver.shell('chmod +x /data/AppSpawnTest') - self.driver.shell('./data/AppSpawnTest') - - def teardown(self): - Step("收尾工作,删除文件.................") - self.driver.shell("rm /data/AppSpawnTest") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py deleted file mode 100644 index 26b96df1..00000000 --- a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py +++ /dev/null @@ -1,39 +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 - - -class SubStartupAppspawnNativeprocess0100(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("TestCase: setup") - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - - def test_step1(self): - Step("执行AppSpawnTest'.................") - result = self.driver.shell('./data/AppSpawnTest') - self.driver.Assert.contains(result, "Failed spawn new app result", "默认启动孵化APPSPAWN失败") - - def teardown(self): - Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py deleted file mode 100644 index 27866f8d..00000000 --- a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py +++ /dev/null @@ -1,42 +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 - - -class SubStartupAppspawnNativeprocess0200(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("TestCase: setup") - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - - def test_step1(self): - Step("执行AppSpawnTest'.................") - result = self.driver.shell('./data/AppSpawnTest -s -b moduleTestProcessName') - self.driver.Assert.contains(result, "Failed spawn new app result", "带沙盒启动孵化APPSPAWN失败") - Step("执行AppSpawnTest'.................") - failresult = self.driver.shell('./data/AppSpawnTest -s') - self.driver.Assert.contains(failresult, "Failed spawn new app result -1", "模拟'带沙盒启动孵化APPSPAWN失败'失败") - - def teardown(self): - Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py deleted file mode 100644 index c16add36..00000000 --- a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py +++ /dev/null @@ -1,39 +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 - - -class SubStartupAppspawnNativeprocess0400(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("TestCase: setup") - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - - def test_step1(self): - Step("执行AppSpawnTest'.................") - result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx') - self.driver.Assert.contains(result, "Failed spawn new app result", "模拟新app启动孵化APPSPAWN失败") - - def teardown(self): - Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py deleted file mode 100644 index f10dd2c7..00000000 --- a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py +++ /dev/null @@ -1,39 +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 - - -class SubStartupAppspawnNativeprocess0500(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("TestCase: setup") - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - - def test_step1(self): - Step("执行AppSpawnTest'.................") - result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx -s') - self.driver.Assert.contains(result, "Failed spawn new app result -1", "指定不存在app启动孵化APPSPAWN失败") - - def teardown(self): - Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py deleted file mode 100644 index dc1c2248..00000000 --- a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py +++ /dev/null @@ -1,42 +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 - - -class SubStartupAppspawnNativeprocess0600(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("TestCase: setup") - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - - def test_step1(self): - Step("执行AppSpawnTest'.................") - result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx -s') - self.driver.Assert.contains(result, "Failed spawn new app result -1", "指定不存在app启动孵化APPSPAWN失败") - Step("执行AppSpawnTest'.................") - successresult = self.driver.shell('./data/AppSpawnTest -C') - self.driver.Assert.contains(result, "Failed spawn new app result", "模拟指定不存在的app启动孵化APPSPAWN失败后,重新启动测试失败") - - def teardown(self): - Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json deleted file mode 100644 index 9f5581fd..00000000 --- a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativesandbox/SubStartupAppspawnNativesandbox0100.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py deleted file mode 100644 index 982ae508..00000000 --- a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.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 time -from devicetest.core.test_case import Step, TestCase -from hypium.model import UiParam, WindowFilter -import os - - -class SubStartupAppspawnNativesandbox0100(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.shell("power-shell timeout -o 2147483647") - - def test_step1(self): - Step("步骤1:创建公有hnp存放目录") - self.driver.shell("mkdir -p data/UCbrowser/public") - Step("步骤2:导入安装包文件hnp") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - hnp = os.path.abspath(os.path.join( - os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/hnpsample.hnp')) - hap = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) - self.driver.push_file(hnp, "data/UCbrowser/public/") - self.driver.push_file(hap, "data/UCbrowser") - Step("步骤3:执行安装命令") - self.driver.shell( - "hnp install -u 100 -p uc_browser -i data/UCbrowser -s data/UCbrowser/entry-default-signedArm64-test11.hap -a arm64 -f") - Step("步骤4:查看是是否安装成功") - public = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/") - self.driver.Assert.contains(public, "hnpsample.org") - result = self.driver.shell("cat /data/service/el1/startup/hnp_info.json") - self.driver.Assert.contains(result, "uc_browser") - Step("步骤5:安装测试hap包") - ishap = self.driver.has_app("com.example.hnptestapplication") - if (ishap): - hap1 = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), - 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-sandbox.hap')) - self.driver.install_app(hap1) - Step("步骤6:打开测试hap包") - self.driver.shell("aa start -a EntryAbility -b com.example.hnptestapplication") - Step("步骤7:获取测试应用pid") - time.sleep(3) - pid = self.driver.System.get_pid("com.example.hnptestapplication") - Step("步骤8:查看测试应用公有沙箱路径") - result = self.driver.shell("ls /proc/%d/root/data/service/hnp" % pid) - Step("步骤9:预期结果校验") - Step("识别设备型号...............................") - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - if ("HYM" in device or "HAD" in device): - self.driver.Assert.contains(result, "bin") - self.driver.Assert.contains(result, "hnpsample.org") - else: - self.driver.Assert.contains(result, "No such file or directory") - diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json deleted file mode 100644 index 700785e5..00000000 --- a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_nativesandbox/SubStartupAppspawnNativesandbox0200.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py deleted file mode 100644 index d26ab39d..00000000 --- a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_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 time -from devicetest.core.test_case import Step, TestCase -from hypium.model import UiParam, WindowFilter -import os - - -class SubStartupAppspawnNativesandbox0200(TestCase): - - def __init__(self, controllers): - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.TAG, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.shell("power-shell timeout -o 2147483647") - - def test_step1(self): - Step("步骤1:创建公有hnp存放目录") - self.driver.shell("mkdir -p data/com.example.hnptestapplication/private") - Step("步骤2:导入安装包文件hnp") - path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) - hnp = os.path.abspath(os.path.join( - os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/hnpsample.hnp')) - hap = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) - self.driver.push_file(hnp, "data/com.example.hnptestapplication/private/") - self.driver.push_file(hap, "data/com.example.hnptestapplication") - Step("步骤3:执行安装命令") - self.driver.shell( - "hnp install -u 100 -p com.example.hnptestapplication -i data/com.example.hnptestapplication -s data/com.example.hnptestapplication/entry-default-signedArm64-test11.hap -a arm64 -f") - Step("步骤4:查看是是否安装成功") - public = self.driver.shell("ls /data/app/el1/bundle/100/hnp/com.example.hnptestapplication") - self.driver.Assert.contains(public, "hnpsample.org") - Step("步骤5:安装测试hap包") - ishap = self.driver.has_app("com.example.hnptestapplication") - if (ishap): - hap1 = os.path.abspath( - os.path.join(os.path.join(path, "testFile"), - 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-sandbox.hap')) - self.driver.install_app(hap1) - Step("步骤6:打开测试hap包") - self.driver.shell("aa start -a EntryAbility -b com.example.hnptestapplication") - Step("步骤7:获取测试应用pid") - time.sleep(1) - pid = self.driver.System.get_pid("com.example.hnptestapplication") - Step("步骤8:查看测试应用公有沙箱路径") - result = self.driver.shell("ls /proc/%d/root/data/app" % pid) - Step("步骤9:预期结果校验") - Step("识别设备型号...............................") - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - if ("HYM" in device or "HAD" in device): - self.driver.Assert.contains(result, "bin") - self.driver.Assert.contains(result, "hnpsample.org") - else: - self.driver.Assert.contains(result, "No such file or directory") - - def teardown(self): - self.driver.shell("hnp uninstall -u 100 -p com.example.hnptestapplication") diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json deleted file mode 100644 index 9a4957d4..00000000 --- a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_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_supplementary/Substartupappspawnsupplementary0100.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py deleted file mode 100644 index fc2cad96..00000000 --- a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py +++ /dev/null @@ -1,59 +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 hyp import HypiumClass1, HypiumClass2, HypiumFunction1 - -from aw import Common - - -class Substartupappspawnsupplementary0100(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("TestCase: setup") - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - Step("安装测试hap.................") - sourpath = Common.sourcepath("asan.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") - 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.example.myapplication", "EntryAbility") - sleep(3) - Step("校验hap显示Hello World.................") - if not self.driver.find_component(BY.text("Hello World")): - throw std::runtime_error("Failed to find component with text 'Hello'") - - - def teardown(self): - Step("收尾工作.................") - Step("收尾工作:卸载hap......................") - self.driver.AppManager.clear_app_data('com.example.myapplication') - self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json deleted file mode 100644 index d17ba198..00000000 --- a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_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_supplementary/Substartupappspawnsupplementary0200.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py deleted file mode 100644 index 4b5ec061..00000000 --- a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.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. - -from time import sleep -from devicetest.core.test_case import Step, TestCase -from hypium importFunction1, SpecificFunction2 - -from aw import Common - - -class Substartupappspawnsupplementary0200(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("TestCase: setup") - Step("预置工作:初始化手机开始.................") - Step(self.devices[0].device_id) - Step("安装测试hap.................") - sourpath = Common.sourcepath("sn.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") - 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.example.myapplication", "EntryAbility") - sleep(3) - Step("检查存在device info.................") - assert self.driver.find_component(BY.text("3333333", MatchPattern.CONTAINS)) - print("点击菜单device info.................") - self.driver.touch(BY.text(" device info ")) - sleep(1) - Step("校验serial为空.................") - if not self.driver.find_component(BY.text("serial: " + "\n" + " deviceType", MatchPattern.CONTAINS)) - - def teardown(self): - Step("收尾工作.................") - Step("收尾工作:卸载hap......................") - self.driver.AppManager.clear_app_data('com.example.myapplication') - self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json deleted file mode 100644 index 53f12fe9..00000000 --- a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device", - "label": "phone" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0100.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py deleted file mode 100644 index f8876929..00000000 --- a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py +++ /dev/null @@ -1,77 +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 - -from devicetest.core.test_case import TestCase, Step, CheckPoint -from devicetest.core.test_case import Step, TestCase -from hypium import HypiumClass, HypiumFunction -from hypium.action.os_hypium.device_logger import DeviceLogger -from hypium.model import UiParam, WindowFilter -import time - - -class Substartupappspawnubsanvariable0100(TestCase): - def __init__(self, controllers): - self.tag = self.__class__.__name__ - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('开启DEBUG日志') - self.driver.shell("hilog -b D -D 0xC02C11") - self.driver.shell("hilog -b DEBUG -T APPSPAWN") - self.driver.shell("hilog -b D -D 0xDC02C11") - self.driver.shell("hilog -G 16M") - - def test_step1(self): - Step("步骤1:过滤关键日志") - device_logger = DeviceLogger(self.driver) - device_logger.set_filter_string("SetAsanEnabledEnv") - Step("步骤2:安装测试hap") - path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) - hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), - "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledTrueProcessTest.hap")) - ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") - if(ishap): - self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") - else: - pass - self.driver.install_app(hap) - Step("步骤3:开始抓取日志") - device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) - Step("步骤4:启动测试应用") - self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledtrueprocesstest") - time.sleep(8) - Step("步骤4:关闭日志") - device_logger.stop_log() - device_logger.check_log('SetAsanEnabledEnv 22,(null),(null),(null)') - device_logger.check_log('print_stacktrace=1:print_module_map=2:log_exe_name=1,(null)') - - def teardown(self): - Step("收尾工作:删除测试应用") - self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") - self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json deleted file mode 100644 index 29b796cf..00000000 --- a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device", - "label": "phone" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0200.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py deleted file mode 100644 index 83070fb5..00000000 --- a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py +++ /dev/null @@ -1,75 +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 - -from devicetest.core.test_case import TestCase, Step, CheckPoint -from devicetest.core.test_case import Step, TestCase -from hyp import HypiumClass1, HypiumClass2, HypiumFunction1 -from hypium.action.os_hypium.device_logger import DeviceLogger -from hypium.model import UiParam, WindowFilter -import time - - -class Substartupappspawnubsanvariable0200(TestCase): - def __init__(self, controllers): - self.tag = self.__class__.__name__ - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('开启DEBUG日志') - self.driver.shell("hilog -b D") - self.driver.shell("hilog -G 16M") - - def test_step1(self): - Step("步骤1:过滤关键日志") - device_logger = DeviceLogger(self.driver) - device_logger.set_filter_string("SetAsanEnabledEnv") - Step("步骤2:安装测试hap") - path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) - hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), - "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledFalseProcessTest.hap")) - ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") - if (ishap): - self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") - else: - pass - self.driver.install_app(hap) - Step("步骤3:开始抓取日志") - device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) - Step("步骤4:启动测试应用") - self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledfalseprocesstest") - time.sleep(8) - Step("步骤4:关闭日志") - device_logger.stop_log() - time.sleep(2) - device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') - - def teardown(self): - Step("收尾工作:删除测试应用") - self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") - self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json deleted file mode 100644 index e72103b0..00000000 --- a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device", - "label": "phone" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0300.py"] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py deleted file mode 100644 index 591f529c..00000000 --- a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py +++ /dev/null @@ -1,75 +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 - -from devicetest.core.test_case import TestCase, Step, CheckPoint -from devicetest.core.test_case import Step, TestCase -from hypium import HypiumClass, HypiumFunction -from hypium.action.os_hypium.device_logger import DeviceLogger -from hypium.model import UiParam, WindowFilter -import time - - -class Substartupappspawnubsanvariable0300(TestCase): - def __init__(self, controllers): - self.tag = self.__class__.__name__ - self.tests = [ - "test_step1" - ] - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step("预置工作:初始化手机开始.................") - self.driver = UiDriver(self.device1) - Step("预置工作:检测屏幕是否亮.................") - self.driver.enable_auto_wakeup(self.device1) - Step("预置工作:滑动解锁.................") - self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) - Step('设置屏幕常亮') - self.driver.Screen.enable_stay_awake() - Step('开启DEBUG日志') - self.driver.shell("hilog -b D") - self.driver.shell("hilog -G 16M") - - def test_step1(self): - Step("步骤1:过滤关键日志") - device_logger = DeviceLogger(self.driver) - device_logger.set_filter_string("SetAsanEnabledEnv") - Step("步骤2:安装测试hap") - path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) - hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), - "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartNoConfigEnabledProcessTest.hap")) - ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") - if (ishap): - self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") - else: - pass - self.driver.install_app(hap) - Step("步骤3:开始抓取日志") - device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) - Step("步骤4:启动测试应用") - self.driver.shell("aa start -a EntryAbility -b com.example.actsstartnoconfigenabledprocesstest") - time.sleep(8) - Step("步骤4:关闭日志") - device_logger.stop_log() - time.sleep(2) - device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') - - def teardown(self): - Step("收尾工作:删除测试应用") - self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") - self.driver.shell("hilog -b I") -- Gitee From fe36326ff0837dcd4f332a0dc2a62ed79bb839da Mon Sep 17 00:00:00 2001 From: wangfenging Date: Wed, 20 Aug 2025 18:34:15 +0800 Subject: [PATCH 06/21] Add debug hap json config Signed-off-by: wangfenging --- appdata-sandbox.json | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) mode change 100755 => 100644 appdata-sandbox.json diff --git a/appdata-sandbox.json b/appdata-sandbox.json old mode 100755 new mode 100644 index c4a062d5..73706695 --- a/appdata-sandbox.json +++ b/appdata-sandbox.json @@ -1080,5 +1080,54 @@ "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" + } + ] + }], + "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" + }] + }] + }] }] } -- Gitee From 81d3267630dd1ed1d78e9cc635a4607556fcf0e8 Mon Sep 17 00:00:00 2001 From: tlbl Date: Thu, 21 Aug 2025 14:08:08 +0800 Subject: [PATCH 07/21] debug support cloud Signed-off-by: l30052632 --- appdata-sandbox.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/appdata-sandbox.json b/appdata-sandbox.json index 73706695..faef4e59 100644 --- a/appdata-sandbox.json +++ b/appdata-sandbox.json @@ -1108,6 +1108,12 @@ "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" } ] }], -- Gitee From c30f99793c9837c02d8e5e3df39f53b23e8ec2ce Mon Sep 17 00:00:00 2001 From: wanglei Date: Thu, 21 Aug 2025 12:19:45 +0000 Subject: [PATCH 08/21] dlclose when arkweb upgrade Signed-off-by: wanglei --- interfaces/innerkits/include/appspawn.h | 1 + standard/appspawn_service.c | 67 ++++++++++++++++++- .../app_spawn_service_test.cpp | 16 ++--- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/interfaces/innerkits/include/appspawn.h b/interfaces/innerkits/include/appspawn.h index 217363b0..e9feda93 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/standard/appspawn_service.c b/standard/appspawn_service.c index 5f9bceb9..274fe9a5 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); @@ -1751,6 +1756,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; @@ -1783,12 +1840,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(); @@ -1859,6 +1916,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/unittest/app_spawn_standard_test/app_spawn_service_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp index f0441dcd..a8f86701 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 @@ -1187,7 +1187,7 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_ConvertEnvValue_001, TestSize.Level0) } /** - * @brief 向appspawn发送MSG_LOAD_WEBLIB_IN_APPSPAWN类型的消息,传入arkweb包名 + * @brief 向appspawn发送MSG_LOAD_WEBLIB_IN_APPSPAWN类型的消息,传入任意包名 * */ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_LOAD_WEBLIB_IN_APPSPAWN_001, TestSize.Level0) @@ -1198,12 +1198,8 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_LOAD_WEBLIB_IN_APPSPAWN_001, TestSiz ret = AppSpawnClientInit(APPSPAWN_SERVER_NAME, &clientHandle); APPSPAWN_CHECK(ret == 0, break, "Failed to create client %{public}s", APPSPAWN_SERVER_NAME); - char bundleName[64] = {0}; - ret = GetParameter("persist.arkwebcore.package_name", "", bundleName, 64); - APPSPAWN_CHECK(ret == 0, break, "Failed to get arkweb bundleName"); - AppSpawnReqMsgHandle reqHandle; - ret = AppSpawnReqMsgCreate(MSG_LOAD_WEBLIB_IN_APPSPAWN, bundleName, &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); @@ -1214,10 +1210,10 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_LOAD_WEBLIB_IN_APPSPAWN_001, TestSiz } /** - * @brief 向appspawn发送MSG_LOAD_WEBLIB_IN_APPSPAWN类型的消息,传入空字符串 + * @brief 向appspawn发送MSG_UNLOAD_WEBLIB_IN_APPSPAWN类型的消息,传入任意包名 * */ -HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_LOAD_WEBLIB_IN_APPSPAWN_002, TestSize.Level0) +HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_UNLOAD_WEBLIB_IN_APPSPAWN_001, TestSize.Level0) { int ret = 0; AppSpawnClientHandle clientHandle = nullptr; @@ -1226,10 +1222,10 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_LOAD_WEBLIB_IN_APPSPAWN_002, TestSiz APPSPAWN_CHECK(ret == 0, break, "Failed to create client %{public}s", APPSPAWN_SERVER_NAME); AppSpawnReqMsgHandle reqHandle; - ret = AppSpawnReqMsgCreate(MSG_LOAD_WEBLIB_IN_APPSPAWN, "", &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_LOAD_WEBLIB_IN_APPSPAWN, ret %{public}d", ret); + APPSPAWN_CHECK(ret == 0, break, "Failed to send MSG_UNLOAD_WEBLIB_IN_APPSPAWN, ret %{public}d", ret); } while (0); AppSpawnClientDestroy(clientHandle); -- Gitee From 81acefeaf63c563c23684d56b1ce9ae318a0b038 Mon Sep 17 00:00:00 2001 From: fan-jingle Date: Thu, 21 Aug 2025 16:07:17 +0800 Subject: [PATCH 09/21] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fan-jingle --- modules/common/appspawn_silk.c | 2 +- modules/sandbox/normal/sandbox_common.cpp | 11 ++++++++--- modules/sandbox/sandbox_dec.c | 5 +++-- standard/appspawn_kickdog.c | 1 + standard/appspawn_main.c | 7 +++++-- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/common/appspawn_silk.c b/modules/common/appspawn_silk.c index 2f8d9141..c5e61d37 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/sandbox/normal/sandbox_common.cpp b/modules/sandbox/normal/sandbox_common.cpp index 9eca40fc..df0cedf3 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" 数组 diff --git a/modules/sandbox/sandbox_dec.c b/modules/sandbox/sandbox_dec.c index 8e36ea2e..72c0d4f8 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/standard/appspawn_kickdog.c b/standard/appspawn_kickdog.c index ef01677b..600ac395 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 ac4f7da8..bed93f4d 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 -- Gitee From 80e5adec6196d0e10038bc368f9c78556c08f120 Mon Sep 17 00:00:00 2001 From: wangfenging Date: Thu, 21 Aug 2025 17:12:41 +0800 Subject: [PATCH 10/21] Modify dlpmanager mount mode Signed-off-by: wangfenging --- appdata-sandbox.json | 7 - modules/sandbox/normal/sandbox_core.cpp | 94 ++++++------ modules/sandbox/normal/sandbox_core.h | 6 +- test/moduletest/appspawn_client_test.cpp | 1 - test/moduletest/appspawn_test_cmder.cpp | 1 - test/moduletest/test_app_info.json | 1 - .../app_spawn_sandbox_test.cpp | 136 +++++++++++++++++- test/unittest/app_spawn_test_helper.h | 3 +- 8 files changed, 180 insertions(+), 69 deletions(-) diff --git a/appdata-sandbox.json b/appdata-sandbox.json index 73706695..64f8ea73 100644 --- 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" : "", diff --git a/modules/sandbox/normal/sandbox_core.cpp b/modules/sandbox/normal/sandbox_core.cpp index 524053a7..076abf38 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"); diff --git a/modules/sandbox/normal/sandbox_core.h b/modules/sandbox/normal/sandbox_core.h index 1461b6fb..8758e863 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/test/moduletest/appspawn_client_test.cpp b/test/moduletest/appspawn_client_test.cpp index 3e285594..8e2960f1 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 f2449821..b1bca776 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 549e4699..bf584d89 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_standard_test/app_spawn_sandbox_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_test.cpp index 1d488af1..d929e46f 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); @@ -2440,4 +2440,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_test_helper.h b/test/unittest/app_spawn_test_helper.h index 4c9bfc33..4190f757 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") -- Gitee From 081a6d6170dc3e2d7e754f5eac25122bf0fbaab2 Mon Sep 17 00:00:00 2001 From: nianyuu Date: Thu, 21 Aug 2025 09:56:53 +0800 Subject: [PATCH 11/21] set pidMax when encaps extInfo is null Signed-off-by: nianyuu --- modules/common/appspawn_encaps.c | 73 +++++++++++-------- test/mock/app_spawn_stub.h | 3 +- .../app_spawn_common_test.cpp | 53 ++++++++------ 3 files changed, 73 insertions(+), 56 deletions(-) diff --git a/modules/common/appspawn_encaps.c b/modules/common/appspawn_encaps.c index 1d417e1d..6e22442c 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; @@ -283,35 +283,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); + + return permissionsJson; +} - encapsInfo->encap = (UserEncap *)calloc(count + 1, sizeof(UserEncap)); - APPSPAWN_CHECK(encapsInfo->encap != NULL, return APPSPAWN_SYSTEM_ERROR, "Failed to calloc encap"); +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 +349,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 +362,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 +424,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/test/mock/app_spawn_stub.h b/test/mock/app_spawn_stub.h index 5abe3276..3d4e12ef 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/unittest/app_spawn_standard_test/app_spawn_common_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_common_test.cpp index 266cb7be..3f6a4f11 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 @@ -775,7 +775,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,8 +816,8 @@ 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) @@ -827,16 +828,12 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_006, TestSize.Level0) 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) @@ -847,9 +844,17 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_007, TestSize.Level0) 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); @@ -1062,12 +1067,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 +1084,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 +1230,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) -- Gitee From c6b8f19a9893ad36689098c547f28fcaf7baa84b Mon Sep 17 00:00:00 2001 From: nianyuu Date: Sat, 23 Aug 2025 15:00:28 +0800 Subject: [PATCH 12/21] sync test code Signed-off-by: nianyuu --- modules/common/appspawn_common.c | 9 ++++---- .../sub_startup_appspawn_nativespawn_0100.py | 4 +++- .../sub_startup_appspawn_nativespawn_0200.py | 4 +++- .../sub_startup_appspawn_nativespawn_0300.py | 4 +++- .../sub_startup_appspawn_nativespawn_0400.py | 4 +++- .../sub_startup_appspawn_nativespawn_0500.py | 4 +++- .../sub_startup_appspawn_nativespawn_0700.py | 4 +++- .../sub_startup_appspawn_nativespawn_0900.py | 4 +++- .../sub_startup_appspawn_nativespawn_1000.py | 4 +++- .../sub_startup_appspawn_nativespawn_1100.py | 4 +++- .../sub_startup_appspawn_nativespawn_1200.py | 4 +++- .../sub_startup_appspawn_nativespawn_1300.py | 4 +++- .../sub_startup_appspawn_nativespawn_1400.py | 4 +++- .../sub_startup_appspawn_nativespawn_1500.py | 4 +++- .../sub_startup_appspawn_nativespawn_1600.py | 4 +++- .../sub_startup_appspawn_nativespawn_1700.py | 4 +++- .../sub_startup_appspawn_nativespawn_1800.py | 4 +++- .../sub_startup_appspawn_nativespawn_1900.py | 4 +++- .../app_spawn_client_test.cpp | 2 +- .../app_spawn_interface_test.cpp | 4 ++-- .../unittest/app_spawn_standard_test/BUILD.gn | 4 +++- .../app_spawn_sandbox_debug_mode.cpp | 2 +- .../app_spawn_sandbox_new_debug_mode.cpp | 21 ++++++++++--------- .../app_spawn_sandboxmgr_test.cpp | 2 +- 24 files changed, 74 insertions(+), 38 deletions(-) diff --git a/modules/common/appspawn_common.c b/modules/common/appspawn_common.c index 901c06bb..7c6095d7 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/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 e9ebe366..fea78abc 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 64f2ba3c..94df5ef8 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 32195b39..0cbc0e3e 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 5f0c5173..05c07a60 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 3f9a7bfc..3bcaac1e 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 5486dd66..387c4c3d 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 af214e54..427097fc 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 93161e24..9e0a418d 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 e31c6663..879a0149 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 53100365..8773b0bc 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 ffb58b3e..0c65799e 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 5d72bc5b..00a0c4f2 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 63c6344d..606387c2 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 4c20f740..3223b60a 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 474485a7..8c88da56 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 a99c2ab6..14145410 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 3ea853e4..e6670b74 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/unittest/app_spawn_client_test/app_spawn_client_test.cpp b/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp index 4fa5b75f..d99749cb 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 @@ -1199,7 +1199,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 005db33d..0a387a8e 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 c1624c89..5bfa7924 100644 --- a/test/unittest/app_spawn_standard_test/BUILD.gn +++ b/test/unittest/app_spawn_standard_test/BUILD.gn @@ -140,7 +140,9 @@ ohos_unittest("AppSpawn_ut") { ] 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" ] 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 5b4c5d40..c8cea619 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 04396530..05f94524 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_INVAILD. * @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_INVAILD. * @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_sandboxmgr_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandboxmgr_test.cpp index 1f736325..219854ad 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); } -- Gitee From c33de0759a98b33cf9742b7c1cb9b11a110c0e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=B5=A9?= Date: Wed, 6 Aug 2025 10:37:34 +0800 Subject: [PATCH 13/21] modeify readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨浩 --- modules/ace_adapter/ace_adapter.cpp | 2 +- service/hnp/README_zh.md | 3 +-- service/hnp/installer/README_zh.md | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/ace_adapter/ace_adapter.cpp b/modules/ace_adapter/ace_adapter.cpp index e38f114d..6f448c55 100644 --- a/modules/ace_adapter/ace_adapter.cpp +++ b/modules/ace_adapter/ace_adapter.cpp @@ -231,7 +231,7 @@ APPSPAWN_STATIC void ClearEnvAndReturnSuccess(AppSpawnContent *content, AppSpawn int ret = 0; ssize_t written = write(fd, &ret, sizeof(ret)); (void)close(fd); - APPSPAWN_LOGI("ClearEnvAndReturnSuccess %{public}u %{public}zd", client->id, written); + APPSPAWN_LOGI("ClearEnvAndReturnSuccess %{public}zd", written); } APPSPAWN_STATIC int RunChildThread(const AppSpawnMgr *content, const AppSpawningCtx *property) diff --git a/service/hnp/README_zh.md b/service/hnp/README_zh.md index 01e11883..5ad862a3 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 d06cda79..182f31e2 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) 接口调用安装: -- Gitee From 5dc9b2d88240c11731754cb68974dc664e877af8 Mon Sep 17 00:00:00 2001 From: nianyuu Date: Mon, 25 Aug 2025 14:45:35 +0800 Subject: [PATCH 14/21] add autotest testcases Signed-off-by: nianyuu --- ..._startup_appspawn_nativedmscheck_0100.json | 12 +++ ...ub_startup_appspawn_nativedmscheck_0100.py | 62 +++++++++++++ ..._startup_appspawn_nativedmscheck_0200.json | 12 +++ ...ub_startup_appspawn_nativedmscheck_0200.py | 67 ++++++++++++++ ..._startup_appspawn_nativedmscheck_0300.json | 12 +++ ...ub_startup_appspawn_nativedmscheck_0300.py | 80 +++++++++++++++++ ..._startup_appspawn_nativedmscheck_0400.json | 12 +++ ...ub_startup_appspawn_nativedmscheck_0400.py | 90 +++++++++++++++++++ .../sub_startup_appspawn_nativepack_0100.json | 12 +++ .../sub_startup_appspawn_nativepack_0100.py | 78 ++++++++++++++++ .../sub_startup_appspawn_nativepack_0200.json | 12 +++ .../sub_startup_appspawn_nativepack_0200.py | 68 ++++++++++++++ .../sub_startup_appspawn_nativepack_0300.json | 12 +++ .../sub_startup_appspawn_nativepack_0300.py | 77 ++++++++++++++++ .../sub_startup_appspawn_nativepack_0400.json | 12 +++ .../sub_startup_appspawn_nativepack_0400.py | 77 ++++++++++++++++ .../sub_startup_appspawn_nativepack_0500.json | 12 +++ .../sub_startup_appspawn_nativepack_0500.py | 88 ++++++++++++++++++ .../sub_startup_appspawn_nativepack_0600.json | 12 +++ .../sub_startup_appspawn_nativepack_0600.py | 86 ++++++++++++++++++ .../sub_startup_appspawn_nativeprocess.json | 20 +++++ .../sub_startup_appspawn_nativeprocess.py | 41 +++++++++ ...sub_startup_appspawn_nativeprocess_0100.py | 39 ++++++++ ...sub_startup_appspawn_nativeprocess_0200.py | 42 +++++++++ ...sub_startup_appspawn_nativeprocess_0400.py | 39 ++++++++ ...sub_startup_appspawn_nativeprocess_0500.py | 39 ++++++++ ...sub_startup_appspawn_nativeprocess_0600.py | 42 +++++++++ ...b_startup_appspawn_nativesandbox_0100.json | 12 +++ ...sub_startup_appspawn_nativesandbox_0100.py | 84 +++++++++++++++++ ...b_startup_appspawn_nativesandbox_0200.json | 13 +++ ...sub_startup_appspawn_nativesandbox_0200.py | 84 +++++++++++++++++ ...b_startup_appspawn_supplementary_0100.json | 14 +++ ...sub_startup_appspawn_supplementary_0100.py | 59 ++++++++++++ ...b_startup_appspawn_supplementary_0200.json | 14 +++ ...sub_startup_appspawn_supplementary_0200.py | 62 +++++++++++++ ...b_startup_appspawn_ubsanvariable_0100.json | 13 +++ ...sub_startup_appspawn_ubsanvariable_0100.py | 77 ++++++++++++++++ ...b_startup_appspawn_ubsanvariable_0200.json | 13 +++ ...sub_startup_appspawn_ubsanvariable_0200.py | 75 ++++++++++++++++ ...b_startup_appspawn_ubsanvariable_0300.json | 13 +++ ...sub_startup_appspawn_ubsanvariable_0300.py | 75 ++++++++++++++++ 41 files changed, 1763 insertions(+) create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json create mode 100644 test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json create mode 100644 test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py create mode 100644 test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py create mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json create mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py create mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json create mode 100644 test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py create mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json create mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py create mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json create mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json new file mode 100644 index 00000000..c467494b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py new file mode 100644 index 00000000..a3f4c191 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0100.py @@ -0,0 +1,62 @@ +#!/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, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativedmscheck0100(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:唤醒屏幕.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:创建公有hnp存放目录") + self.driver.shell("mkdir -p data/no_sign/public") + Step("步骤2:导入安装包文件hnp") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/no_sign/hnpsample.hnp')) + hap = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/no_sign/entry-default-signedArm64.hap')) + self.driver.push_file(hnp, "data/no_sign/public/") + self.driver.push_file(hap, "data/no_sign") + Step("步骤3:执行安装命令") + result = self.driver.shell( + "hnp install -u 100 -p wechat_sign -i /data/no_sign -s /data/no_sign/entry-default-signedArm64-test11.hap -a arm64 -f") + Step("步骤4:预期结果校验") + self.driver.Assert.contains(result, "hnp uninstall start now! name=hnpsample") + self.driver.Assert.contains(result, "native manager process exit. ret=8393475") + + def teardown(self): + self.driver.shell("rm -rf data/no_sign") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json new file mode 100644 index 00000000..676d65fa --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py new file mode 100644 index 00000000..6e495429 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0200.py @@ -0,0 +1,67 @@ +#!/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, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativedmscheck0200(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:唤醒屏幕.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:创建公有hnp存放目录") + self.driver.shell("mkdir -p data/wechat_sign/public") + Step("步骤2:导入安装包文件hnp") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/hnpsample.hnp')) + hap = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) + self.driver.push_file(hnp, "data/wechat_sign/public/") + self.driver.push_file(hap, "data/wechat_sign") + Step("步骤3:执行安装命令") + result1 = self.driver.shell( + "hnp install -u 100 -p wechat_sign -i /data/wechat_sign -s /data/wechat_sign/entry-default-signedArm64-test11.hap -a arm64 -f") + Step("步骤4:预期结果校验") + public = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/") + self.driver.Assert.contains(public, "hnpsample.org") + result = self.driver.shell("cat /data/service/el1/startup/hnp_info.json") + self.driver.Assert.contains(result, "wechat_sign") + self.driver.Assert.contains(result1, "native manager process exit. ret=0") + self.driver.Assert.contains(result1, "hnp install start now! src file=/data/wechat_sign/public/hnpsample.hnp, dst path=/data/app/el1/bundle/100/hnppublic") + + def teardown(self): + self.driver.shell("rm -rf data/sign") + self.driver.shell("hnp uninstall -u 100 -p wechat_sign") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json new file mode 100644 index 00000000..7edfe4b8 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py new file mode 100644 index 00000000..54d9d5e7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0300.py @@ -0,0 +1,80 @@ +#!/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, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativedmscheck0300(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:唤醒屏幕.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b I -D 0xC02C11") + self.driver.shell("hilog -b DEBUG -T APPSPAWN") + self.driver.shell("hilog -b D -D 0xDC02C11") + self.driver.shell("hilog -G 16M") + host.shell('hdc shell "hilog -r"') + + def test_step1(self): + Step("步骤1:安装私有路径hap包") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hap1 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signedArm64Pri-test.hap')) + hap2 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signed-hnpselinux.hap')) + self.driver.install_app(hap1) + self.driver.install_app(hap2) + Step("步骤2:过滤日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("MY_TAG") + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:打开测试应用") + self.driver.start_app("com.example.hnpselinuxtestapplication", "EntryAbility") + time.sleep(60) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(4) + device_logger.check_log('Open public cfg file to read failed, errno=[2]') + device_logger.check_log('Open public cfg file to write failed, errno=[2]') + device_logger.check_log('Open private cfg file to read failed, errno=[2]') + device_logger.check_log('Open private cfg file to write failed, errno=[2]') + + def teardown(self): + Step("收尾工作:删除hap") + self.driver.uninstall_app("com.example.hnp_test") + self.driver.uninstall_app("com.example.hnpselinuxtestapplication") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json new file mode 100644 index 00000000..1aafb7c2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativedmscheck/SubStartupAppspawnNativedmscheck0400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py new file mode 100644 index 00000000..2cdbd51e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativedmscheck/sub_startup_appspawn_nativedmscheck_0400.py @@ -0,0 +1,90 @@ +#!/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, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativedmscheck0400(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:唤醒屏幕.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b I -D 0xC02C11") + self.driver.shell("hilog -b DEBUG -T APPSPAWN") + self.driver.shell("hilog -b D -D 0xDC02C11") + self.driver.shell("hilog -G 16M") + host.shell('hdc shell "hilog -r"') + + def test_step1(self): + Step("步骤1:安装私有路径hap包") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hap1 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signedArm64-test.hap')) + hap2 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-signed-hnpselinux.hap')) + self.driver.install_app(hap1) + self.driver.install_app(hap2) + Step("步骤2:过滤日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("MY_TAG") + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:打开测试应用") + self.driver.start_app("com.example.hnpselinuxtestapplication", "EntryAbility") + time.sleep(60) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(4) + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device): + device_logger.check_log("cfg file content:") + device_logger.check_log("[This is hnp sample config file.].") + device_logger.check_log("cfg file end") + device_logger.check_log('Open public cfg file to write failed, errno=[13]') + else: + device_logger.check_log('Open public cfg file to read failed, errno=[2]') + device_logger.check_log('Open public cfg file to write failed, errno=[2]') + device_logger.check_log('Open private cfg file to read failed, errno=[2]') + device_logger.check_log('Open private cfg file to write failed, errno=[2]') + + def teardown(self): + Step("收尾工作:删除hap") + self.driver.uninstall_app("com.example.hnp_test") + self.driver.uninstall_app("com.example.hnpselinuxtestapplication") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json new file mode 100644 index 00000000..a8e61cc2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py new file mode 100644 index 00000000..60b3688b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0100.py @@ -0,0 +1,78 @@ +#!/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 hypium.model import UiParam, WindowFilter +import os +import time + + +class SubStartupAppspawnNativepack0100(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('预置工作:新增一个123.txt文件') + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample')) + with open(file + "\\lib\\123.txt", "a+") as f1: + f1.write("12345678hdaskheiwoi4eliqwkldsajoejqooiudsisa") + + def test_step1(self): + Step("获取bat文件路径") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) + Step("执行bat文件") + host.shell(bat) + Step("复制压缩文件") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) + sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) + host.shell("copy "+file1 + " " + file2) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(file2, out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + with open(sample + "\\lib\\123.txt") as f: + dif1 = f.read() + with open(out + "\\sample\\lib\\123.txt") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除out目录文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json new file mode 100644 index 00000000..f42ce0d5 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py new file mode 100644 index 00000000..1a38d824 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0200.py @@ -0,0 +1,68 @@ +#!/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 hypium.model import UiParam, WindowFilter +import os +import time + + +class SubStartupAppspawnNativepack0200(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("获取bat文件路径") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) + Step("执行bat文件") + host.shell(bat) + Step("复制压缩文件") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) + sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) + host.shell("copy "+file1 + " " + file2) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(file2, out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除out目录文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json new file mode 100644 index 00000000..376a9a5f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py new file mode 100644 index 00000000..9a1631cc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0300.py @@ -0,0 +1,77 @@ +#!/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 hypium.model import UiParam, WindowFilter +import os +import time + + +class SubStartupAppspawnNativepack0300(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('预置工作:修改打包的文件') + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample')) + with open(file+"\\cfg\\hnpsample.cfg", "a") as f1: + f1.write("weuhriqj82hs9九jisapojhwkeioqw8321093nskjdlajejnphoneklv") + time.sleep(2) + + def test_step1(self): + Step("获取bat文件路径") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + bat = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/run.bat')) + Step("执行bat文件") + host.shell(bat) + Step("复制压缩文件") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) + sample = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/sample/')) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.hnp')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/hnpsample.zip')) + host.shell("copy "+file1 + " " + file2) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(file2, out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除out目录文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/window/out/')) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + with open(file + "\\cfg\\hnpsample.cfg", "w") as f1: + f1.write("This is hnp sample config file.") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json new file mode 100644 index 00000000..b615cf06 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py new file mode 100644 index 00000000..ed43fa77 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0400.py @@ -0,0 +1,77 @@ +#!/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 hypium.model import UiParam, WindowFilter +import os +import time + + +class SubStartupAppspawnNativepack0400(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("步骤1:添加读写权限") + self.driver.hdc("target mount") + Step("步骤2:导入打包所需的文件到设备data/usr目录") + self.driver.shell("mkdir data/usr") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + self.driver.hdc("hdc file send " + file1 + " /data") + self.driver.hdc("hdc file send " + file2 + " /data/usr") + Step("步骤3:添加权限") + self.driver.shell("chmod +x /data/hnpcli") + Step("步骤4:执行打包命令") + self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") + Step("步骤5:复制hnp文件为zip文件") + self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") + Step("步骤6:导出生成的zip包到本地") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.hdc("hdc file recv /data/hnpsample.zip "+out) + Step("步骤7:解压hnpsample.zip文件") + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + with open(file2+"\\cfg\\hnpsample.cfg") as f: + dif1 = f.read() + with open(out+"\\sample\\cfg\\hnpsample.cfg") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除out目录文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.shell("rm -rf /data/hnpsample.zip") + self.driver.shell("rm -rf /data/hnpsample.hnp") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json new file mode 100644 index 00000000..ecdac029 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0500.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py new file mode 100644 index 00000000..a50cf5e1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0500.py @@ -0,0 +1,88 @@ +#!/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 Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativepack0500(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('预置工作:设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('预置工作:修改打包的文件') + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + with open(file+"\\cfg\\hnpsample.cfg", "a") as f1: + f1.write("weuhriqj82hs9九jisapojhwkeioqw8321093nskjdlajejnphoneklv") + time.sleep(2) + + def test_step1(self): + Step("步骤1:添加读写权限") + self.driver.hdc("target mount") + Step("步骤2:导入打包所需的文件到设备data/usr目录") + self.driver.shell("mkdir data/usr") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + self.driver.hdc("hdc file send " + file1 + " /data") + self.driver.hdc("hdc file send " + file2 + " /data/usr") + Step("步骤3:添加权限") + self.driver.shell("chmod +x /data/hnpcli") + Step("步骤4:执行打包命令") + self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") + Step("步骤5:复制hnp文件为zip文件") + self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") + Step("步骤6:导出生成的zip包到本地") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.hdc("hdc file recv /data/hnpsample.zip " + out) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(out + "\\hnpsample.zip", out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除&修改相关文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.shell("rm -rf /data/hnpsample.zip") + self.driver.shell("rm -rf /data/hnpsample.hnp") + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + with open(file + "\\cfg\\hnpsample.cfg", "w") as f1: + f1.write("This is hnp sample config file.") + + diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json new file mode 100644 index 00000000..434e339a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativepack/SubStartupAppspawnNativepack0600.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py new file mode 100644 index 00000000..49a7f75c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativepack/sub_startup_appspawn_nativepack_0600.py @@ -0,0 +1,86 @@ +#!/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 Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativepack0600(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('预置工作:设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('预置工作:新增一个123.txt文件') + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + f1.write("12345678hdaskheiwoi4eliqwkldsajoejqooiudsisa") + + def test_step1(self): + Step("步骤1:添加读写权限") + self.driver.hdc("target mount") + Step("步骤2:导入打包所需的文件到设备data/usr目录") + self.driver.shell("mkdir data/usr") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + file1 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/hnpcli')) + file2 = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + self.driver.hdc("hdc file send " + file1 + " /data") + self.driver.hdc("hdc file send " + file2 + " /data/usr") + Step("步骤3:添加权限") + self.driver.shell("chmod +x /data/hnpcli") + Step("步骤4:执行打包命令") + self.driver.shell("data/hnpcli pack -i /data/usr/sample -o /data ") + Step("步骤5:复制hnp文件为zip文件") + self.driver.shell("cp /data/hnpsample.hnp /data/hnpsample.zip") + Step("步骤6:导出生成的zip包到本地") + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + self.driver.hdc("hdc file recv /data/hnpsample.zip " + out) + Step("步骤7:解压hnpsample.zip文件") + host.unzip_file(out + "\\hnpsample.zip", out) + Step("步骤8:比较2个文件内容是否一致") + time.sleep(1) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + dif1 = f.read() + with open(out + "\\sample\\lib\\123.txt") as f: + dif2 = f.read() + self.driver.Assert.equal(dif1, dif2) + + def teardown(self): + Step("收尾工作:删除相关文件") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + out = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/out/')) + file = os.path.abspath(os.path.join(os.path.join(path, "testFile"), 'sub_startup_appspawn_nativepack/sample')) + self.driver.shell("rm -rf /data/hnpsample.zip") + self.driver.shell("rm -rf /data/hnpsample.hnp") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json new file mode 100644 index 00000000..8c1a9c37 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.json @@ -0,0 +1,20 @@ +{ + "description": "Config for OpenHarmony app test suites", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTestSuite", + "testsuite": "sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py", + "suitecases": [ + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0100.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0200.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0300.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0400.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0500.py", + "sub_startup_appspawn_nativeprocess/SubStartupAppspawnNativeprocess0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py new file mode 100644 index 00000000..3ef49829 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess.py @@ -0,0 +1,41 @@ +#!/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 +from devicetest.core.suite.test_suite import TestSuite +from aw import Common + + +class SubStartupAppspawnNativeprocess(TestSuite): + + def setup(self): + Step("TestCase: setup") + self.driver = UiDriver(self.device1) + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("导入配置文件.................") + self.driver.hdc("target mount") + sourpath = Common.sourcepath("AppSpawnTest", "sub_startup_appspawn_nativeprocess") + destpath = "/data/AppSpawnTest" + self.driver.push_file(sourpath, destpath) + sleep(3) + Step("给测试文件AppSpawnTest可执行权限.................") + self.driver.shell('chmod +x /data/AppSpawnTest') + self.driver.shell('./data/AppSpawnTest') + + def teardown(self): + Step("收尾工作,删除文件.................") + self.driver.shell("rm /data/AppSpawnTest") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py new file mode 100644 index 00000000..26b96df1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0100.py @@ -0,0 +1,39 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0100(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest') + self.driver.Assert.contains(result, "Failed spawn new app result", "默认启动孵化APPSPAWN失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py new file mode 100644 index 00000000..27866f8d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0200.py @@ -0,0 +1,42 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0200(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest -s -b moduleTestProcessName') + self.driver.Assert.contains(result, "Failed spawn new app result", "带沙盒启动孵化APPSPAWN失败") + Step("执行AppSpawnTest'.................") + failresult = self.driver.shell('./data/AppSpawnTest -s') + self.driver.Assert.contains(failresult, "Failed spawn new app result -1", "模拟'带沙盒启动孵化APPSPAWN失败'失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py new file mode 100644 index 00000000..c16add36 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0400.py @@ -0,0 +1,39 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0400(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx') + self.driver.Assert.contains(result, "Failed spawn new app result", "模拟新app启动孵化APPSPAWN失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py new file mode 100644 index 00000000..f10dd2c7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0500.py @@ -0,0 +1,39 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0500(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx -s') + self.driver.Assert.contains(result, "Failed spawn new app result -1", "指定不存在app启动孵化APPSPAWN失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py new file mode 100644 index 00000000..dc1c2248 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativeprocess/sub_startup_appspawn_nativeprocess_0600.py @@ -0,0 +1,42 @@ +#!/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 + + +class SubStartupAppspawnNativeprocess0600(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("执行AppSpawnTest'.................") + result = self.driver.shell('./data/AppSpawnTest -b ohos.xxxxxx.xxxxxxxx -s') + self.driver.Assert.contains(result, "Failed spawn new app result -1", "指定不存在app启动孵化APPSPAWN失败") + Step("执行AppSpawnTest'.................") + successresult = self.driver.shell('./data/AppSpawnTest -C') + self.driver.Assert.contains(result, "Failed spawn new app result", "模拟指定不存在的app启动孵化APPSPAWN失败后,重新启动测试失败") + + def teardown(self): + Step("TestCase: teardown") diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json new file mode 100644 index 00000000..9f5581fd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativesandbox/SubStartupAppspawnNativesandbox0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py new file mode 100644 index 00000000..982ae508 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0100.py @@ -0,0 +1,84 @@ +#!/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 Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativesandbox0100(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.shell("power-shell timeout -o 2147483647") + + def test_step1(self): + Step("步骤1:创建公有hnp存放目录") + self.driver.shell("mkdir -p data/UCbrowser/public") + Step("步骤2:导入安装包文件hnp") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/hnpsample.hnp')) + hap = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) + self.driver.push_file(hnp, "data/UCbrowser/public/") + self.driver.push_file(hap, "data/UCbrowser") + Step("步骤3:执行安装命令") + self.driver.shell( + "hnp install -u 100 -p uc_browser -i data/UCbrowser -s data/UCbrowser/entry-default-signedArm64-test11.hap -a arm64 -f") + Step("步骤4:查看是是否安装成功") + public = self.driver.shell("ls /data/app/el1/bundle/100/hnppublic/") + self.driver.Assert.contains(public, "hnpsample.org") + result = self.driver.shell("cat /data/service/el1/startup/hnp_info.json") + self.driver.Assert.contains(result, "uc_browser") + Step("步骤5:安装测试hap包") + ishap = self.driver.has_app("com.example.hnptestapplication") + if (ishap): + hap1 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-sandbox.hap')) + self.driver.install_app(hap1) + Step("步骤6:打开测试hap包") + self.driver.shell("aa start -a EntryAbility -b com.example.hnptestapplication") + Step("步骤7:获取测试应用pid") + time.sleep(3) + pid = self.driver.System.get_pid("com.example.hnptestapplication") + Step("步骤8:查看测试应用公有沙箱路径") + result = self.driver.shell("ls /proc/%d/root/data/service/hnp" % pid) + Step("步骤9:预期结果校验") + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device): + self.driver.Assert.contains(result, "bin") + self.driver.Assert.contains(result, "hnpsample.org") + else: + self.driver.Assert.contains(result, "No such file or directory") + diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json new file mode 100644 index 00000000..700785e5 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_nativesandbox/SubStartupAppspawnNativesandbox0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py new file mode 100644 index 00000000..d26ab39d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_nativesandbox/sub_startup_appspawn_nativesandbox_0200.py @@ -0,0 +1,84 @@ +#!/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 Step, TestCase +from hypium.model import UiParam, WindowFilter +import os + + +class SubStartupAppspawnNativesandbox0200(TestCase): + + def __init__(self, controllers): + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.shell("power-shell timeout -o 2147483647") + + def test_step1(self): + Step("步骤1:创建公有hnp存放目录") + self.driver.shell("mkdir -p data/com.example.hnptestapplication/private") + Step("步骤2:导入安装包文件hnp") + path = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + hnp = os.path.abspath(os.path.join( + os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/hnpsample.hnp')) + hap = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), 'SUB_STARTUP_APPSPAWN_NATIVE/sign/entry-default-signedArm64-test11.hap')) + self.driver.push_file(hnp, "data/com.example.hnptestapplication/private/") + self.driver.push_file(hap, "data/com.example.hnptestapplication") + Step("步骤3:执行安装命令") + self.driver.shell( + "hnp install -u 100 -p com.example.hnptestapplication -i data/com.example.hnptestapplication -s data/com.example.hnptestapplication/entry-default-signedArm64-test11.hap -a arm64 -f") + Step("步骤4:查看是是否安装成功") + public = self.driver.shell("ls /data/app/el1/bundle/100/hnp/com.example.hnptestapplication") + self.driver.Assert.contains(public, "hnpsample.org") + Step("步骤5:安装测试hap包") + ishap = self.driver.has_app("com.example.hnptestapplication") + if (ishap): + hap1 = os.path.abspath( + os.path.join(os.path.join(path, "testFile"), + 'SUB_STARTUP_APPSPAWN_NATIVE/entry-default-sandbox.hap')) + self.driver.install_app(hap1) + Step("步骤6:打开测试hap包") + self.driver.shell("aa start -a EntryAbility -b com.example.hnptestapplication") + Step("步骤7:获取测试应用pid") + time.sleep(1) + pid = self.driver.System.get_pid("com.example.hnptestapplication") + Step("步骤8:查看测试应用公有沙箱路径") + result = self.driver.shell("ls /proc/%d/root/data/app" % pid) + Step("步骤9:预期结果校验") + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("HYM" in device or "HAD" in device): + self.driver.Assert.contains(result, "bin") + self.driver.Assert.contains(result, "hnpsample.org") + else: + self.driver.Assert.contains(result, "No such file or directory") + + def teardown(self): + self.driver.shell("hnp uninstall -u 100 -p com.example.hnptestapplication") diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json new file mode 100644 index 00000000..9a4957d4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_supplementary/Substartupappspawnsupplementary0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py new file mode 100644 index 00000000..fc2cad96 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py @@ -0,0 +1,59 @@ +#!/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 hyp import HypiumClass1, HypiumClass2, HypiumFunction1 + +from aw import Common + + +class Substartupappspawnsupplementary0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("asan.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") + 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.example.myapplication", "EntryAbility") + sleep(3) + Step("校验hap显示Hello World.................") + if not self.driver.find_component(BY.text("Hello World")): + throw std::runtime_error("Failed to find component with text 'Hello'") + + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json new file mode 100644 index 00000000..d17ba198 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_supplementary/Substartupappspawnsupplementary0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py new file mode 100644 index 00000000..4b5ec061 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py @@ -0,0 +1,62 @@ +#!/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 importFunction1, SpecificFunction2 + +from aw import Common + + +class Substartupappspawnsupplementary0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("sn.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") + 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.example.myapplication", "EntryAbility") + sleep(3) + Step("检查存在device info.................") + assert self.driver.find_component(BY.text("3333333", MatchPattern.CONTAINS)) + print("点击菜单device info.................") + self.driver.touch(BY.text(" device info ")) + sleep(1) + Step("校验serial为空.................") + if not self.driver.find_component(BY.text("serial: " + "\n" + " deviceType", MatchPattern.CONTAINS)) + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json new file mode 100644 index 00000000..53f12fe9 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py new file mode 100644 index 00000000..f8876929 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py @@ -0,0 +1,77 @@ +#!/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 + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import HypiumClass, HypiumFunction +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class Substartupappspawnubsanvariable0100(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D -D 0xC02C11") + self.driver.shell("hilog -b DEBUG -T APPSPAWN") + self.driver.shell("hilog -b D -D 0xDC02C11") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledTrueProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if(ishap): + self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledtrueprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + device_logger.check_log('SetAsanEnabledEnv 22,(null),(null),(null)') + device_logger.check_log('print_stacktrace=1:print_module_map=2:log_exe_name=1,(null)') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json new file mode 100644 index 00000000..29b796cf --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py new file mode 100644 index 00000000..83070fb5 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py @@ -0,0 +1,75 @@ +#!/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 + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hyp import HypiumClass1, HypiumClass2, HypiumFunction1 +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class Substartupappspawnubsanvariable0200(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledFalseProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if (ishap): + self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledfalseprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json new file mode 100644 index 00000000..e72103b0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py new file mode 100644 index 00000000..591f529c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py @@ -0,0 +1,75 @@ +#!/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 + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import HypiumClass, HypiumFunction +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class Substartupappspawnubsanvariable0300(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartNoConfigEnabledProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if (ishap): + self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartnoconfigenabledprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") + self.driver.shell("hilog -b I") -- Gitee From 1617bb84dfc8f54f3acd791fc8f1e2b11d126206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Mon, 25 Aug 2025 14:39:26 +0800 Subject: [PATCH 15/21] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- .../sub_startup_appspawn_cgroups_0100.json} | 26 +-- .../sub_startup_appspawn_cgroups_0100.py | 75 +++++++ .../sub_startup_appspawn_cgroups_0200.json} | 26 +-- .../sub_startup_appspawn_cgroups_0200.py | 73 +++++++ .../sub_startup_appspawn_cgroups_0300.json} | 26 +-- .../sub_startup_appspawn_cgroups_0300.py | 73 +++++++ .../sub_startup_appspawn_coldstart_0100.json | 15 ++ .../sub_startup_appspawn_coldstart_0100.py | 59 ++++++ ...startup_appspawn_coldstartablity_0100.json | 15 ++ ..._startup_appspawn_coldstartablity_0100.py} | 127 ++++++------ ...startup_appspawn_coldstartablity_0200.json | 15 ++ ..._startup_appspawn_coldstartablity_0200.py} | 122 ++++++----- .../sub_startup_appspawn_debughap_0100.json} | 26 +-- .../sub_startup_appspawn_debughap_0100.py} | 144 ++++++------- .../sub_startup_appspawn_debughap_0200.json | 14 ++ .../sub_startup_appspawn_debughap_0200.py} | 125 ++++++------ .../sub_startup_appspawn_debughap_0300.json | 14 ++ .../sub_startup_appspawn_debughap_0300.py | 79 ++++++++ .../sub_startup_appspawn_debughap_0500.json | 14 ++ .../sub_startup_appspawn_debughap_0500.py} | 145 ++++++------- .../sub_startup_appspawn_debughap_0600.json | 15 ++ .../sub_startup_appspawn_debughap_0600.py} | 146 ++++++-------- .../sub_startup_appspawn_debughap_0700.json | 15 ++ .../sub_startup_appspawn_debughap_0700.py | 78 +++++++ .../sub_startup_appspawn_debughap_0800.json | 14 ++ .../sub_startup_appspawn_debughap_0800.py} | 190 ++++++++++-------- .../sub_startup_appspawn_debughap_0900.json | 14 ++ .../sub_startup_appspawn_debughap_0900.py} | 143 ++++++------- .../sub_startup_appspawn_devicedebug_0300.py | 86 -------- ...sub_startup_appspawn_devicedebug_0500.json | 14 -- ...sub_startup_appspawn_devicedebug_0600.json | 14 -- ...sub_startup_appspawn_devicedebug_0700.json | 14 -- ...sub_startup_appspawn_devicedebug_0800.json | 14 -- ...sub_startup_appspawn_devicedebug_0900.json | 14 -- 34 files changed, 1174 insertions(+), 810 deletions(-) rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json => sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json} (67%) create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json => sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json} (67%) create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json => sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json} (67%) create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py create mode 100644 test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json create mode 100644 test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py => sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py} (38%) create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py => sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py} (40%) rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json => sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json} (67%) rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py => sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py} (64%) create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py => sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py} (60%) create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py => sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py} (64%) create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py => sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py} (62%) create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py => sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py} (41%) create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py => sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py} (62%) delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json similarity index 67% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json rename to test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json index b764571d..2e315add 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json @@ -1,14 +1,14 @@ -{ - "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" - ] - } +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_cgroups/Substartupappspawncgroups0100.py" + ] + } } \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py new file mode 100644 index 00000000..0e24a7f9 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py @@ -0,0 +1,75 @@ +#!/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 importFunction1, SpecificFunction2 + +from aw import Common + +class Substartupappspawncgroups0100(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 + 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.shell("power-shell setmode 602") + + def process(self): + hap_path = Common.sourcepath('ForkTest1.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name + bundle_name = "com.example.exe_sys_cmd" + 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) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef | grep %s" % bundle_name) + cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" %(bundle_name, pid)).split() + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 2: + count += 1 + self.driver.Assert.equal(count, 1) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.clear_app_data(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_cgroups/sub_startup_appspawn_cgroups_0200.json similarity index 67% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json rename to test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json index e560671a..26a1000e 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json @@ -1,14 +1,14 @@ -{ - "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" - ] - } +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_cgroups/Substartupappspawncgroups0200.py" + ] + } } \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py new file mode 100644 index 00000000..e11d33c4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py @@ -0,0 +1,73 @@ +#!/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 SomeClass, some_function + +from aw import Common + + +class Substartupappspawncgroups0200(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 + 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.shell("power-shell timeout -o 86400000") + + def process(self): + hap_path = Common.sourcepath('ForkTest2.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name = "com.example.exe_sys_cmd" + 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) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef | grep %s" % bundle_name) + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 3: + count += 1 + self.driver.Assert.equal(count, 1) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.uninstall_app("com.example.exe_sys_cmd") \ 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_cgroups/sub_startup_appspawn_cgroups_0300.json similarity index 67% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json rename to test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json index cb9198c7..1be0bf2f 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json @@ -1,14 +1,14 @@ -{ - "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" - ] - } +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_cgroups/Substartupappspawncgroups0300.py" + ] + } } \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py new file mode 100644 index 00000000..da0bcc97 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py @@ -0,0 +1,73 @@ +#!/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 HypiumClass, HypiumFunction + +from aw import Common + + +class Substartupappspawncgroups0300(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 + 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.shell("power-shell timeout -o 86400000") + + def process(self): + hap_path = Common.sourcepath('ForkTest3.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name = "com.example.exe_sys_cmd" + 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) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef |grep %s" % bundle_name) + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 2: + count += 1 + self.driver.Assert.equal(count, 2) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.uninstall_app("com.example.exe_sys_cmd") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json new file mode 100644 index 00000000..49136690 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_coldstart/Substartupappspawncoldstart0100.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..d0c65b3f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py @@ -0,0 +1,59 @@ +#!/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 import HypiumFunction1, HypiumFunction + + +class Substartupappspawncoldstart0100(TestCase): + + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + 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) + + def test_step1(self): + Step("设置冷启动全局参数.................") + result = self.driver.shell('param set startup.appspawn.cold.boot 1') + sleep(3) + if "Set parameter startup.appspawn.cold.boot 1 success" in result: + pass + else: + raise ValueError('设置冷启动全局参数失败!') + Step("通过命令启动日历.................") + 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.calendar") + result_ps = result_ps.split('\n')[0] + Step("日历进程信息如下:" + str(result_ps)) + if '"' in result_ps: + throw std::logic_error("日进程信息中包含非法字符 \"") + + def teardown(self): + Step("收尾工作.................") + pid = self.driver.System.get_pid('com.calendar') + self.driver.shell("kill -9 " + str(pid)) + diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json new file mode 100644 index 00000000..0a585dcc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_coldstartablity/Substartupappspawncoldstartablity0100.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_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py similarity index 38% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py rename to test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py index 8446d1c5..da2d64dc 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py @@ -1,66 +1,61 @@ -#!/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 +#!/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 hyp import HypiumClass1, HypiumClass2, HypiumFunction1 + +from aw import Common + + +class Substartupappspawncoldstartablity0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + 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("asan-enable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") + 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.example.myapplication", "EntryAbility") + sleep(3) + pid = self.driver.System.get_pid('com.example.myapplication') + Step(pid) + Step("校验hap应用的maps.................") + result = self.driver.shell('cat ' + os.path.join('/proc', str(pid), 'maps') + '|grep libclang.asan.so') + Step(result) + self.driver.Assert.contains(result, '/system/lib64/libclang_rt.asan.so') + self.driver.Assert.contains(result, 'anon:libclang_rt.asan.so.bss') + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json new file mode 100644 index 00000000..0e9342a4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_coldstartablity/Substartupappspawncoldstartablity0200.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_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py similarity index 40% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py rename to test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py index f37c3217..04fc5b10 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py @@ -1,62 +1,60 @@ -#!/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 +#!/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 hyp import HypiumClass1, HypiumClass2, HypiumFunction1 + +from aw import Common + + +class Substartupappspawncoldstartablity0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + 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("asan-disable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") + 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.example.myapplication", "EntryAbility") + sleep(3) + pid = self.driver.System.get_pid('com.example.myapplication') + Step(pid) + Step("校验hap应用的maps.................") + Step(result) + self.driver.Assert.equal(result, '') + + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json similarity index 67% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json rename to test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json index 9b0248bf..1fd513bc 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json @@ -1,14 +1,14 @@ -{ - "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" - ] - } +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0100.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_debughap/sub_startup_appspawn_debughap_0100.py similarity index 64% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py rename to test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py index f958bb79..a429b69f 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py @@ -1,82 +1,64 @@ -#!/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) +#!/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.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0100(TestCase): + + def __init__(self, controllers): + 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): + Step("安装测试hap并打开") + bundle_name = "com.example.release" + hap_path = Common.sourcepath('release.hap', "sub_startup_appspawn_debughap") + 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) + + release_has = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s" % bundle_name) + self.driver.Assert.equal(release_has, False) + + 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_debughap/sub_startup_appspawn_debughap_0200.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json new file mode 100644 index 00000000..66713d04 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0200.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_debughap/sub_startup_appspawn_debughap_0200.py similarity index 60% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py rename to test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py index f7d2d294..dec704a0 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py @@ -1,61 +1,64 @@ -#!/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 +#!/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.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0200(TestCase): + + def __init__(self, controllers): + 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): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + 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("param set startup.appspawn.sandbox.debughap true") + self.driver.AppManager.start_app(bundle_name) + + result = self.driver.shell("ls /mnt/debug/100/debug_hap").split() + self.driver.Assert.contains(result, bundle_name) + + 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_debughap/sub_startup_appspawn_debughap_0300.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json new file mode 100644 index 00000000..4918b0b9 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py new file mode 100644 index 00000000..fb7609b2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0300.py @@ -0,0 +1,79 @@ +#!/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.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0300(TestCase): + + def __init__(self, controllers): + 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): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + 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("param set startup.appspawn.sandbox.debughap true") + self.driver.AppManager.start_app(bundle_name) + + sandbox_list = [] + mount_dict = list(filter(None, self.driver.shell("mount|grep %s" % bundle_name).split("\n"))) + for mount in mount_dict: + if mount.split()[2].startswith("/mnt/debug"): + sandbox_list.append(mount.split()[2]) + else: + pass + + for i in range(1, 5): + for path in ["base", "database"]: + self.driver.Assert.contains(sandbox_list, "/mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" + % (bundle_name, i, path)) + + list01 = ["el2/share", "el2/log", "el1/bundle", "el2/auth_groups", "el2/distributedfiles"] + for path in list01: + self.driver.Assert.contains(sandbox_list, "/mnt/debug/100/debug_hap/%s/data/storage/%s" + % (bundle_name, path)) + + 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_debughap/sub_startup_appspawn_debughap_0500.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json new file mode 100644 index 00000000..a8e1e788 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0500.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_debughap/sub_startup_appspawn_debughap_0500.py similarity index 64% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py rename to test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py index a16ae9e2..e410e953 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py @@ -1,83 +1,64 @@ -#!/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) +#!/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.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0500(TestCase): + + def __init__(self, controllers): + 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): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + 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) + + result = self.driver.shell("ls -Z /mnt/debug/100/debug_hap").split("\n") + self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % bundle_name) + + 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_debughap/sub_startup_appspawn_debughap_0600.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json new file mode 100644 index 00000000..7a19d9b4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0600.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_debughap/sub_startup_appspawn_debughap_0600.py similarity index 62% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py rename to test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py index 3c846505..446185f8 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py @@ -1,84 +1,64 @@ -#!/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) +#!/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.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0600(TestCase): + + def __init__(self, controllers): + 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): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + 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) + + result = self.driver.shell("ls /mnt/debug/100/debug_hap").split() + self.driver.Assert.contains(result, bundle_name) + + 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_debughap/sub_startup_appspawn_debughap_0700.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json new file mode 100644 index 00000000..5538e209 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py new file mode 100644 index 00000000..e19ac7fd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0700.py @@ -0,0 +1,78 @@ +#!/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.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0700(TestCase): + + def __init__(self, controllers): + 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) + + self.driver.hdc("target mount") + self.driver.shell("mv /system/etc/init/init_dec.cfg /system/etc/init/init_dec.cfg_bak") + cfg_path = Common.sourcepath('init_dec.cfg', "sub_startup_appspawn_debughap") + self.driver.push_file(cfg_path, "/system/etc/init") + self.driver.System.reboot() + # 解锁屏幕 + 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并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + 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("param set startup.appspawn.sandbox.debughap true") + self.driver.AppManager.start_app(bundle_name) + + has_dir = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s" % bundle_name) + self.driver.Assert.equal(has_dir, True) + result = self.driver.shell("ls /mnt/debug/100/debug_hap/%s" % bundle_name) + self.driver.Assert.contains(result, "Operation not permitted") + + def teardown(self): + Step("收尾工作.................") + self.driver.hdc("target mount") + self.driver.shell("mv /system/etc/init/init_dec.cfg_bak /system/etc/init/init_dec.cfg") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.System.reboot() + self.driver.System.wait_for_boot_complete() + self.driver.shell("param set startup.appspawn.sandbox.debughap true") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json new file mode 100644 index 00000000..d17ff07f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0800.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_debughap/sub_startup_appspawn_debughap_0800.py similarity index 41% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py rename to test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py index 023bb122..7974ad11 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py @@ -1,88 +1,104 @@ -#!/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) +#!/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.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0800(TestCase): + + def __init__(self, controllers): + 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): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + 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) + + for i in range(1, 5): + for path in {"database", "base"}: + mac_path = self.driver.Storage.has_dir("/data/app/el%d/100/%s/%s" % (i, path, bundle_name)) + sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" + % (bundle_name, i, path)) + self.driver.Assert.equal(mac_path, sandbox_path) + + if mac_path is True: + mac_path_content = self.driver.shell("ls /data/app/el%d/100/%s/%s" % (i, path, bundle_name)) + sandbox_path_content = self.driver.shell("ls /mnt/debug/100/debug_hap/%s/data/storage/el%d/%s" + % (bundle_name, i, path)) + self.driver.Assert.equal(mac_path_content, sandbox_path_content) + + path_dict = { + "/mnt/hmdfs/100/non_account/merge_view/data": "el2/auth_groups", + "/mnt/hmdfs/100/account/merge_view/data": "el2/distributedfiles", + "/data/app/el2/100/log": "el2/log", + "/data/app/el1/bundle/public": "el1/bundle", + "/mnt/share/100": "el2/share" + } + + for mac, sandbox in path_dict.items(): + if mac != "/mnt/hmdfs/100/non_account/merge_view/data": + mac_path = self.driver.Storage.has_dir("%s/%s" % (mac, bundle_name)) + sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/%s" + % (bundle_name, sandbox)) + self.driver.Assert.equal(mac_path, sandbox_path) + if mac_path is True: + mac_path_content = self.driver.shell("ls %s/%s" % (mac, bundle_name)) + sandbox_path_content = self.driver.shell( + "ls /mnt/debug/100/debug_hap/%s/data/storage/%s" % (bundle_name, sandbox)) + self.driver.Assert.equal(mac_path_content, sandbox_path_content) + else: + mac_path = self.driver.Storage.has_dir("%s" % mac) + sandbox_path = self.driver.Storage.has_dir("/mnt/debug/100/debug_hap/%s/data/storage/%s" + % (bundle_name, sandbox)) + self.driver.Assert.equal(mac_path, sandbox_path) + if mac_path is True: + mac_path_content = self.driver.shell("ls %s" % mac) + sandbox_path_content = self.driver.shell("ls /mnt/debug/100/debug_hap/%s/data/storage/%s" + % (bundle_name, sandbox)) + self.driver.Assert.equal(mac_path_content, sandbox_path_content) + + 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_debughap/sub_startup_appspawn_debughap_0900.json b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json new file mode 100644 index 00000000..ab601307 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_debughap/SubStartupAppspawnDebughap0900.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_debughap/sub_startup_appspawn_debughap_0900.py similarity index 62% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py rename to test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py index 6bc95411..67a388ef 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py @@ -1,81 +1,64 @@ -#!/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) +#!/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.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupAppspawnDebughap0900(TestCase): + + def __init__(self, controllers): + 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): + Step("安装测试hap并打开") + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_debughap") + 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) + + result = self.driver.shell("ls -Z /mnt/debug/100") + self.driver.Assert.contains(result, "u:object_r:sharefs:s0 debug_hap") + + 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.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py deleted file mode 100644 index 9d1359d3..00000000 --- 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_0500.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json deleted file mode 100644 index eff74779..00000000 --- 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_0600.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json deleted file mode 100644 index acbcf0b7..00000000 --- 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_0700.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json deleted file mode 100644 index 2fc5b2e4..00000000 --- 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_0800.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json deleted file mode 100644 index aab5e2c2..00000000 --- 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_0900.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json deleted file mode 100644 index 93b61870..00000000 --- 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 -- Gitee From 5b43937f7265f971d74fb56be7d9804a8847af2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Mon, 25 Aug 2025 14:44:03 +0800 Subject: [PATCH 16/21] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- ...startup_appspawn_filemgr_sandbox_0100.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0100.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_0200.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0200.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_0300.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0300.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_0400.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0400.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_0500.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0500.py | 64 +++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_0600.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0600.py | 59 +++++++++++++++++ ...startup_appspawn_filemgr_sandbox_0700.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0700.py | 63 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_0800.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0800.py | 63 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_0900.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_0900.py | 63 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1000.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1000.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1100.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1100.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1200.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1200.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1300.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1300.py | 59 +++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1400.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1400.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1500.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1500.py | 61 ++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1600.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1600.py | 64 +++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1700.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1700.py | 59 +++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1800.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1800.py | 64 +++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_1900.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_1900.py | 64 +++++++++++++++++++ ...startup_appspawn_filemgr_sandbox_2000.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_2000.py | 57 +++++++++++++++++ ...startup_appspawn_filemgr_sandbox_2100.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_2100.py | 57 +++++++++++++++++ ...startup_appspawn_filemgr_sandbox_2200.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_2200.py | 58 +++++++++++++++++ ...startup_appspawn_filemgr_sandbox_2300.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_2300.py | 57 +++++++++++++++++ ...startup_appspawn_filemgr_sandbox_2500.json | 14 ++++ ...b_startup_appspawn_filemgr_sandbox_2500.py | 57 +++++++++++++++++ 48 files changed, 1793 insertions(+) create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.py create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.json create mode 100644 test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.py diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.json new file mode 100644 index 00000000..2b59544a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0100.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..0a019433 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0100.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0100(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 + 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): + file_mgr + 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) + pid = self.driver.System.get_pid(file_mgr) + result = self.driver.shell("ls /proc/%d/root/storage" % pid).split() + content = ["External", "Users", "hmdfs"] + for i in content: + self.driver.Assert.contains(result, i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.json new file mode 100644 index 00000000..494b8688 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0200.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..daf89fbc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0200.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0200(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 + 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): + file_mgr + 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) + pid = self.driver.System.get_pid(file_mgr) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser" % pid).split() + content = ["Desktop", "Documents", "Download", "appdata"] + for i in content: + self.driver.Assert.contains(result, i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.json new file mode 100644 index 00000000..d3d2775c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0300.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..a1b1e96b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0300.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0300(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 + 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): + file_mgr + 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) + pid = self.driver.System.get_pid(file_mgr) + result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata" % pid) + content = ["el1", "el2"] + for i in content: + self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.json new file mode 100644 index 00000000..39d21ea1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0400.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..26a39493 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0400.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0400(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 + 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): + file_mgr + 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) + pid = self.driver.System.get_pid(file_mgr) + result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata/el2" % pid) + content = ["base", "distributedfiles", "cloud"] + for i in content: + self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.json new file mode 100644 index 00000000..603a7825 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0500.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..3c1c873b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0500.py @@ -0,0 +1,64 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0500(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 + 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): + file_mgr + count = 0 + 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) + pid = self.driver.System.get_pid(file_mgr) + for i in range(1, 3): + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el%d/base" % (pid, i)).split() + for bundle_name in result: + if "com." in bundle_name or "com.ohos" in bundle_name: + count += 1 + self.driver.Assert.greater(count, 0) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.json new file mode 100644 index 00000000..4e801c20 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0600.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..e4914937 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0600.py @@ -0,0 +1,59 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0600(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 + 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): + file_mgr + 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) + pid = self.driver.System.get_pid(file_mgr) + result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata/el1" % pid) + self.driver.Assert.contains(result, "u:object_r:sharefs:s0 base") + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.json new file mode 100644 index 00000000..8f16be1a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0700.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..64725e22 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0700.py @@ -0,0 +1,63 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0700(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 + 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): + file_mgr + count = 0 + 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) + pid = self.driver.System.get_pid(file_mgr) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el2/distributedfiles" % pid,).split() + for bundle_name in result: + if "com." in bundle_name or "com.ohos" in bundle_name: + count += 1 + self.driver.Assert.greater(count, 0) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.json new file mode 100644 index 00000000..80bd2cf2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0800.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..4ddfadbd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0800.py @@ -0,0 +1,63 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0800(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 + 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): + file_mgr + count = 0 + 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) + pid = self.driver.System.get_pid(file_mgr) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el2/cloud" % pid,).split() + for bundle_name in result: + if "com." in bundle_name or "com.ohos" in bundle_name: + count += 1 + self.driver.Assert.greater(count, 0) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.json new file mode 100644 index 00000000..0c444897 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox0900.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..e0d16560 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_0900.py @@ -0,0 +1,63 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox0900(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 + 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): + file_mgr + count = 0 + 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) + pid = self.driver.System.get_pid(file_mgr) + result = self.driver.shell("ls -Z /proc/%d/root/storage" % pid,).split() + for i in result: + if "sharefs" in i: + count += 1 + self.driver.Assert.equal(count, 0) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(file_mgr) + self.driver.AppManager.stop_app(file_mgr) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.json new file mode 100644 index 00000000..56838555 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1000.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..a9890f38 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1000.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1000(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 + 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): + notepad + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage" % pid) + content = ["External", "Users", "hmdfs"] + for i in content: + self.driver.Assert.contains(result, i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.json new file mode 100644 index 00000000..071a6565 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1100.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..0a81042e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1100.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1100(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 + 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): + notepad + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser" % pid) + content = ["Desktop", "Documents", "Download", "appdata"] + for i in content: + self.driver.Assert.contains(result, i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.json new file mode 100644 index 00000000..1cdcdb7d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1200.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..2ef1db99 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1200.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1200(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 + 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): + notepad + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls -Z /proc/%d/root/storage" % pid) + content = ["External", "hmdfs", "Users"] + for i in content: + self.driver.Assert.contains(result, "u:object_r:sharefs:s0 %s" % i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.json new file mode 100644 index 00000000..6a974dd2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1300.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..6231fe7e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1300.py @@ -0,0 +1,59 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1300(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 + 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): + notepad + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls -Z /proc/%d/root/storage/Users" % pid).rsplit("\n") + self.driver.Assert.equal(result[0], "u:object_r:sharefs:s0 currentUser") + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.json new file mode 100644 index 00000000..6be9d12e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1400.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..7803be0c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1400.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1400(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 + 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): + notepad + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata" % pid).split() + content = ["el1", "el2"] + for i in content: + self.driver.Assert.contains(result, i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.json new file mode 100644 index 00000000..3b303104 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1500.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..2a6326a1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1500.py @@ -0,0 +1,61 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1500(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 + 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): + notepad + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata/el2" % pid) + content = ["base", "distributedfiles", "cloud"] + for i in content: + self.driver.Assert.contains(result, "sharefs_appdata_file:s0 %s" % i) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.json new file mode 100644 index 00000000..cc7e90ae --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1600.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..cde3680a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1600.py @@ -0,0 +1,64 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1600(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 + 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): + notepad + count = 0 + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + for i in range(1, 3): + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el%d/base" % (pid, i)).split() + for bundle_name in result: + if "com." in bundle_name or "com.ohos" in bundle_name: + count += 1 + self.driver.Assert.greater(count, 0) + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.json new file mode 100644 index 00000000..987cdcae --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1700.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..e9d03195 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1700.py @@ -0,0 +1,59 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1700(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 + 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): + notepad + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls -Z /proc/%d/root/storage/Users/currentUser/appdata/el1" % pid).split("\n") + self.driver.Assert.equal(result[0], "u:object_r:sharefs_appdata_file:s0 base") + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.json new file mode 100644 index 00000000..93278ccf --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1800.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..53eeb475 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1800.py @@ -0,0 +1,64 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1800(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 + 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): + notepad + count = 0 + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el2/distributedfiles" % pid).split() + for bundle_name in result: + if "com." in bundle_name or "com.ohos" in bundle_name: + count += 1 + self.driver.Assert.greater(count, 0) + + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.json new file mode 100644 index 00000000..c6034bb5 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox1900.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..cec6adb6 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_1900.py @@ -0,0 +1,64 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox1900(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 + 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): + notepad + count = 0 + notepad = "com.notepad" + self.driver.shell("echo 0 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el2/cloud" % pid).split() + for bundle_name in result: + if "com." in bundle_name or "com.ohos" in bundle_name: + count += 1 + self.driver.Assert.greater(count, 0) + + + def teardown(self): + Step("收尾工作.................") + self.driver.shell("echo 1 > /proc/sys/kernel/dec/dec_mode") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.json new file mode 100644 index 00000000..b2533830 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2000.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..e954c06d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2000.py @@ -0,0 +1,57 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox2000(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 + 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): + notepad + notepad = "com.notepad" + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser" % pid) + self.driver.Assert.contains(result, "Operation not permitted") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.json new file mode 100644 index 00000000..d4d8580c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2100.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..d977d931 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2100.py @@ -0,0 +1,57 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox2100(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 + 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): + notepad + notepad = "com.notepad" + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata" % pid) + self.driver.Assert.contains(result, "Operation not permitted") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.json new file mode 100644 index 00000000..d204b6d2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2200.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..2fbd8db1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2200.py @@ -0,0 +1,58 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox2200(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 + 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): + notepad + notepad = "com.notepad" + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + for i in range(1, 3): + result = self.driver.shell("ls /proc/%d/root/storage/Users/currentUser/appdata/el%d" % (pid, i)) + self.driver.Assert.contains(result, "Operation not permitted") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.json new file mode 100644 index 00000000..c1f9ef72 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2300.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..4062169b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2300.py @@ -0,0 +1,57 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox2300(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 + 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): + notepad + notepad = "com.notepad" + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage/External" % pid) + self.driver.Assert.contains(result, "Operation not permitted") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.json b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.json new file mode 100644 index 00000000..b89444cb --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_filemgr_sandbox/SubStartupAppspawnFilemgrSandbox2500.py" + ] + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..61a324b6 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_filemgr_sandbox/sub_startup_appspawn_filemgr_sandbox_2500.py @@ -0,0 +1,57 @@ +#!/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 FilemgrSandbox, Appspawn, SubStartup + + +class SubStartupAppspawnFilemgrSandbox2500(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 + 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): + notepad + notepad = "com.notepad" + self.driver.AppManager.start_app(notepad) + time.sleep(3) + pid = self.driver.System.get_pid(notepad) + result = self.driver.shell("ls /proc/%d/root/storage/hmdfs" % pid) + self.driver.Assert.contains(result, "Operation not permitted") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.clear_app_data(notepad) + self.driver.AppManager.stop_app(notepad) \ No newline at end of file -- Gitee From ec269616f00788b4f43866adf5ea489adb197314 Mon Sep 17 00:00:00 2001 From: chennuo Date: Wed, 20 Aug 2025 11:52:06 +0800 Subject: [PATCH 17/21] fix bugs:kernel permission Signed-off-by: chennuo --- modules/common/appspawn_encaps.c | 25 ++++++++++++------- .../app_spawn_common_test.cpp | 23 +++++++++++------ 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/modules/common/appspawn_encaps.c b/modules/common/appspawn_encaps.c index 1d417e1d..ae531516 100644 --- a/modules/common/appspawn_encaps.c +++ b/modules/common/appspawn_encaps.c @@ -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; } 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 266cb7be..9292f24a 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); @@ -822,7 +823,8 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_005, TestSize.Level0) 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); @@ -842,8 +844,9 @@ HWTEST_F(AppSpawnCommonTest, App_Spawn_Encaps_006, TestSize.Level0) 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); @@ -989,7 +992,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 +1010,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); @@ -1248,7 +1253,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 +1290,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); -- Gitee From 5719d7a94beddab5e62863cf0cbb658d68ace61f Mon Sep 17 00:00:00 2001 From: fan-jingle Date: Mon, 25 Aug 2025 13:54:46 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=99=9A=E5=81=87?= =?UTF-8?q?=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fan-jingle --- .../app_spawn_client_test.cpp | 37 +++---------------- .../app_spawn_cgroup_test.cpp | 7 +--- .../app_spawn_child_test.cpp | 8 ---- .../app_spawn_sandbox_new_test.cpp | 29 +-------------- .../app_spawn_sandbox_test.cpp | 4 +- .../app_spawn_service_test.cpp | 3 -- .../nweb_spawn_service_test.cpp | 2 - 7 files changed, 11 insertions(+), 79 deletions(-) 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 d99749cb..8c1c0a8f 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); 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 5f7d4e94..b89fc162 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 4552f66e..3c863d40 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_sandbox_new_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_test.cpp index 92bc3010..2fc9eecd 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 d929e46f..0434a39c 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 @@ -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); } 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 a8f86701..47ce99fe 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); } 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 ccc8bcfd..7ef20cf1 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); -- Gitee From 7774c0523eef395134ee4b8feb11a744e9772324 Mon Sep 17 00:00:00 2001 From: hua-mengzheng Date: Tue, 26 Aug 2025 11:25:01 +0800 Subject: [PATCH 19/21] appspawn runchildthread update Signed-off-by: hua-mengzheng --- modules/ace_adapter/ace_adapter.cpp | 5 +++++ modules/nweb_adapter/nwebspawn_adapter.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/ace_adapter/ace_adapter.cpp b/modules/ace_adapter/ace_adapter.cpp index 6f448c55..e4e95d24 100644 --- a/modules/ace_adapter/ace_adapter.cpp +++ b/modules/ace_adapter/ace_adapter.cpp @@ -240,6 +240,11 @@ APPSPAWN_STATIC int RunChildThread(const AppSpawnMgr *content, const AppSpawning 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; diff --git a/modules/nweb_adapter/nwebspawn_adapter.cpp b/modules/nweb_adapter/nwebspawn_adapter.cpp index f2238082..e520dd3e 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) ? -- Gitee From 71daf9ef3f6ae3f564f9651b0fd0ba12c6723e47 Mon Sep 17 00:00:00 2001 From: fan-jingle Date: Mon, 25 Aug 2025 16:38:09 +0800 Subject: [PATCH 20/21] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=99=9A?= =?UTF-8?q?=E5=81=87=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fan-jingle --- .../app_spawn_cold_run_test.cpp | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) 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 ebc0e292..879123e8 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; -- Gitee From d184fad36f41210310b457a2195e77685ca02639 Mon Sep 17 00:00:00 2001 From: nianyuu Date: Tue, 26 Aug 2025 21:30:38 +0800 Subject: [PATCH 21/21] fix appspawn diff Signed-off-by: nianyuu --- appspawn.cfg | 6 +- interfaces/innerkits/client/appspawn_msg.c | 9 +- modules/common/appspawn_begetctl.c | 2 +- modules/common/appspawn_cgroup.c | 2 +- modules/sandbox/modern/sandbox_debug_mode.c | 4 +- modules/sandbox/normal/sandbox_common.cpp | 5 +- modules/sandbox/normal/sandbox_core.cpp | 2 +- standard/appspawn_service.c | 7 +- test/BUILD.gn | 1 + ...sub_startup_appspawn_atomservice_0100.json | 14 --- .../sub_startup_appspawn_atomservice_0100.py | 104 ------------------ ...sub_startup_appspawn_atomservice_0300.json | 14 --- .../sub_startup_appspawn_atomservice_0300.py | 66 ----------- test/unittest/app_spawn_client_test/BUILD.gn | 1 - .../unittest/app_spawn_standard_test/BUILD.gn | 102 ++++++++++++++++- .../app_spawn_appmgr_test.cpp | 8 -- .../app_spawn_common_test.cpp | 3 +- .../app_spawn_kickdog_test.cpp | 2 +- .../app_spawn_sandbox_new_debug_mode.cpp | 4 +- util/include/appspawn_error.h | 6 +- 20 files changed, 128 insertions(+), 234 deletions(-) delete mode 100644 test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.json delete mode 100644 test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0100.py delete mode 100644 test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.json delete mode 100644 test/autotest/sub_startup_appspawn_atomservice/sub_startup_appspawn_atomservice_0300.py diff --git a/appspawn.cfg b/appspawn.cfg index 989ab65f..9759e7e8 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/interfaces/innerkits/client/appspawn_msg.c b/interfaces/innerkits/client/appspawn_msg.c index ab871cb7..3b7332af 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/modules/common/appspawn_begetctl.c b/modules/common/appspawn_begetctl.c index c813e839..3696bb8f 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 eaf73279..4f6043a6 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/sandbox/modern/sandbox_debug_mode.c b/modules/sandbox/modern/sandbox_debug_mode.c index 7953b34a..54b9b945 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 df0cedf3..0503c71a 100644 --- a/modules/sandbox/normal/sandbox_common.cpp +++ b/modules/sandbox/normal/sandbox_common.cpp @@ -905,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 076abf38..ea47460d 100644 --- a/modules/sandbox/normal/sandbox_core.cpp +++ b/modules/sandbox/normal/sandbox_core.cpp @@ -1032,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/standard/appspawn_service.c b/standard/appspawn_service.c index 274fe9a5..51eeec66 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -446,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); @@ -1611,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); @@ -1626,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; } diff --git a/test/BUILD.gn b/test/BUILD.gn index 7e399ae1..22e12e97 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 a69713ef..00000000 --- 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 8ed54e46..00000000 --- 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 c5a1372f..00000000 --- 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 9001688a..00000000 --- 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/unittest/app_spawn_client_test/BUILD.gn b/test/unittest/app_spawn_client_test/BUILD.gn index 3b3932f6..dd62ab13 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_standard_test/BUILD.gn b/test/unittest/app_spawn_standard_test/BUILD.gn index 5bfa7924..024c3d97 100644 --- a/test/unittest/app_spawn_standard_test/BUILD.gn +++ b/test/unittest/app_spawn_standard_test/BUILD.gn @@ -137,6 +137,7 @@ 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 { @@ -217,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" ] @@ -311,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 fa672280..f648c1d1 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_common_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_common_test.cpp index 5fb39ebf..6f028823 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 @@ -1483,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); @@ -1495,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 7b7760b3..5706afbf 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_new_debug_mode.cpp b/test/unittest/app_spawn_standard_test/app_spawn_sandbox_new_debug_mode.cpp index 05f94524..396d0855 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 @@ -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) diff --git a/util/include/appspawn_error.h b/util/include/appspawn_error.h index ba0c7350..f3258678 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 -- Gitee