From ef7f1f27a212e9e563c487710619af09aba08545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Fri, 18 Apr 2025 11:48:01 +0800 Subject: [PATCH] fix: add devicedebug autotest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- .../sub_startup_appspawn_cgroups_0100.json | 14 ++++ .../sub_startup_appspawn_cgroups_0100.py | 75 ++++++++++++++++++ .../sub_startup_appspawn_cgroups_0200.json | 14 ++++ .../sub_startup_appspawn_cgroups_0200.py | 74 ++++++++++++++++++ .../sub_startup_appspawn_cgroups_0300.json | 14 ++++ .../sub_startup_appspawn_cgroups_0300.py | 73 ++++++++++++++++++ .../sub_startup_appspawn_coldstart_0100.json | 15 ++++ .../sub_startup_appspawn_coldstart_0100.py | 59 ++++++++++++++ ...startup_appspawn_coldstartablity_0100.json | 15 ++++ ...b_startup_appspawn_coldstartablity_0100.py | 61 +++++++++++++++ ...startup_appspawn_coldstartablity_0200.json | 15 ++++ ...b_startup_appspawn_coldstartablity_0200.py | 61 +++++++++++++++ ...tartup_appspawn_selinuxlabelconf_1000.json | 14 ++++ ..._startup_appspawn_selinuxlabelconf_1000.py | 55 ++++++++++++++ ...tartup_appspawn_selinuxlabelconf_1100.json | 14 ++++ ..._startup_appspawn_selinuxlabelconf_1100.py | 53 +++++++++++++ ...b_startup_appspawn_supplementary_0100.json | 14 ++++ ...sub_startup_appspawn_supplementary_0100.py | 59 ++++++++++++++ ...b_startup_appspawn_supplementary_0200.json | 14 ++++ ...sub_startup_appspawn_supplementary_0200.py | 62 +++++++++++++++ ...b_startup_appspawn_ubsanvariable_0100.json | 13 ++++ ...sub_startup_appspawn_ubsanvariable_0100.py | 76 +++++++++++++++++++ ...b_startup_appspawn_ubsanvariable_0200.json | 13 ++++ ...sub_startup_appspawn_ubsanvariable_0200.py | 75 ++++++++++++++++++ ...b_startup_appspawn_ubsanvariable_0300.json | 13 ++++ ...sub_startup_appspawn_ubsanvariable_0300.py | 75 ++++++++++++++++++ 26 files changed, 1040 insertions(+) create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py create mode 100644 test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json create mode 100644 test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py create mode 100644 test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.json create mode 100644 test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py create mode 100644 test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.json create mode 100644 test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.py create mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json create mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py create mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json create mode 100644 test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json create mode 100644 test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json new file mode 100644 index 00000000..2e315add --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_cgroups/Substartupappspawncgroups0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py new file mode 100644 index 00000000..0e24a7f9 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import time +from devicetest.core.test_case import TestCase, Step +from hypium importFunction1, SpecificFunction2 + +from aw import Common + +class Substartupappspawncgroups0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.shell("power-shell setmode 602") + + def process(self): + hap_path = Common.sourcepath('ForkTest1.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name + bundle_name = "com.example.exe_sys_cmd" + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef | grep %s" % bundle_name) + cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" %(bundle_name, pid)).split() + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 2: + count += 1 + self.driver.Assert.equal(count, 1) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json new file mode 100644 index 00000000..26a1000e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_cgroups/Substartupappspawncgroups0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py new file mode 100644 index 00000000..f3f2fc53 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py @@ -0,0 +1,74 @@ +#!/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) + 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) == 3: + count += 1 + self.driver.Assert.equal(count, 1) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.uninstall_app("com.example.exe_sys_cmd") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json new file mode 100644 index 00000000..1be0bf2f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_cgroups/Substartupappspawncgroups0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py new file mode 100644 index 00000000..09919c70 --- /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 * + +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) + 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, 2) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.uninstall_app("com.example.exe_sys_cmd") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json new file mode 100644 index 00000000..49136690 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_coldstart/Substartupappspawncoldstart0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py new file mode 100644 index 00000000..036499cc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import HypiumFunction1, HypiumFunction + + +class Substartupappspawncoldstart0100(TestCase): + + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("设置冷启动全局参数.................") + result = self.driver.shell('param set startup.appspawn.cold.boot 1') + sleep(3) + if "Set parameter startup.appspawn.cold.boot 1 success" in result: + pass + else: + raise ValueError('设置冷启动全局参数失败!') + Step("通过命令启动日历.................") + result = self.driver.shell("aa start -C -d 123456 -a MainAbility -b com.hmos.calendar") + sleep(3) + self.driver.Assert.contains(result, "start ability successfully.", "通过命令启动日历失败!") + Step("检查日历冷启动进程.................") + result_ps = self.driver.shell("ps -ef|grep com.hmos.calendar") + result_ps = result_ps.split('\n')[0] + Step("日历进程信息如下:" + str(result_ps)) + if '"' in result_ps: + throw std::logic_error("日进程信息中包含非法字符 \"") + + def teardown(self): + Step("收尾工作.................") + pid = self.driver.System.get_pid('com.hmos.calendar') + self.driver.shell("kill -9 " + str(pid)) + diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json new file mode 100644 index 00000000..0a585dcc --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_coldstartablity/Substartupappspawncoldstartablity0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py new file mode 100644 index 00000000..5c67f277 --- /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 hypium import * + +from aw import Common + + +class Substartupappspawncoldstartablity0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("asan-enable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + pid = self.driver.System.get_pid('com.example.myapplication') + Step(pid) + Step("校验hap应用的maps.................") + result = self.driver.shell('cat ' + os.path.join('/proc', str(pid), 'maps') + '|grep libclang.asan.so') + Step(result) + self.driver.Assert.contains(result, '/system/lib64/libclang_rt.asan.so') + self.driver.Assert.contains(result, 'anon:libclang_rt.asan.so.bss') + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json new file mode 100644 index 00000000..0e9342a4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_coldstartablity/Substartupappspawncoldstartablity0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py new file mode 100644 index 00000000..dfbbe71d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import * + +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.................") + result = self.driver.shell('cat /proc/' + str(pid) + '/maps|grep libclang_rt.asan.so') + 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 00000000..9db864fd --- /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 00000000..777fa04b --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py @@ -0,0 +1,55 @@ +#!/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 * +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 00000000..bae02bd1 --- /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 00000000..4f71fe61 --- /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.huawei.hmos.settings", "com.huawei.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.huawei.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 00000000..9a4957d4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_supplementary/Substartupappspawnsupplementary0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0100.py new file mode 100644 index 00000000..4fa33bfb --- /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 hypium import * + +from aw import Common + + +class Substartupappspawnsupplementary0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("asan.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + Step("校验hap显示Hello World.................") + if not self.driver.find_component(BY.text("Hello World")): + throw std::runtime_error("Failed to find component with text 'Hello'") + + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json new file mode 100644 index 00000000..d17ba198 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_supplementary/Substartupappspawnsupplementary0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py new file mode 100644 index 00000000..4b5ec061 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_supplementary/sub_startup_appspawn_supplementary_0200.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium importFunction1, SpecificFunction2 + +from aw import Common + + +class Substartupappspawnsupplementary0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("sn.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + Step("检查存在device info.................") + assert self.driver.find_component(BY.text("3333333", MatchPattern.CONTAINS)) + print("点击菜单device info.................") + self.driver.touch(BY.text(" device info ")) + sleep(1) + Step("校验serial为空.................") + if not self.driver.find_component(BY.text("serial: " + "\n" + " deviceType", MatchPattern.CONTAINS)) + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json new file mode 100644 index 00000000..53f12fe9 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py new file mode 100644 index 00000000..69e4db98 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0100.py @@ -0,0 +1,76 @@ +#!/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 * +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + +class Substartupappspawnubsanvariable0100(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D -D 0xC02C11") + self.driver.shell("hilog -b DEBUG -T APPSPAWN") + self.driver.shell("hilog -b D -D 0xDC02C11") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledTrueProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if(ishap): + self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledtrueprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + device_logger.check_log('SetAsanEnabledEnv 22,(null),(null),(null)') + device_logger.check_log('print_stacktrace=1:print_module_map=2:log_exe_name=1,(null)') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json new file mode 100644 index 00000000..29b796cf --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0200.py new file mode 100644 index 00000000..66b61951 --- /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 hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class Substartupappspawnubsanvariable0200(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledFalseProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if (ishap): + self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledfalseprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json new file mode 100644 index 00000000..e72103b0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_appspawn_ubsanvariable/Substartupappspawnubsanvariable0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py b/test/autotest/sub_startup_appspawn_ubsanvariable/sub_startup_appspawn_ubsanvariable_0300.py new file mode 100644 index 00000000..f4843585 --- /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 * +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class Substartupappspawnubsanvariable0300(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartNoConfigEnabledProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if (ishap): + self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartnoconfigenabledprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") + self.driver.shell("hilog -b I") -- Gitee