From a06b12269323f2d182e557f46ea0c8e4071096c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Mon, 11 Aug 2025 16:28:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=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 | 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 ++++++++++++++ 30 files changed, 1280 insertions(+) create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json 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 create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py 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 create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py 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 create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.json create mode 100644 test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py create mode 100644 test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json create mode 100644 test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.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 new file mode 100644 index 00000000..2e315add --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json @@ -0,0 +1,14 @@ +{ + "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_cgroups/sub_startup_appspawn_cgroups_0200.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json new file mode 100644 index 00000000..26a1000e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json @@ -0,0 +1,14 @@ +{ + "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_cgroups/sub_startup_appspawn_cgroups_0300.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json new file mode 100644 index 00000000..1be0bf2f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json @@ -0,0 +1,14 @@ +{ + "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..036499cc --- /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.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 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_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py new file mode 100644 index 00000000..da2d64dc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_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. + +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_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py new file mode 100644 index 00000000..04fc5b10 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py @@ -0,0 +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. + +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 new file mode 100644 index 00000000..1fd513bc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.json @@ -0,0 +1,14 @@ +{ + "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 new file mode 100644 index 00000000..a429b69f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0100.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 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_debughap/sub_startup_appspawn_debughap_0200.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.py new file mode 100644 index 00000000..dec704a0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0200.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 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_debughap/sub_startup_appspawn_debughap_0500.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0500.py new file mode 100644 index 00000000..e410e953 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_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 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_debughap/sub_startup_appspawn_debughap_0600.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.py new file mode 100644 index 00000000..446185f8 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0600.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 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_debughap/sub_startup_appspawn_debughap_0800.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py new file mode 100644 index 00000000..7974ad11 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0800.py @@ -0,0 +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.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_debughap/sub_startup_appspawn_debughap_0900.py b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.py new file mode 100644 index 00000000..67a388ef --- /dev/null +++ b/test/autotest/sub_startup_appspawn_debughap/sub_startup_appspawn_debughap_0900.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 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 new file mode 100644 index 00000000..d2ef15d1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.json @@ -0,0 +1,14 @@ +{ + "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 new file mode 100644 index 00000000..d65e7ce4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_fd/sub_startup_appspawn_fd_0100.py @@ -0,0 +1,83 @@ +#!/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() -- Gitee