diff --git a/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0100.json b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0100.json new file mode 100644 index 0000000000000000000000000000000000000000..b408aca07a98c4d960e2a534a048e75a1ae24564 --- /dev/null +++ b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "test/autotest/SUB_STARTUP_APPSPAWN_CGROUPS/SubStartupAppspawnCgroup0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0100.py b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0100.py new file mode 100644 index 0000000000000000000000000000000000000000..0b69b20d797a431727d74c7a3d6c0c6148a6694f --- /dev/null +++ b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0100.py @@ -0,0 +1,74 @@ +# 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 time +from devicetest.core.test_case import TestCase, Step +from hypium import UiDriver + +from aw import Common + + +class SubStartupAppspawnCgroup0100(TestCase): + + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + #解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.shell("power-shell setmdoe 602") + + def process(self): + hap_path = Common.sourcepath('ForkTest1.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name = "com.example.exe_sys_cmd" + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(bundle_name) + else: + self.driver.AppManager.install_app(bundle_name) + self.driver.AppManager.start_app(bundle_name) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef |grep %s" % bundle_name) + cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" % (bundle_name, pid)).split() + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 2: + count += 1 + self.driver.Assert.equal(count, 1) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作...") + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0200.json b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0200.json new file mode 100644 index 0000000000000000000000000000000000000000..9c955111b01686b98e6fc63b575d6babc1697423 --- /dev/null +++ b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "test/autotest/SUB_STARTUP_APPSPAWN_CGROUPS/SubStartupAppspawnCgroup0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0200.py b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0200.py new file mode 100644 index 0000000000000000000000000000000000000000..2e1efc1052f42f29ca164f9a3d12603b8a1626cd --- /dev/null +++ b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0200.py @@ -0,0 +1,73 @@ +# 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 time +from devicetest.core.test_case import TestCase, Step +from hypium import UiDriver + +from aw import Common + + +class SubStartupAppspawnCgroup0200(TestCase): + + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + #解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.shell("power-shell timeout -o 86400000") + + def process(self): + hap_path = Common.sourcepath('ForkTest2.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name = "com.example.exe_sys_cmd" + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(bundle_name) + else: + self.driver.AppManager.install_app(bundle_name) + self.driver.AppManager.start_app(bundle_name) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef |grep %s" % bundle_name) + cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" % (bundle_name, pid)).split() + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 3: + count += 1 + self.driver.Assert.equal(count, 1) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作...") + self.driver.AppManager.clear_app_data("com.example.exe_sys_cmd") diff --git a/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0300.json b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0300.json new file mode 100644 index 0000000000000000000000000000000000000000..9f598ad93423e8208ae3e62bef65d3b431ea188e --- /dev/null +++ b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "test/autotest/SUB_STARTUP_APPSPAWN_CGROUPS/SubStartupAppspawnCgroup0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0300.py b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0300.py new file mode 100644 index 0000000000000000000000000000000000000000..21b0e96027e90075db93d994c97f67d7f9a5a696 --- /dev/null +++ b/test/autotest/subStartupAppspawnCgroup/sub_startup_appspawn_cgroup_0300.py @@ -0,0 +1,73 @@ +# 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 time +from devicetest.core.test_case import TestCase, Step +from hypium import UiDriver + +from aw import Common + + +class SubStartupAppspawnCgroup0300(TestCase): + + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + #解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.shell("power-shell timeout -o 86400000") + + def process(self): + hap_path = Common.sourcepath('ForkTest3.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name = "com.example.exe_sys_cmd" + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(bundle_name) + else: + self.driver.AppManager.install_app(bundle_name) + self.driver.AppManager.start_app(bundle_name) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef |grep %s" % bundle_name) + cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" % (bundle_name, pid)).split() + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 2: + count += 1 + self.driver.Assert.equal(count, 2) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作...") + self.driver.AppManager.clear_app_data("com.example.exe_sys_cmd") diff --git a/test/autotest/subStartupAppspawnColdstart/sub_startup_appspawn_coldstart_0100.json b/test/autotest/subStartupAppspawnColdstart/sub_startup_appspawn_coldstart_0100.json new file mode 100644 index 0000000000000000000000000000000000000000..cc1ab0491375b036967079f9f597b5623ec02e65 --- /dev/null +++ b/test/autotest/subStartupAppspawnColdstart/sub_startup_appspawn_coldstart_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "test/autotest/SUB_STARTUP_APPSPAWN_CGROUPS/SubStartupAppspawnColdstart0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnColdstart/sub_startup_appspawn_coldstart_0100.py b/test/autotest/subStartupAppspawnColdstart/sub_startup_appspawn_coldstart_0100.py new file mode 100644 index 0000000000000000000000000000000000000000..b20c065b8ee647191dc9a2c5979699102079618f --- /dev/null +++ b/test/autotest/subStartupAppspawnColdstart/sub_startup_appspawn_coldstart_0100.py @@ -0,0 +1,52 @@ +# 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 time +from devicetest.core.test_case import TestCase, Step +from hypium import UiDriver + +from aw import Common + + +class SubStartupAppspawnColdstart0100(TestCase): + + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def test_step1(self): + Step("设置冷启动全局参...............") + result = self.driver.shell('param set startup.appspawn.cold.boot 1') + sleep(3) + if "Set paramter startup.appspawn.cold.boot 1 success" in result: + pass + else: + raise ValueError('设置冷启动全局参数失败') + Step("通过命令启动日历...........") + result = self.driver.shell('aa start -C -d 123456 -a MainAbility -b com.example.calendar') + sleep(3) + self.driver.Assert.contains(result, "start ability successfully", "通过命令启动日历失败") + Step("检查日历冷启动进程............") + result_ps = self.driver.shell("ps -ef|grep com.example.calendar") + result_ps = result_ps.split('\n')[0] + Step("日历进程信息如下:" + str(result_ps)) + + def teardown(self): + Step("收尾工作...") + pid = self.driver.System.get_pid('com.example.calendar') + self.driver.shell('kill -9 %d' % pid) \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0100.json b/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0100.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9e96345178c6657b14c1bc80d6aa09a5eb4474 --- /dev/null +++ b/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "test/autotest/SUB_STARTUP_APPSPAWN_CGROUPS/SubStartupAppspawnColdstartAblity0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0100.py b/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0100.py new file mode 100644 index 0000000000000000000000000000000000000000..b1763276470615c8db493b85f48172fcf34e7ca0 --- /dev/null +++ b/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0100.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 time +from devicetest.core.test_case import TestCase, Step +from hypium import UiDriver + +from aw import Common + + +class SubStartupAppspawnColdstartAblity0100(TestCase): + + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作开始") + Step(self.devices[0].device_id) + Step("安装测试hap") + sourcepath = Common.sourcepath("asan-enable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") + Step(sourcepath) + self.driver.AppManager.install_app(sourcepath) + Step("预置工作:检查屏幕") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap...............") + result = self.driver.startup_app("com.example.myapplication", "EntryAbility") + sleep(3) + pid = self.driver.System.get_pid('com.example.myapplication') + Step(pid) + Step("校验") + result = self.driver.shell('cat /proc/self/maps|grep libclang_rt.asan.so') + Step(result) + self.driver.Assert.contains(result, '/system/lib64/libclang_rt.asan.so') + self.driver.Assert.contains(result, 'anon:libclang_rt.asan.so.bss') + + def teardown(self): + Step("收尾工作...") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0200.json b/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0200.json new file mode 100644 index 0000000000000000000000000000000000000000..99782006f9b3512e1807e0e6435316995123af47 --- /dev/null +++ b/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0200.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "test/autotest/SUB_STARTUP_APPSPAWN_CGROUPS/SubStartupAppspawnColdstartAblity0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0200.py b/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0200.py new file mode 100644 index 0000000000000000000000000000000000000000..3fb55ad8ccd6cc5467bef647638bda9409e4ed74 --- /dev/null +++ b/test/autotest/subStartupAppspawnColdstartAblity/sub_startup_appspawn_coldstart_ablity_0200.py @@ -0,0 +1,58 @@ +# 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 time +from devicetest.core.test_case import TestCase, Step +from hypium import UiDriver + +from aw import Common + + +class sub_startup_appspawn_coldstart_ablity_0200(TestCase): + + + def __init__(self, controllers): + self.tag = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.tag, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作开始") + Step(self.devices[0].device_id) + Step("安装测试hap") + sourcepath = Common.sourcepath("asan-enable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") + Step(sourcepath) + self.driver.AppManager.install_app(sourcepath) + Step("预置工作:检查屏幕") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap...............") + result = self.driver.startup_app("com.example.myapplication", "EntryAbility") + sleep(3) + pid = self.driver.System.get_pid('com.example.myapplication') + Step(pid) + Step("校验") + result = self.driver.shell('cat /proc/self/maps|grep libclang_rt.asan.so') + Step(result) + self.driver.Assert.contains(result, '') + + def teardown(self): + Step("收尾工作...") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication')