From 1ed60cf069a2a43ea25d25978630f134ddffff47 Mon Sep 17 00:00:00 2001 From: nianyuu Date: Sat, 18 Jan 2025 14:32:47 +0800 Subject: [PATCH 1/2] add devicedebug autotest Signed-off-by: nianyuu --- ...sub_startup_appspawn_devicedebug_0100.json | 14 +++ .../sub_startup_appspawn_devicedebug_0100.py | 80 +++++++++++++++++ ...sub_startup_appspawn_devicedebug_0200.json | 14 +++ .../sub_startup_appspawn_devicedebug_0200.py | 82 ++++++++++++++++++ ...sub_startup_appspawn_devicedebug_0300.json | 14 +++ .../sub_startup_appspawn_devicedebug_0300.py | 84 ++++++++++++++++++ ...sub_startup_appspawn_devicedebug_0400.json | 14 +++ .../sub_startup_appspawn_devicedebug_0400.py | 86 +++++++++++++++++++ ...sub_startup_appspawn_devicedebug_0500.json | 14 +++ .../sub_startup_appspawn_devicedebug_0500.py | 81 +++++++++++++++++ ...sub_startup_appspawn_devicedebug_0600.json | 14 +++ .../sub_startup_appspawn_devicedebug_0600.py | 64 ++++++++++++++ ...sub_startup_appspawn_devicedebug_0700.json | 14 +++ .../sub_startup_appspawn_devicedebug_0700.py | 79 +++++++++++++++++ ...sub_startup_appspawn_devicedebug_0800.json | 14 +++ .../sub_startup_appspawn_devicedebug_0800.py | 60 +++++++++++++ ...sub_startup_appspawn_devicedebug_0900.json | 14 +++ .../sub_startup_appspawn_devicedebug_0900.py | 59 +++++++++++++ 18 files changed, 801 insertions(+) create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json create mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json new file mode 100644 index 00000000..b764571d --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py new file mode 100644 index 00000000..6a4ed9be --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py @@ -0,0 +1,80 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +SubStartupAppspawnDevicedebug0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + global bundle_name + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('release.hap', "sub_startup_appspawn_devicedebug") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + pid1 = self.driver.System.get_pid(bundle_name) + + Step("开启日志") + device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") + log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] + device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) + + Step("devicedebug发送kill信号") + self.driver.shell("devicedebug kill -9 %d" % pid1) + pid2 = self.driver.System.get_pid(bundle_name) + self.driver.Assert.equal(pid1, pid2) + + Step("匹配日志") + device_logger.stop_log() + time.sleep(10) + assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid1) + assert device_logger.check_log("appspawn devicedebug process is not debuggable, pid=%d" % pid1) + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json new file mode 100644 index 00000000..cb9198c7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py new file mode 100644 index 00000000..844b360f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py @@ -0,0 +1,82 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +SubStartupAppspawnDevicedebug0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + global bundle_name + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + pid1 = self.driver.System.get_pid(bundle_name) + + Step("开启日志") + device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") + log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] + device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) + + Step("devicedebug发送kill信号") + self.driver.shell("devicedebug kill -9 %d" % pid1) + + Step("匹配日志") + device_logger.stop_log() + time.sleep(10) + assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid1) + assert device_logger.check_log("appspawn devicedebug debugable=1, pid=%d, signal=9" % pid1) + assert device_logger.check_log("devicedebug manager process exit. ret=0") + self.driver.AppManager.start_app(bundle_name) + pid2 = self.driver.System.get_pid(bundle_name) + self.driver.Assert.not_equal(pid1, pid2) + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json new file mode 100644 index 00000000..e560671a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py new file mode 100644 index 00000000..124b5835 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py @@ -0,0 +1,84 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + +SubStartupAppspawnDevicedebug0300(TestCase): + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + global bundle_name + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + + Step("开启日志") + device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") + log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] + device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) + + Step("devicedebug发送kill信号") + signal_lst = [1, 9, 11, 15, 64] + log_dict = {} + # 本地跑1-64的 但是由于太费时间,流水线跑signal_lst中这几个有代表性的就可以了 + for signal in signal_lst: # range(1, 65)替换signal_lst + self.driver.AppManager.start_app(bundle_name) + pid = self.driver.System.get_pid(bundle_name) + log_dict.update({signal: pid}) + self.driver.shell("devicedebug kill -%d %d" % (signal, pid)) + self.driver.AppManager.stop_app(bundle_name) + + Step("匹配日志") + device_logger.stop_log() + time.sleep(10) + for signal, pid in log_dict.items(): + assert device_logger.check_log("devicedebug cmd kill start signal[%d], pid[%d]" % (signal, pid)) + assert device_logger.check_log("appspawn devicedebug debugable=1, pid=%d, signal=%d" % (pid, signal)) + assert device_logger.check_log("devicedebug manager process exit. ret=0") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json new file mode 100644 index 00000000..9b0248bf --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py new file mode 100644 index 00000000..e8c938f6 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py @@ -0,0 +1,86 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +SubStartupAppspawnDevicedebug0400(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + global bundle_name + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + + Step("开启日志") + device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") + log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] + device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) + + Step("devicedebug发送kill信号") + signal_lst = ["65", "0", "SIGKILL", "null", "undefined", "sigkill"] + for signal in signal_lst: + self.driver.AppManager.start_app(bundle_name) + pid1 = self.driver.System.get_pid(bundle_name) + self.driver.shell("devicedebug kill -%s %d" % (signal, pid1)) + pid2 = self.driver.System.get_pid(bundle_name) + self.driver.Assert.equal(pid1, pid2) + + Step("匹配日志") + device_logger.stop_log() + time.sleep(10) + for i in range(len(signal_lst)): + assert device_logger.check_log("devicedebug manager process start.") + assert device_logger.check_log("devicedebug manager process exit. ret=22") + assert device_logger.check_log("signal is 65 not in [1, 64]") + assert device_logger.check_log("signal is 0 not in [1, 64]", expect_match_times=len(signal_lst)-1) + + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json new file mode 100644 index 00000000..eff74779 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py new file mode 100644 index 00000000..b028350c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py @@ -0,0 +1,81 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +SubStartupAppspawnDevicedebug0500(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + global bundle_name + bundle_name = "com.example.myapplication" + hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + + Step("开启日志") + device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") + log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] + device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) + + Step("devicedebug发送kill信号") + self.driver.AppManager.start_app(bundle_name) + pid1 = self.driver.System.get_pid(bundle_name) + self.driver.shell("devicedebug kill %d" % pid1) + pid2 = self.driver.System.get_pid(bundle_name) + self.driver.Assert.equal(pid1, pid2) + + Step("匹配日志") + device_logger.stop_log() + time.sleep(10) + assert device_logger.check_log("devicedebug manager process start.") + assert device_logger.check_log("devicedebug cmd operator num is 3 < 4") + assert device_logger.check_log("devicedebug manager process exit. ret=18") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json new file mode 100644 index 00000000..acbcf0b7 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py new file mode 100644 index 00000000..15bd1609 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py @@ -0,0 +1,64 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +SubStartupAppspawnDevicedebug0600(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("开启日志") + device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") + log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] + device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) + + Step("devicedebug发送kill信号") + pid = self.driver.System.get_pid("nwebspawn") + self.driver.shell("devicedebug kill -9 %d" % pid) + + Step("匹配日志") + device_logger.stop_log() + time.sleep(10) + assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid) + assert device_logger.check_log("appspawn devicedebug process is not debuggable, pid=%d" % pid) + assert device_logger.check_log("devicedebug manager process exit. ret=218103838") + + def teardown(self): + Step("收尾工作.................") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json new file mode 100644 index 00000000..2fc5b2e4 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py new file mode 100644 index 00000000..141ff482 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py @@ -0,0 +1,79 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +SubStartupAppspawnDevicedebug0700(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + Step("安装测试hap并打开") + global bundle_name + bundle_name = "com.example.exe_sys_cmd" + hap_path = Common.sourcepath('debug_fork.hap', "sub_startup_appspawn_devicedebug") + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + result01 = self.driver.shell("ps -ef|grep exe_sys_cmd|grep -v grep").split("\n") + childprocess_pid = result01[1].split()[1] + + Step("开启日志") + device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") + log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] + device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) + + Step("devicedebug发送kill信号") + self.driver.shell("devicedebug kill -9 %s" % childprocess_pid) + + Step("匹配日志") + device_logger.stop_log() + time.sleep(10) + assert device_logger.check_log("appspawn devicedebug get app info unsuccess, pid=%s" % childprocess_pid) + assert device_logger.check_log("devicedebug manager process exit. ret=218103837") + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.stop_app(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json new file mode 100644 index 00000000..aab5e2c2 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py new file mode 100644 index 00000000..6d0f6552 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py @@ -0,0 +1,60 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +SubStartupAppspawnDevicedebug0800(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + devicedebug_help_dict = [ + "devicedebug: 'aaa' is not a valid devicedebug command. See 'devicedebug help'.", + "usage: devicedebug ", + "These are common devicedebug commands list:", + " help list available commands", + " kill send a signal(1-64) to a process" + ] + result_dict = list(filter(lambda x: x != "\r", self.driver.shell("devicedebug aaa").split("\n"))) + result_dict = list(filter(None, result_dict)) + for result in result_dict: + self.driver.Assert.contains(devicedebug_help_dict, result.rstrip("\r")) + + def teardown(self): + Step("收尾工作.................") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json new file mode 100644 index 00000000..93b61870 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py new file mode 100644 index 00000000..44e7a31a --- /dev/null +++ b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py @@ -0,0 +1,59 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from aw import Common + + +SubStartupAppspawnDevicedebug0900(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def process(self): + devicedebug_help_dict = [ + "usage: devicedebug ", + "These are common devicedebug commands list:", + " help list available commands", + " kill send a signal(1-64) to a process" + ] + result_dict = list(filter(lambda x: x != "\r", self.driver.shell("devicedebug help").split("\n"))) + result_dict = list(filter(None, result_dict)) + for result in result_dict: + self.driver.Assert.contains(devicedebug_help_dict, result.rstrip("\r")) + + def teardown(self): + Step("收尾工作.................") \ No newline at end of file -- Gitee From b01e16f052661315965297b5147ca10598e9cf2f Mon Sep 17 00:00:00 2001 From: nianyuu Date: Wed, 12 Mar 2025 17:32:59 +0800 Subject: [PATCH 2/2] adjust the order of mount points Signed-off-by: nianyuu --- appdata-sandbox.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/appdata-sandbox.json b/appdata-sandbox.json index 463b1ea3..22502dd4 100755 --- a/appdata-sandbox.json +++ b/appdata-sandbox.json @@ -98,16 +98,6 @@ "sandbox-path" : "/data/data/hiai", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" - }, { - "src-path" : "/vendor/etc/vulkan", - "sandbox-path" : "/vendor/etc/vulkan", - "sandbox-flags" : [ "bind", "rec" ], - "check-action-status": "false" - }, { - "src-path" : "/vendor/etc/passthrough", - "sandbox-path" : "/vendor/etc/passthrough", - "sandbox-flags" : [ "bind", "rec" ], - "check-action-status": "false" }, { "src-path" : "/mnt/sandbox///data/storage/el2", "sandbox-path" : "/data/storage/el2", @@ -233,19 +223,29 @@ "sandbox-path" : "/data/storage/el4/database", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" + }, { + "src-path" : "/chip_prod/etc/passthrough", + "sandbox-path" : "/chip_prod/etc/passthrough", + "sandbox-flags" : [ "bind", "rec" ], + "check-action-status": "false" }, { "src-path" : "/mnt/hmdfs//cloud/data/", "sandbox-path" : "/data/storage/el2/cloud", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" + }, { + "src-path" : "/vendor/etc/vulkan", + "sandbox-path" : "/vendor/etc/vulkan", + "sandbox-flags" : [ "bind", "rec" ], + "check-action-status": "false" }, { "src-path" : "/mnt/data//media_fuse", "sandbox-path" : "/data/storage/el2/media", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }, { - "src-path" : "/chip_prod/etc/passthrough", - "sandbox-path" : "/chip_prod/etc/passthrough", + "src-path" : "/vendor/etc/passthrough", + "sandbox-path" : "/vendor/etc/passthrough", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" } -- Gitee