diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0100.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0100.json new file mode 100644 index 0000000000000000000000000000000000000000..680ba7fec8c5989c498e99b75d49eab04bbd29f0 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0100.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0100.py new file mode 100644 index 0000000000000000000000000000000000000000..cc5240317e819e0bcb59635c228e9b37bb5717c4 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0100.py @@ -0,0 +1,83 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn0100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:首次获取nativesapwn进程号") + pid1 = self.driver.System.get_pid("nativespawn") + Step("步骤5:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤6:第二次获取nativesapwn进程号") + pid2 = self.driver.System.get_pid("nativespawn") + Step("步骤7:关闭测试应用") + self.driver.stop_app("com.acts.childprocessmanager") + Step("步骤8:第三次获取nativesapwn进程号") + pid3 = self.driver.System.get_pid("nativespawn") + Step("步骤9:预期结果校验") + self.driver.Assert.equal(pid1, None) + self.driver.Assert.not_equal(pid2, None) + self.driver.Assert.equal(pid3, None) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0200.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0200.json new file mode 100644 index 0000000000000000000000000000000000000000..35f2dbc3c2e4698b8c2aa744417aa00e18c22831 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0200.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0200.py new file mode 100644 index 0000000000000000000000000000000000000000..1b81b8e1ad18828b857bc100b91d2e11a5a30c64 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0200.py @@ -0,0 +1,82 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn0200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:查看数据") + res = self.driver.shell("ls -l /proc/%d/ns/net" % pid) + childres = self.driver.shell("ls -l /proc/%d/ns/net" % child_pid) + Step("步骤7:预期结果检验") + arr = res.split("-> ")[1] + childarr = childres.split("-> ")[1] + self.driver.Assert.equal(arr, childarr) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0300.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0300.json new file mode 100644 index 0000000000000000000000000000000000000000..52c04399192844138443904d9090ea5503e532e6 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0300.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0300.py new file mode 100644 index 0000000000000000000000000000000000000000..30963fe61a13ad9a62b57f0c015843b852b50508 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0300.py @@ -0,0 +1,82 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn0300(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:查看数据") + res = self.driver.shell("ls -l /proc/%d/ns/net" % pid) + childres = self.driver.shell("ls -l /proc/%d/ns/net" % child_pid) + Step("步骤7:预期结果检验") + arr = res.split("-> ")[1] + childarr = childres.split("-> ")[1] + self.driver.Assert.not_equal(arr, childarr) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0400.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0400.json new file mode 100644 index 0000000000000000000000000000000000000000..53ec308d8b07d17a43ec365c74f0d9dc62677784 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0400.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0400.py new file mode 100644 index 0000000000000000000000000000000000000000..57bf33a338758ebe4775d142b819010fa9108e70 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0400.py @@ -0,0 +1,82 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn0400(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用nativespawn孵化子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:查看数据") + res = self.driver.shell("ls -l /proc/%d/ns/net" % pid) + childres = self.driver.shell("ls -l /proc/%d/ns/net" % child_pid) + Step("步骤7:预期结果检验") + arr = res.split("-> ")[1] + childarr = childres.split("-> ")[1] + self.driver.Assert.equal(arr, childarr) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0500.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0500.json new file mode 100644 index 0000000000000000000000000000000000000000..8ac0c9f06308f5d28576051d995679d6abbab164 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0500.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0500.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0500.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0500.py new file mode 100644 index 0000000000000000000000000000000000000000..c01985d2a74eef7d59896520cb42494efd52e83d --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0500.py @@ -0,0 +1,82 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn0500(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用nativespawn孵化子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:查看数据") + res = self.driver.shell("ls -l /proc/%d/ns/net" % pid) + childres = self.driver.shell("ls -l /proc/%d/ns/net" % child_pid) + Step("步骤7:预期结果检验") + arr = res.split("-> ")[1] + childarr = childres.split("-> ")[1] + self.driver.Assert.not_equal(arr, childarr) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0700.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0700.json new file mode 100644 index 0000000000000000000000000000000000000000..e524f783a15c0c75bb3222b7b085dbc8404340cf --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0700.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0700.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0700.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0700.py new file mode 100644 index 0000000000000000000000000000000000000000..159ff680f3f70eacf7dd5ddfc18c2528b1235bdf --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0700.py @@ -0,0 +1,82 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn0700(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:测试应用沙箱路径data/storage/el1生成一个123.txt") + self.driver.shell("echo 123456789 > /proc/%d/root/data/storage/el1/123.txt" % pid) + Step("步骤8:测试应用appspawn孵化子进程查看沙箱路径data/storage/el1") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/123.txt" % child_pid) + Step("步骤8:预期结果检验") + self.driver.Assert.contains(childres, "root/data/storage/el1/123.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/123.txt" % pid) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0900.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0900.json new file mode 100644 index 0000000000000000000000000000000000000000..4dadc000629fa9eb1a8283f6a2bd8369c3a1496a --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0900.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0900.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0900.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0900.py new file mode 100644 index 0000000000000000000000000000000000000000..e425e2310d73fb145cd803d7c94c8c26a388e080 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_0900.py @@ -0,0 +1,84 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn0900(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用孵化native进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1生成一个123.txt") + self.driver.shell("echo 0123456789 > /proc/%d/root/data/storage/el1/123.txt" % pid) + Step("步骤8:测试应用孵化native进程查看沙箱路径data/storage/el1") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/123.txt" % child_pid) + Step("步骤8:预期结果检验") + self.driver.Assert.contains(childres, "root/data/storage/el1/123.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/123.txt" % pid) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1000.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1000.json new file mode 100644 index 0000000000000000000000000000000000000000..65eb9d6c961e652a5e13c7afe70202a36aa39673 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1000.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1000.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1000.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1000.py new file mode 100644 index 0000000000000000000000000000000000000000..5041713f21bf2a9eb665155d70394fcfe7bb96df --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1000.py @@ -0,0 +1,91 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1000(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("Start Ark Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:测试应用沙箱路径data/storage/el1/bundle目录下,创建2个文件夹") + self.driver.shell("mkdir /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + Step("步骤8:测试应用沙箱路径data/storage/el1/bundle/tets1,创建1个test.txt文件") + self.driver.shell("echo this is test1 > /proc/%d/root/data/storage/el1/bundle/test1/test.txt" % pid) + Step("步骤9:test1挂载test2") + self.driver.shell("mount /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + Step("步骤10:查看test2目录下的文件是否和test1内容一致") + res = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/test2/test.txt" % pid) + Step("步骤11:测试应用appspawn孵化子进程查看沙箱路径data/storage/el1/bundle/test2/test.txt") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/test2/test.txt" % child_pid) + Step("步骤12:预期结果检验") + self.driver.Assert.contains(res, "this is test1") + self.driver.Assert.contains(childres, "root/data/storage/el1/bundle/test2/test.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1100.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1100.json new file mode 100644 index 0000000000000000000000000000000000000000..52e18e1cf4fedf7b60ecb9c09d2c7c3428a40252 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1100.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1100.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1100.py new file mode 100644 index 0000000000000000000000000000000000000000..3d6179da2b7e4c128d71408f0866d1093ee85783 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1100.py @@ -0,0 +1,91 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1100(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("Start Ark Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用appspawn孵化子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:ArkProcess0") + Step("步骤7:测试应用沙箱路径data/storage/el1/bundle目录下,创建2个文件夹") + self.driver.shell("mkdir /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + Step("步骤8:测试应用沙箱路径data/storage/el1/bundle/tets1,创建1个test.txt文件") + self.driver.shell("echo this is test1 > /proc/%d/root/data/storage/el1/bundle/test1/test.txt" % pid) + Step("步骤9:test1挂载test2") + self.driver.shell("mount /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + Step("步骤10:查看test2目录下的文件是否和test1内容一致") + res = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/test2/test.txt" % pid) + Step("步骤11:测试应用appspawn孵化子进程查看沙箱路径data/storage/el1/bundle/test2/test.txt") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/test2/test.txt" % child_pid) + Step("步骤12:预期结果检验") + self.driver.Assert.contains(res, "this is test1") + self.driver.Assert.contains(childres, "root/data/storage/el1/bundle/test2/test.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/bundle/test1 /proc/%d/root/data/storage/el1/bundle/test2" % (pid, pid)) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1200.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1200.json new file mode 100644 index 0000000000000000000000000000000000000000..ff9fc37a5ea011ed6a18bcda6687f4ca518c0125 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1200.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1200.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1200.py new file mode 100644 index 0000000000000000000000000000000000000000..8fcadffd5a1682466704dcd282cf504f312a9a34 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1200.py @@ -0,0 +1,91 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1200(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Native Process按钮") + self.driver.touch(BY.text("start Native Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:孵化native子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1/bundle目录下,创建2个文件夹") + self.driver.shell("mkdir /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + Step("步骤8:测试应用沙箱路径data/storage/el1/bundle/tets1,创建1个zsj.txt文件") + self.driver.shell("echo this is zsj1 > /proc/%d/root/data/storage/el1/bundle/zsj1/zsj.txt" % pid) + Step("步骤9:test1挂载test2") + self.driver.shell("mount /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + Step("步骤10:查看test2目录下的文件是否和test1内容一致") + res = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/zsj2/zsj.txt" % pid) + Step("步骤11:孵化native子进程查看沙箱路径data/storage/el1/bundle/zsj2/zsj.txt") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/zsj2/zsj.txt" % child_pid) + Step("步骤12:预期结果检验") + self.driver.Assert.contains(res, "this is zsj1") + self.driver.Assert.contains(childres, "root/data/storage/el1/bundle/zsj2/zsj.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1300.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1300.json new file mode 100644 index 0000000000000000000000000000000000000000..060f23479bd1ec68b5d37d14402393a99bb06ece --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1300.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1300.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1300.py new file mode 100644 index 0000000000000000000000000000000000000000..29eaca606886fbc505cbbe1c0139bd7e7a86597d --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1300.py @@ -0,0 +1,91 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1300(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取孵化native子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1/bundle目录下,创建2个文件夹") + self.driver.shell("mkdir /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + Step("步骤8:测试应用沙箱路径data/storage/el1/bundle/tets1,创建1个zsj.txt文件") + self.driver.shell("echo this is zsj1 > /proc/%d/root/data/storage/el1/bundle/zsj1/zsj.txt" % pid) + Step("步骤9:test1挂载test2") + self.driver.shell("mount /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + Step("步骤10:查看test2目录下的文件是否和test1内容一致") + res = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/zsj2/zsj.txt" % pid) + Step("步骤11:孵化native子进程查看沙箱路径data/storage/el1/bundle/zsj2/zsj.txt") + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/bundle/zsj2/zsj.txt" % child_pid) + Step("步骤12:预期结果检验") + self.driver.Assert.contains(res, "this is zsj1") + self.driver.Assert.contains(childres, "root/data/storage/el1/bundle/zsj2/zsj.txt: No such file or directory") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/bundle/zsj1 /proc/%d/root/data/storage/el1/bundle/zsj2" % (pid, pid)) + + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1400.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1400.json new file mode 100644 index 0000000000000000000000000000000000000000..6b1aade8c9e12af961bca1127ab8ca3ca9f84204 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1400.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1400.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1400.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1400.py new file mode 100644 index 0000000000000000000000000000000000000000..71c95199cfe295801308a5aba0c3e9fcc3dff745 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1400.py @@ -0,0 +1,90 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1400(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用孵化native进程pid") + child_pid 1 = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用沙箱路径data/storage/el1生成一个native.txt") + self.driver.shell("echo this is native1 > /proc/%d/root/data/storage/el1/native.txt" % child_pid 1) + childres = self.driver.shell("cat /proc/%d/root/data/storage/el1/native.txt" % child_pid 1) + Step("步骤8:杀死孵化native进程") + self.driver.shell("kill -9 %d" % child_pid 1) + Step("步骤9:再次点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤10:测试应用孵化native进程查看沙箱路径data/storage/el1") + child_pid 2 = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry1") + childres2 = self.driver.shell("cat /proc/%d/root/data/storage/el1/native.txt" % child_pid 2) + Step("步骤11:预期结果检验") + self.driver.Assert.contains(childres, "this is native1") + self.driver.Assert.contains(childres2, "this is native1") + self.driver.shell("rm -rf /proc/%d/root/data/storage/el1/native.txt" % child_pid 2) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1500.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1500.json new file mode 100644 index 0000000000000000000000000000000000000000..851b51223a6fe81b8ff8bf3e97467f52acd300a3 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1500.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1500.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1500.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1500.py new file mode 100644 index 0000000000000000000000000000000000000000..dc71daf44fb956265c5b5579d7fe275519992b1c --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1500.py @@ -0,0 +1,85 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1500(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用孵化native进程pid") + child_pid 1 = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:杀死nativespawn进程") + self.driver.shell("kill -9 `pidof nativespawn`") + Step("步骤8:查询测试应用") + result = self.driver.shell("ps -ef | grep com.acts.childprocessmanager") + Step("步骤9:查询nativespawn进程号") + nativepid = self.driver.System.get_pid("nativespawn") + self.driver.Assert.contains(result, str(child_pid 1)) + self.driver.Assert.contains(result, str(pid)) + self.driver.Assert.equal(nativepid, None) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1600.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1600.json new file mode 100644 index 0000000000000000000000000000000000000000..749e6f9959947b54f173657a1c4b3a4dd03c8515 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1600.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1600.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1600.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1600.py new file mode 100644 index 0000000000000000000000000000000000000000..4a3bc803cc34df4e138a00f47c17bdeabad9870b --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1600.py @@ -0,0 +1,78 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1600(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤5:获取测试应用nativespawn孵化子进程pid") + time.sleep(1) + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤6:孵化的native子进程(Isolated=true)selinux标签类型") + childres = self.driver.shell("ps -efZ | grep %d | grep -v grep" % child_pid) + Step("步骤9: 预期结果校验") + self.driver.Assert.contains(childres, "u:r:isolated_render:s0") + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1700.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1700.json new file mode 100644 index 0000000000000000000000000000000000000000..949a2197805fa2395ae8ca5f35ac29dc6b254f0d --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1700.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1700.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1700.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1700.py new file mode 100644 index 0000000000000000000000000000000000000000..58b4c977109c6cc4de6ade43547aedc10b2eb8a0 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1700.py @@ -0,0 +1,83 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1700(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:点击start Ark Process按钮") + self.driver.touch(BY.text("start Native Process")) + Step("步骤5:获取测试应用pid") + pid = self.driver.System.get_pid("com.acts.childprocessmanager") + Step("步骤6:获取测试应用nativespawn孵化子进程pid") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + Step("步骤7:测试应用selinux标签类型") + res = self.driver.shell("ps -efZ | grep %d | grep -v grep" % pid) + Step("步骤8:孵化的native子进程(Isolated=false)selinux标签类型") + childres = self.driver.shell("ps -efZ | grep %d | grep -v grep" % child_pid) + string = res.split(" ")[0] + child_string = childres.split(" ")[0] + Step("步骤9: 预期结果校验") + self.driver.Assert.equal(string, child_string) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1800.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1800.json new file mode 100644 index 0000000000000000000000000000000000000000..b5bedb14789015eec490b40cd2a9858909dd38d8 --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1800.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1800.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1800.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1800.py new file mode 100644 index 0000000000000000000000000000000000000000..a1ab55679961bcad0d40d2f3457b0724f2b0ee3a --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1800.py @@ -0,0 +1,93 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1800(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + self.driver.install_app(hap) + Step("步骤2:打开测试应用") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:首次获取nativesapwn进程号") + pid1 = self.driver.System.get_pid("nativespawn") + Step("步骤5:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + time.sleep(1) + Step("步骤6:再次点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤7:第二次获取nativesapwn进程号") + pid2 = self.driver.System.get_pid("nativespawn") + Step("步骤8:杀掉孵化的一个nativ进程") + child_pid = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry0") + self.driver.shell("kill -9 %d" % child_pid) + Step("步骤9:第三次获取nativesapwn进程号") + pid3 = self.driver.System.get_pid("nativespawn") + Step("步骤10:杀掉孵化的最后一个native子进程") + child_pid 1 = self.driver.System.get_pid("com.acts.childprocessmanager:Native_libentry1") + self.driver.shell("kill -9 %d" % child_pid 1) + Step("步骤11:第四次获取nativesapwn进程号") + pid4 = self.driver.System.get_pid("nativespawn") + Step("步骤12:预期结果校验") + self.driver.Assert.equal(pid1, None) + self.driver.Assert.not_equal(pid2, None) + self.driver.Assert.not_equal(pid3, None) + self.driver.Assert.equal(pid4, None) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1900.json b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1900.json new file mode 100644 index 0000000000000000000000000000000000000000..77347638d95a1c37628f959e4c5948a95b5346ea --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1900.json @@ -0,0 +1,12 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1900.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1900.py b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1900.py new file mode 100644 index 0000000000000000000000000000000000000000..a4f318c88b170d95141541bdb8ea4531d954be0e --- /dev/null +++ b/test/autotest/SubStartupAppspawnNativespawn/sub_startup_appspawn_nativespawn_1900.py @@ -0,0 +1,102 @@ +# 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 TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import UiParam +from hypium.model import UiParam +from aw import Common +import time + + +class SubStartupAppspawnNativespawn1900(TestCase): + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('获取权限状态') + is_status = self.driver.shell("param get persist.sys.abilityms.multi_process_model") + if ("true" in is_status): + pass + else: + Step('设置权限为true') + self.driver.shell("param set persist.sys.abilityms.multi_process_model true") + Step('重启生效') + self.driver.shell("reboot") + self.driver.System.wait_for_boot_complete() + self.driver.ScreenLock.unlock() + + def test_step1(self): + Step("步骤1:安装测试应用") + hap1 = Common.sourcepath('entry-default-nativespawn.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + hap2 = Common.sourcepath('entry-default-nativespawn1.hap', "SUB_STARTUP_STABILITY_APPSPAWN") + is_hap = self.driver.has_app("com.acts.childprocessmanager") + if(is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager") + else: + pass + is_hap = self.driver.has_app("com.acts.childprocessmanager1") + if (is_hap): + self.driver.uninstall_app("com.acts.childprocessmanager1") + else: + pass + self.driver.install_app(hap1) + self.driver.install_app(hap2) + Step("步骤2:打开测试应用1") + self.driver.start_app("com.acts.childprocessmanager") + Step("步骤3:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤4:首次获取nativesapwn进程号") + pid1 = self.driver.System.get_pid("nativespawn") + Step("步骤5:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤6:第二次获取nativesapwn进程号") + pid2 = self.driver.System.get_pid("nativespawn") + Step("步骤7:打开测试应用2") + self.driver.start_app("com.acts.childprocessmanager1") + Step("步骤8:点击StartArk用例按钮") + self.driver.touch(BY.text("StartArk用例")) + Step("步骤9:点击start Native Process Isolated按钮") + self.driver.touch(BY.text("start Native Process Isolated")) + Step("步骤10:关闭测试应用1") + self.driver.stop_app("com.acts.childprocessmanager") + Step("步骤11:第三次获取nativesapwn进程号") + pid3 = self.driver.System.get_pid("nativespawn") + Step("步骤12:关闭测试应用1") + self.driver.stop_app("com.acts.childprocessmanager1") + Step("步骤13:第四次获取nativesapwn进程号") + pid4 = self.driver.System.get_pid("nativespawn") + Step("步骤12:预期结果校验") + self.driver.Assert.equal(pid1, None) + self.driver.Assert.not_equal(pid2, None) + self.driver.Assert.not_equal(pid3, None) + self.driver.Assert.equal(pid4, None) + + def teardown(self): + Step("收尾工作:卸载测试应用") + self.driver.uninstall_app("com.acts.childprocessmanager") + self.driver.uninstall_app("com.acts.childprocessmanager1") \ No newline at end of file