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 0000000000000000000000000000000000000000..2e315adde130987bd470216829bf931c727ee57a --- /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 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_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 0000000000000000000000000000000000000000..26a1000ecacb2f7dc1c1cdbcda65daa65dd1dbe5 --- /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 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_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 0000000000000000000000000000000000000000..1be0bf2fa2be71c356219c5668f33cce3d55fdc3 --- /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 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..036499cc18d94b43144c40e28986629a1c297306 --- /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 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_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 0000000000000000000000000000000000000000..da2d64dc612b264024e1871ee9f8f334f72bfb33 --- /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 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_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 0000000000000000000000000000000000000000..04fc5b10004313f5d215c207190ba485de7ec67d --- /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_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.json b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.json new file mode 100644 index 0000000000000000000000000000000000000000..9db864fdbe3e097b9e9636604a52f1be611f84fd --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_selinuxlabelconf/Substartupappspawnselinuxlabelconf1000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py new file mode 100644 index 0000000000000000000000000000000000000000..e1cee13f910b530aea8b9a3e4eba43d7b365e4ba --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py @@ -0,0 +1,56 @@ +#!/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 hyp import HypiumClass1, HypiumClass2, HypiumFunction1 +from devicetest.core.test_case import Step, TestCase +from aw import Common + + +class Substartupappspawnselinuxlabelconf1000(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("selinux.hap", "SUB_STARTUP_APPSPAWN_SELINUXLABELCONF") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + sleep(3) + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + result_el1 = self.driver.shell('ls -lZ /data/app/el1/100/base/ | grep com.example.myapplication') + Step(result_el1) + result_el2 = self.driver.shell('ls -lZ /data/app/el2/100/base/ | grep com.example.myapplication') + Step(result_el2) + self.driver.Assert.contains(result_el1, "hap_data_file", "安装非预置应用,对应标签为normal_hap") + self.driver.Assert.contains(result_el2, "hap_data_file", "安装非预置应用,对应标签为normal_hap") + + def teardown(self): + Step("TestCase: teardown") + 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_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.json b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.json new file mode 100644 index 0000000000000000000000000000000000000000..bae02bd14f9756b724890fab53d519a0ad32115a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_selinuxlabelconf/Substartupappspawnselinuxlabelconf1100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.py b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.py new file mode 100644 index 0000000000000000000000000000000000000000..9dba92bb39e97ce9da4fc73cb233ba339dcf1702 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.py @@ -0,0 +1,53 @@ +#!/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 hypium import UiParam +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam + + +class Substartupappspawnselinuxlabelconf1100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.enable_stay_awake() + self.driver.ScreenLock.unlock() + sleep(3) + + def test_step1(self): + Step("拉起设置........................................") + self.driver.start_app("com.hmos.settings", "com.hmos.settings.MainAbility") + result_el1 = self.driver.shell('ls -lZ /data/app/el1/100/base/ | grep permissionmanager') + Step(result_el1) + result_el2 = self.driver.shell('ls -lZ /data/app/el2/100/base/ | grep permissionmanager') + Step(result_el2) + self.driver.Assert.contains(result_el1, "permissionmanager_hap_data_file", "预置应用,对应标签为自定义的标签") + self.driver.Assert.contains(result_el2, "permissionmanager_hap_data_file", "预置应用,对应标签为自定义的标签") + + def teardown(self): + Step("TestCase: teardown") + self.driver.stop_app("com.hmos.settings") diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json new file mode 100644 index 0000000000000000000000000000000000000000..9a4957d4a6e74c792901be396e7973333bb98790 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_supplementary/Substartupappspawnsupplementary0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py new file mode 100644 index 0000000000000000000000000000000000000000..fc2cad965f74fe109124db7b6dd4e8138db3b153 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hyp import HypiumClass1, HypiumClass2, HypiumFunction1 + +from aw import Common + + +class Substartupappspawnsupplementary0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("asan.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + Step("校验hap显示Hello World.................") + if not self.driver.find_component(BY.text("Hello World")): + throw std::runtime_error("Failed to find component with text 'Hello'") + + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json new file mode 100644 index 0000000000000000000000000000000000000000..d17ba198713dcaa0d91c9dd2f4afeee58422919e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_supplementary/Substartupappspawnsupplementary0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py new file mode 100644 index 0000000000000000000000000000000000000000..4b5ec0613a756b77afd269042f8aec687d360c6c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium importFunction1, SpecificFunction2 + +from aw import Common + + +class Substartupappspawnsupplementary0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("sn.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + Step("检查存在device info.................") + assert self.driver.find_component(BY.text("3333333", MatchPattern.CONTAINS)) + print("点击菜单device info.................") + self.driver.touch(BY.text(" device info ")) + sleep(1) + Step("校验serial为空.................") + if not self.driver.find_component(BY.text("serial: " + "\n" + " deviceType", MatchPattern.CONTAINS)) + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json new file mode 100644 index 0000000000000000000000000000000000000000..53f12fe94418163592797dcdbc2d51b88dc77f02 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py new file mode 100644 index 0000000000000000000000000000000000000000..f8876929df40cb1e4e3c969b8ec45737a77d7bf5 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import HypiumClass, HypiumFunction +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class Substartupappspawnubsanvariable0100(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D -D 0xC02C11") + self.driver.shell("hilog -b DEBUG -T APPSPAWN") + self.driver.shell("hilog -b D -D 0xDC02C11") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledTrueProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if(ishap): + self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledtrueprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + device_logger.check_log('SetAsanEnabledEnv 22,(null),(null),(null)') + device_logger.check_log('print_stacktrace=1:print_module_map=2:log_exe_name=1,(null)') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json new file mode 100644 index 0000000000000000000000000000000000000000..29b796cf39bdad74194c8a62ca82db82411d55b1 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py new file mode 100644 index 0000000000000000000000000000000000000000..83070fb5acd95cb3476c4b9073057b939c632a40 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hyp import HypiumClass1, HypiumClass2, HypiumFunction1 +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class Substartupappspawnubsanvariable0200(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledFalseProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if (ishap): + self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledfalseprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json new file mode 100644 index 0000000000000000000000000000000000000000..e72103b0edfcb17227de9df9befb878cdd6e5fe6 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py new file mode 100644 index 0000000000000000000000000000000000000000..591f529ca455040ff431f5805e287438e131067a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import HypiumClass, HypiumFunction +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class Substartupappspawnubsanvariable0300(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartNoConfigEnabledProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if (ishap): + self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartnoconfigenabledprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") + self.driver.shell("hilog -b I")