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 b764571dcfdf67a148bfd6310512fdd2b5b0dcb8..2e315adde130987bd470216829bf931c727ee57a 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 0000000000000000000000000000000000000000..0e24a7f905b20dbc591d2b82799b00361542d395 --- /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 e560671a212be51ebb45ee3a392cd21c95592c14..26a1000ecacb2f7dc1c1cdbcda65daa65dd1dbe5 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 0000000000000000000000000000000000000000..e11d33c49e518c8e42a739b44d687b92de28a1a3 --- /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 cb9198c746feec4cd142a58be74f8ba2bdeedb30..1be0bf2fa2be71c356219c5668f33cce3d55fdc3 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 0000000000000000000000000000000000000000..da0bcc97aa69c43dfb72ae4301296857b8d2f185 --- /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 0000000000000000000000000000000000000000..49136690fb7b9fd496bab70f81d2d66077299f3d --- /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 0000000000000000000000000000000000000000..d0c65b3f29b5b4b93ffb45c2a4d6f2a1e0055a37 --- /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 0000000000000000000000000000000000000000..0a585dccd763b8ed38a5073799ea6c77cb1f4f78 --- /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 8446d1c52685bd120bc2596851f942b32b501634..da2d64dc612b264024e1871ee9f8f334f72bfb33 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 0000000000000000000000000000000000000000..0e9342a455be203f459382fe9a2c45d30f39713d --- /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 f37c3217c7d7ef96188f1551ac69aad733412102..04fc5b10004313f5d215c207190ba485de7ec67d 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 9b0248bf81ca8671446934d04157d36d1123905c..1fd513bc99342b81b1fef726a5f2b7ef749d2243 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 f958bb793252b58faea0bc494a0bba34ece81557..a429b69f6c80ba5ead369569789bae0489dcb1b9 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 0000000000000000000000000000000000000000..66713d048e5f32dda102475701ce3eab1fb92c8c --- /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 f7d2d29460882204f25ee4bea3b6b5317b519a63..dec704a03f93ba6bec8b87bfe058838d599ac8c7 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 0000000000000000000000000000000000000000..4918b0b9a12739b6edf82828ad3bfce4cf06b820 --- /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 0000000000000000000000000000000000000000..fb7609b23dae061f1a2b6fa17830ad2d94a02e16 --- /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 0000000000000000000000000000000000000000..a8e1e788d82d2c7dc101455bd9e73331af48bb9c --- /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 a16ae9e2d2b38f2fc6e6e2731477e6f06f5e0d70..e410e953548cfcadd30fc9c38002e2449242febc 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 0000000000000000000000000000000000000000..7a19d9b426519d9fad44c31389168998c6fe6a23 --- /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 3c84650580d678b803ef6286c38e7df20b822dbb..446185f8061bfb0d5a8c976ffc8f9f79153c0282 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 0000000000000000000000000000000000000000..5538e209a217f335453b2f050bc35dab6a22cc2c --- /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 0000000000000000000000000000000000000000..e19ac7fd2320ba21a14668c4d854538e43448a81 --- /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 0000000000000000000000000000000000000000..d17ff07fde09a75eb1d3364aea7bb8efba3c3155 --- /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 023bb1226f6137f20697152418fa5878012f49eb..7974ad11f57c1e351ae9c3a1a7fabe027c4b4224 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 0000000000000000000000000000000000000000..ab601307be4559b5a2a8cdd30490e869e8a8c997 --- /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 6bc9541124f4f7cf506b004f2f1d7bba962225b2..67a388ef2fd4d98a646a1bf0c3f7a0392e2e086b 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 9d1359d36e917873e22f5418664943a6e96fa6a6..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - -SubStartupAppspawnDevicedebug0300(TestCase): - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - signal_lst = [1, 9, 11, 15, 64] - log_dict = {} - # 本地跑1-64的 但是由于太费时间,流水线跑signal_lst中这几个有代表性的就可以了 - for signal in signal_lst: # range(1, 65)替换signal_lst - self.driver.AppManager.start_app(bundle_name) - pid = self.driver.System.get_pid(bundle_name) - log_dict.update({signal: pid}) - self.driver.shell("devicedebug kill -%d %d" % (signal, pid)) - self.driver.AppManager.stop_app(bundle_name) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - for signal, pid in log_dict.items(): - assert device_logger.check_log("devicedebug cmd kill start signal[%d], pid[%d]" % (signal, pid)) - assert device_logger.check_log("appspawn devicedebug debugable=1, pid=%d, signal=%d" % (pid, signal)) - assert device_logger.check_log("devicedebug manager process exit. ret=0") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json deleted file mode 100644 index eff74779ddd26d5b3738cda0f92f17e1a78604a0..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json deleted file mode 100644 index acbcf0b7151d7bd1cd165e01da4ab8acc0aaa758..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json deleted file mode 100644 index 2fc5b2e47ef7f2ff348429474728a878898f19c9..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json deleted file mode 100644 index aab5e2c2805dc36b8ef13a69af0a88a14bf61895..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json deleted file mode 100644 index 93b618704548e09bebfa9de86151bd64cd1cc8d2..0000000000000000000000000000000000000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py" - ] - } -} \ No newline at end of file