From 4ee3b7c2f7e277d28541c3ba5e967054d38fe015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BD=B3=E4=BC=9F?= Date: Mon, 25 Aug 2025 14:54:59 +0800 Subject: [PATCH] Description:add autotest testcases IssueNo:https://gitee.com/openharmony/startup_init/issues/ICUJK2 Binary Source:No Signed-off-by: songjiawei9 --- .../sub_startup_init_ability_up_0500.json | 14 +++ .../sub_startup_init_ability_up_0500.py | 83 ++++++++++++++++ .../sub_startup_init_ability_up_0600.json | 14 +++ .../sub_startup_init_ability_up_0600.py | 88 +++++++++++++++++ .../sub_startup_init_ability_up_0700.json | 14 +++ .../sub_startup_init_ability_up_0700.py | 88 +++++++++++++++++ .../sub_startup_init_ability_up_0800.json | 14 +++ .../sub_startup_init_ability_up_0800.py | 88 +++++++++++++++++ .../sub_startup_init_ability_up_1000.json | 14 +++ .../sub_startup_init_ability_up_1000.py | 98 +++++++++++++++++++ ...ub_startup_init_access_isolation_0100.json | 14 +++ .../sub_startup_init_access_isolation_0100.py | 79 +++++++++++++++ ...ub_startup_init_access_isolation_0200.json | 14 +++ .../sub_startup_init_access_isolation_0200.py | 75 ++++++++++++++ .../sub_startup_init_apiname_0100.json | 14 +++ .../sub_startup_init_apiname_0100.py | 62 ++++++++++++ .../sub_startup_init_basicenv_0200.json | 14 +++ .../sub_startup_init_basicenv_0200.py | 44 +++++++++ .../sub_startup_init_basicenv_0600.json | 15 +++ .../sub_startup_init_basicenv_0600.py | 43 ++++++++ .../sub_startup_init_basicenv_0700.json | 15 +++ .../sub_startup_init_basicenv_0700.py | 58 +++++++++++ .../sub_startup_init_basicenv_0800.json | 15 +++ .../sub_startup_init_basicenv_0800.py | 63 ++++++++++++ .../sub_startup_init_basicenv_0900.json | 14 +++ .../sub_startup_init_basicenv_0900.py | 55 +++++++++++ .../sub_startup_init_basicenv_1000.json | 14 +++ .../sub_startup_init_basicenv_1000.py | 41 ++++++++ .../sub_startup_init_gwp_0200.json | 14 +++ .../sub_startup_init_gwp_0200.py | 41 ++++++++ .../sub_startup_init_gwp_0300.json | 14 +++ .../sub_startup_init_gwp_0300.py | 61 ++++++++++++ .../sub_startup_init_hilog_0100.json | 12 +++ .../sub_startup_init_hilog_0100.py | 63 ++++++++++++ .../sub_startup_init_odid_0100.json | 15 +++ .../sub_startup_init_odid_0100.py | 79 +++++++++++++++ .../sub_startup_init_odid_0300.json | 15 +++ .../sub_startup_init_odid_0300.py | 76 ++++++++++++++ 38 files changed, 1554 insertions(+) create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.py create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.py create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.py create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.py create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.json create mode 100644 test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.py create mode 100644 test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.json create mode 100644 test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.py create mode 100644 test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.json create mode 100644 test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.py create mode 100644 test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.json create mode 100644 test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.py create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.json create mode 100644 test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.py create mode 100644 test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.json create mode 100644 test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.py create mode 100644 test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.json create mode 100644 test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.py create mode 100644 test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.json create mode 100644 test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.py create mode 100644 test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.json create mode 100644 test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.py create mode 100644 test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.json create mode 100644 test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.py diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.json new file mode 100644 index 000000000..d5aa6b8ae --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp0500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.py new file mode 100644 index 000000000..1085df5cd --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0500.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp0500(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("预置工作:初始化手机/pc开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("重命名系统文件param_watcher.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/param_watcher.cfg /system/etc/init/param_watcher.cfg_bak") + Step("把系统文件param_watcher.cfg拉到本地..........................") + devpath = "/system/etc/init/param_watcher.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/param_watcher.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "param_watcher.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + Step(lines1) + line = lines1.index(' "services" : [{\n') + 1 + path3 = '\t\t\t"importance" : 100,\n' + lines1.insert(line, path3) + s = ''.join(lines1) + Step(s) + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service param_watcher') + Step(result) + pid = self.driver.System.get_pid('param_watcher') + Step(pid) + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件param_watcher.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/param_watcher.cfg") + self.driver.shell( + "mv /system/etc/init/param_watcher.cfg_bak /system/etc/init/param_watcher.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.json new file mode 100644 index 000000000..c56c57c03 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.py new file mode 100644 index 000000000..374f81c29 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0600.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp0600(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("重命名系统文件wifi_standard.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/wifi_standard.cfg /system/etc/init/wifi_standard.cfg_bak") + Step("把系统文件wifi_standard.cfg拉到本地..........................") + devpath = "/system/etc/init/wifi_standard.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/wifi_standard.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "wifi_standard.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + line = lines1.index(' "name" : "wifi_manager_service",\n') + 1 + res1 = line + Step(f"目标索引:{res1}") + index_str1 = lines1[res1] + Step(f"需要修改的目标:{index_str1}") + lines1.remove(index_str1) + Step(f"移除目标之后:{lines1}") + path3 = ' "path" : ["/system/xxxx/bin/sa_main"],\n' + lines1.insert(line, path3) + s = ''.join(lines1) + Step(f"添加修改之后的文件内容:{s}") + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service wifi_manager_service') + Step(result) + pid = self.driver.System.get_pid('wifi_manager_service') + Step(pid) + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件wifi_standard.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/wifi_standard.cfg") + self.driver.shell( + "mv /system/etc/init/wifi_standard.cfg_bak /system/etc/init/wifi_standard.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.json new file mode 100644 index 000000000..ebcbafd88 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.py new file mode 100644 index 000000000..ebcf1465f --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0700.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp0700(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("重命名系统文件hilogd.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/hilogd.cfg /system/etc/init/hilogd.cfg_bak") + Step("把系统文件hilogd.cfg拉到本地..........................") + devpath = "/system/etc/init/hilogd.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/hilogd.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "hilogd.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + line = lines1.index(' "socket" : [{\n') - 1 + res1 = line + Step(f"目标索引:{res1}") + index_str1 = lines1[res1] + Step(f"需要修改的目标:{index_str1}") + lines1.remove(index_str1) + Step(f"移除目标之后:{lines1}") + path3 = ' "file" : ["/dev/test/kmsg rd 0640 root root"],\n' + lines1.insert(line, path3) + s = ''.join(lines1) + Step(f"添加修改之后的文件内容:{s}") + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service hilogd') + Step(result) + self.driver.Assert.contains(result, "HiLogAdapter_init: Can't connect to server. Errno: 2") + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件hilogd.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/hilogd.cfg") + self.driver.shell( + "mv /system/etc/init/hilogd.cfg_bak /system/etc/init/hilogd.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.json new file mode 100644 index 000000000..c2a9032b3 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp0800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.py new file mode 100644 index 000000000..d62e52088 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_0800.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp0800(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("重命名系统文件wifi_standard.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/wifi_standard.cfg /system/etc/init/wifi_standard.cfg_bak") + Step("把系统文件wifi_standard.cfg拉到本地..........................") + devpath = "/system/etc/init/wifi_standard.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/wifi_standard.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "wifi_standard.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + line = lines1.index(' "uid" : "wifi",\n') + res1 = line + Step(f"目标索引:{res1}") + index_str1 = lines1[res1] + Step(f"需要修改的目标:{index_str1}") + lines1.remove(index_str1) + Step(f"移除目标之后:{lines1}") + path3 = ' "uid" : "-1",\n' + lines1.insert(line, path3) + s = ''.join(lines1) + Step(f"添加修改之后的文件内容:{s}") + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service wifi_manager_service') + Step(result) + pid = self.driver.System.get_pid('wifi_manager_service') + Step(pid) + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件wifi_standard.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/wifi_standard.cfg") + self.driver.shell( + "mv /system/etc/init/wifi_standard.cfg_bak /system/etc/init/wifi_standard.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.json b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.json new file mode 100644 index 000000000..fb01c76e2 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_ability_up/SubStartupInitAbilityUp1000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.py b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.py new file mode 100644 index 000000000..cebedd469 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_ability_up/sub_startup_init_ability_up_1000.py @@ -0,0 +1,98 @@ +#!/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 time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitAbilityUp1000(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("重命名系统文件hilogd.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell( + "cp /system/etc/init/hilogd.cfg /system/etc/init/hilogd.cfg_bak") + Step("把系统文件hilogd.cfg拉到本地..........................") + devpath = "/system/etc/init/hilogd.cfg" + self.driver.pull_file(devpath, "testFile/sub_startup_init_ability_up/hilogd.cfg") + Step("修改本地系统文件..........................") + lines1 = [] + path2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + "testFile\sub_startup_init_ability_up") + local_path = os.path.join(path2, "hilogd.cfg") + with open(local_path, "r") as y: + for line in y: + lines1.append(line) + y.close() + line = lines1.index(' "secon" : "u:r:hilogd:s0"\n') + res1 = line + Step(f"目标索引:{res1}") + index_str1 = lines1[res1] + Step(f"需要删除目标:{index_str1}") + lines1.remove(index_str1) + line2 = line - 1 + index_str2 = lines1[line2] + lines2 = list(index_str2) + Step(f"需要修改,:{lines2}") + if ',' in lines2: + lines2.remove(',') + s2 = ''.join(lines2) + Step(f"修改,之后:{s2}") + else: + pass + lines1.remove(index_str2) + lines1.insert(line2, s2) + Step(f"全部修改:{lines1}") + s = ''.join(lines1) + Step(f"修改之后的文件内容:{s}") + with open(local_path, "w") as z: + z.write(s) + z.close() + Step("上传修改后的本地系统文件..........................") + self.driver.push_file(local_path, devpath) + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() + Step("执行命令begetctl dump_service..........................") + result = self.driver.shell('begetctl dump_service hilogd') + Step(result) + self.driver.Assert.contains(result, "HiLogAdapter_init: Can't connect to server.") + + def teardown(self): + Step("收尾工作.................") + Step("恢复系统文件hilogd.cfg..........................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf /system/etc/init/hilogd.cfg") + self.driver.shell( + "mv /system/etc/init/hilogd.cfg_bak /system/etc/init/hilogd.cfg") + Step("执行重启..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.json b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.json new file mode 100644 index 000000000..2545c2229 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_access_isolation/SubStartupInitAccessIsolation0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.py b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.py new file mode 100644 index 000000000..fa4c7fae9 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0100.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from aw import Common +from hypium import UiDriver, UiExplorer +from hypium.action.os_hypium.device_logger import DeviceLogger +import subprocess + + +class SubStartupInitAccessIsolation0100(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("导入测试文件systemapp.................") + self.driver.hdc("target mount") + sourpath_se = Common.sourcepath("systemapp", "sub_startup_init_access_isolation") + destpath_se = "system/bin/systemapp" + self.driver.push_file(sourpath_se, destpath_se) + sleep(3) + Step("重启生效..........................") + self.driver.System.reboot() + sleep(5) + self.driver.System.wait_for_boot_complete() + + def test_step1(self): + Step("过滤打印hilog日志.................") + device_logger = DeviceLogger(self.driver) + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + device_logger.set_filter_string("systemapp") + Step("开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("给测试文件systemapp添加可执行权限.................") + self.driver.hdc("target mount") + self.driver.shell("chmod +x ./system/bin/systemapp") + Step("防止hilog日志出现unknown log.................") + self.driver.shell("hilog -d /system/bin/systemapp") + Step("执行测试文件systemapp.................") + self.driver.shell("./system/bin/systemapp") + time.sleep(3) + Step("停止抓日志") + device_logger.stop_log() + Step("断言预期结果") + time.sleep(2) + device_logger.check_log('systemapp:prohibit system component processes from accessing vendor files') + + def teardown(self): + Step("收尾工作.................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf system/bin/systemapp") + Step("重启恢复..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.json b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.json new file mode 100644 index 000000000..e9829d427 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_access_isolation/SubStartupInitAccessIsolation0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.py b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_0200.py new file mode 100644 index 000000000..1a18ee3ae --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_access_isolation/sub_startup_init_access_isolation_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. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from aw import Common +from hypium import UiDriver, UiExplorer +from hypium.action.os_hypium.device_logger import DeviceLogger +import subprocess + + +class SubStartupInitAccessIsolation0200(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): + print("预置工作:初始化手机开始.................") + print(self.devices[0].device_id) + Step("导入测试文件chipsetapp.................") + self.driver.hdc("target mount") + sourpath_se = Common.sourcepath("chipsetapp", "sub_startup_init_access_isolation") + destpath_se = "vendor/bin/chipsetapp" + self.driver.push_file(sourpath_se, destpath_se) + sleep(3) + Step("重启生效..........................") + self.driver.System.reboot() + sleep(5) + self.driver.System.wait_for_boot_complete() + + def test_step1(self): + Step("过滤打印hilog日志.................") + cmd = 'hdc shell hilog | grep chipsetapp' + trace = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=10) + count = 0 + Step("给测试文件chipsetapp添加可执行权限.................") + self.driver.hdc("target mount") + self.driver.shell("chmod +x ./vendor/bin/chipsetapp") + Step("执行测试文件chipsetapp.................") + self.driver.shell("./vendor/bin/chipsetapp") + Step("验证执行结果.................") + while trace.poll() is None: + result_text = trace.stdout.readline().decode() + if 'chipsetapp:prohibit chipset component processes from accessing system files' in result_text: + Step("实现芯片组件访问系统文件隔离.................") + trace.terminate() + break + count += 1 + + def teardown(self): + print("收尾工作.................") + self.driver.hdc("target mount") + self.driver.shell("rm -rf vendor/bin/chipsetapp") + Step("重启恢复..........................") + self.driver.System.reboot() + sleep(3) + self.driver.System.wait_for_boot_complete() diff --git a/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.json b/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.json new file mode 100644 index 000000000..61b91e1d2 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_apiname/SubStartupInitApiname0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.py b/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.py new file mode 100644 index 000000000..c996fcb17 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_apiname/sub_startup_init_apiname_0100.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from aw import Common + + +class SubStartupInitApiname0100(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("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("安装测试hap.................") + sourpath = Common.sourcepath("distributionOsApiName.hap", "sub_startup_init_apiname") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("命令查看param get const.product.os.dist.apiname.................") + apiname = self.driver.shell("param get const.product.os.dist.apiname") + apiname = apiname.strip() + Step(apiname) + result = "const.product.os.dist.apiname: " + apiname + Step(result) + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + Step("点击get ApiName按钮.................") + self.driver.touch(BY.text("get ApiName")) + sleep(1) + Step("校验apiname值.................") + + 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/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.json new file mode 100644 index 000000000..41e443498 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.py new file mode 100644 index 000000000..c2f111648 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0200.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0200(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("find /dev/unix/socket................") + result_socket = self.driver.shell("ls -l /dev/unix/socket") + Step(result_socket) + self.driver.Assert.contains(result_socket, 'hdcd', "ERROR: hdcd is not exist in socket directory.") + self.driver.Assert.contains(result_socket, 'hilogInput', "ERROR: hilogInput is not exist in socket directory.") + self.driver.Assert.contains(result_socket, 'hilogControl', "ERROR: hilogControl is not exist in socket directory.") + self.driver.Assert.contains(result_socket, 'hisysevent', "ERROR: hisysevent is not exist in socket directory.") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.json new file mode 100644 index 000000000..1f7d0dcbd --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.py new file mode 100644 index 000000000..058b638c2 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0600.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0600(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("df -h................") + result_df = self.driver.shell("df -h") + Step(result_df) + self.driver.Assert.contains(result_df, 'sdd8', "基础文件系统挂载失败") + self.driver.Assert.contains(result_df, '/vendor', "基础文件系统挂载失败") + self.driver.Assert.contains(result_df, '/data', "基础文件系统挂载失败") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.json new file mode 100644 index 000000000..d7a6e64a3 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.py new file mode 100644 index 000000000..2d0af23f1 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0700.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0700(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("df -h................") + result_df = self.driver.shell("df -h") + Step(result_df) + self.driver.Assert.contains(result_df, '/vendor', "基础文件系统挂载失败") + self.driver.Assert.contains(result_df, '/data', "基础文件系统挂载失败") + Step("find fstab................") + + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("ALN" in device): + result_fstab = self.driver.shell("cat /vendor/etc/fstab.kirin9000s") + elif("CLS" in device): + result_fstab = self.driver.shell("cat /vendor/etc/fstab.Kirin9010") + else: + result_fstab = self.driver.shell("cat /vendor/etc/fstab.kirin9020") + Step(result_fstab) + self.driver.Assert.contains(result_fstab, '/usr', "文件系统挂载失败") + self.driver.Assert.contains(result_fstab, '/vendor', "文件系统挂载失败") + self.driver.Assert.contains(result_fstab, '/data', "文件系统挂载失败") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.json new file mode 100644 index 000000000..03fd6b96c --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.py new file mode 100644 index 000000000..181c50d2a --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0800.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0800(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("find cmdline................") + result_cmdline = self.driver.shell("cat /proc/cmdline") + Step(result_cmdline) + + Step("识别设备型号...............................") + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + if ("ALN" in device): + self.driver.Assert.contains(result_cmdline, 'hardware=kirin9000s', "ERROR: cannot find hardware in /proc/cmdline.") + Step("param get hardware................") + result_hardware = self.driver.shell("param get ohos.boot.hardware") + Step(result_hardware) + self.driver.Assert.contains(result_hardware, 'kirin9000s', "ERROR: cannot find hardware in param get.") + elif ("CLS" in device): + self.driver.Assert.contains(result_cmdline, 'hardware=Kirin9010', "ERROR: cannot find hardware in /proc/cmdline.") + result_hardware = self.driver.shell("param get ohos.boot.hardware") + Step(result_hardware) + self.driver.Assert.contains(result_hardware, 'Kirin9010', "ERROR: cannot find hardware in param get.") + else: + self.driver.Assert.contains(result_cmdline, 'hardware=kirin9020', "ERROR: cannot find hardware in /proc/cmdline.") + Step("param get hardware................") + result_hardware = self.driver.shell("param get ohos.boot.hardware") + Step(result_hardware) + self.driver.Assert.contains(result_hardware, 'kirin9020', "ERROR: cannot find hardware in param get.") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.json new file mode 100644 index 000000000..0a41f45ea --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv0900.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.py new file mode 100644 index 000000000..255a0b026 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_0900.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 devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv0900(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("test mkdir................") + self.driver.shell("mkdir /data/testmkdir") + result_mkdir = self.driver.shell("ls -l /data") + Step(result_mkdir) + self.driver.Assert.contains(result_mkdir, 'testmkdir', "ERROR: cannot find testmkdir directory.") + Step("test rmdir................") + self.driver.shell("rmdir /data/testmkdir") + result_rmdir = self.driver.shell("ls -l /data/testmkdir") + Step(result_rmdir) + self.driver.Assert.contains(result_rmdir, 'No such file or directory', "ERROR: rmdir testmkdir directory failed.") + Step("test cd................") + result_cd = self.driver.shell("cd") + Step(result_cd) + self.driver.Assert.contains(result_cd, '', "ERROR: execute cd failed.") + Step("test pwd................") + result_pwd = self.driver.shell("pwd") + Step(result_pwd) + self.driver.Assert.contains(result_pwd, '/', "ERROR: execute pwd failed.") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.json b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.json new file mode 100644 index 000000000..65773ff6b --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_basicenv/SubStartupInitBasicenv1000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.py b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.py new file mode 100644 index 000000000..3fc626cc6 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_basicenv/sub_startup_init_basicenv_1000.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitBasicenv1000(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("test stop status................") + result_param = self.driver.shell("param get") + Step(result_param) + self.driver.Assert.contains(result_param, ' stop', "ERROR: cannot find stop from parameter.") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.json b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.json new file mode 100644 index 000000000..627e5fb03 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_gwp/SubStartupInitGwp0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.py b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.py new file mode 100644 index 000000000..1ec9ab9f1 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0200.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + + +class SubStartupInitGwp0200(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 get const.security.developermode.state") + Step(result) + self.driver.Assert.contains(result, 'true', "开发者模式打开时,进行GWP-ASAN使能") + + def teardown(self): + Step("收尾工作.................") diff --git a/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.json b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.json new file mode 100644 index 000000000..203f603b1 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_gwp/SubStartupInitGwp0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.py b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.py new file mode 100644 index 000000000..66ebfd13d --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_gwp/sub_startup_init_gwp_0300.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +class SubStartupInitGwp0300(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("force.hap", "sub_startup_init_gwp") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + sleep(3) + + def test_step1(self): + self.d = UiExplorer(self.device1) + device_logger = DeviceLogger(self.d) + Step("设置关键字..........................") + device_logger.set_filter_string("gwp_asan") + Step("开启日志..........................") + device_logger.start_log("testFile/Log/log.txt") + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(10) + Step("停止日志..........................") + device_logger.stop_log() + Step("校验日志内容..........................") + + 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/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.json b/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.json new file mode 100644 index 000000000..d6f2a8579 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["sub_startup_init_hilog/SubStartupInitHilog0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.py b/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.py new file mode 100644 index 000000000..c21dbb1e1 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_hilog/sub_startup_init_hilog_0100.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class SubStartupInitHilog0100(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() + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + device_logger.set_filter_string("C02C11") + Step("步骤2:获取appspawn的进程号") + pid = self.driver.System.get_pid("appspawn") + Step("步骤3:开始抓日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:kill进程号") + self.driver.shell("kill -9 %d" % pid) + time.sleep(5) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('nodict') + + def teardown(self): + Step("收尾工作:无") \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.json b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.json new file mode 100644 index 000000000..e27e546d6 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_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_init_odid/SubStartupInitOdid0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.py b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.py new file mode 100644 index 000000000..4c84eecd5 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0100.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + +from aw import Common + + +class SubStartupInitOdid0100(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("odid.hap", "sub_startup_init_odid") + 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.newodidtest", "EntryAbility") + sleep(3) + Step("点击菜单.................") + self.driver.touch(BY.text("dev2 ODID1 ")) + sleep(1) + Step("获取首次odid.................") + component = self.driver.find_component(BY.type("Text")) + odid1 = component.getText() + Step(odid1) + Step("卸载测试hap................") + self.driver.AppManager.clear_app_data('com.example.newodidtest') + self.driver.AppManager.uninstall_app('com.example.newodidtest') + sleep(3) + Step("再次安装hap.................") + sourpath = Common.sourcepath("odid.hap", "sub_startup_init_odid") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("打开测试hap.................") + self.driver.start_app("com.example.newodidtest", "EntryAbility") + sleep(3) + Step("点击菜单.................") + self.driver.touch(BY.text("dev2 ODID1 ")) + sleep(1) + Step("获取二次odid.................") + component = self.driver.find_component(BY.type("Text")) + odid2 = component.getText() + Step(odid2) + + def teardown(self): + Step("收尾工作.................") + Step("卸载测试hap................") + self.driver.AppManager.clear_app_data('com.example.newodidtest') + self.driver.AppManager.uninstall_app('com.example.newodidtest') diff --git a/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.json b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.json new file mode 100644 index 000000000..92e0971b5 --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_init_odid/SubStartupInitOdid0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.py b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.py new file mode 100644 index 000000000..87fbde07c --- /dev/null +++ b/test/autotest/testcases/sub_startup_init_odid/sub_startup_init_odid_0300.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. + +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import UiDriver + +from aw import Common + + +class SubStartupInitOdid0300(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.................") + sourpath1 = Common.sourcepath("odid.hap", "sub_startup_init_odid") + sourpath2 = Common.sourcepath("odid1.hap", "sub_startup_init_odid") + Step(sourpath1) + Step(sourpath2) + self.driver.AppManager.install_app(sourpath1) + self.driver.AppManager.install_app(sourpath2) + 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.newodidtest", "EntryAbility") + sleep(3) + Step("点击菜单.................") + self.driver.touch(BY.text("dev2 ODID1 ")) + sleep(1) + Step("获取第一个odid.................") + component = self.driver.find_component(BY.type("Text")) + odid1 = component.getText() + Step(odid1) + Step("打开第二个开发者测试hap.................") + self.driver.start_app("com.example.odidtest", "EntryAbility") + sleep(3) + Step("点击菜单.................") + self.driver.touch(BY.text("dev1 ODID1 ")) + sleep(1) + Step("获取第二个odid.................") + component = self.driver.find_component(BY.type("Text")) + odid2 = component.getText() + Step(odid2) + + def teardown(self): + Step("收尾工作.................") + Step("卸载测试hap................") + self.driver.AppManager.clear_app_data('com.example.newodidtest') + self.driver.AppManager.clear_app_data('com.example.odidtest') + self.driver.AppManager.uninstall_app('com.example.newodidtest') + self.driver.AppManager.uninstall_app('com.example.odidtest') \ No newline at end of file -- Gitee