From 6d8c5d1b8fc9898c2e0d6dfc92a65f309a78f89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Fri, 18 Apr 2025 11:31:45 +0800 Subject: [PATCH] fix: add devicedebug autotest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- ..._STARTUP_APPSPAWN_SUPPLEMENTARY_0100.json} | 26 +-- ...SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.py | 54 +++++++ ..._STARTUP_APPSPAWN_SUPPLEMENTARY_0200.json} | 26 +-- ...SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.py | 59 +++++++ ...B_STARTUP_APPSPAWN_UBSANVARIABLE_0100.json | 13 ++ ...SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.py | 72 +++++++++ ...B_STARTUP_APPSPAWN_UBSANVARIABLE_0200.json | 13 ++ ...SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.py | 71 ++++++++ ...B_STARTUP_APPSPAWN_UBSANVARIABLE_0300.json | 13 ++ ...SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.py | 71 ++++++++ .../sub_startup_appspawn_cgroups_0100.json} | 26 +-- .../sub_startup_appspawn_cgroups_0100.py} | 150 ++++++++--------- .../sub_startup_appspawn_cgroups_0200.json} | 26 +-- .../sub_startup_appspawn_cgroups_0200.py} | 151 ++++++++--------- .../sub_startup_appspawn_cgroups_0300.json | 14 ++ .../sub_startup_appspawn_cgroups_0300.py} | 152 ++++++++---------- .../sub_startup_appspawn_coldstart_0100.json | 15 ++ .../sub_startup_appspawn_coldstart_0100.py | 54 +++++++ ...startup_appspawn_coldstartablity_0100.json | 15 ++ ...b_startup_appspawn_coldstartablity_0100.py | 58 +++++++ ...startup_appspawn_coldstartablity_0200.json | 15 ++ ...b_startup_appspawn_coldstartablity_0200.py | 58 +++++++ .../sub_startup_appspawn_devicedebug_0200.py | 84 ---------- .../sub_startup_appspawn_devicedebug_0300.py | 86 ---------- .../sub_startup_appspawn_devicedebug_0400.py | 88 ---------- ...sub_startup_appspawn_devicedebug_0500.json | 14 -- ...sub_startup_appspawn_devicedebug_0600.json | 14 -- .../sub_startup_appspawn_devicedebug_0600.py | 66 -------- ...sub_startup_appspawn_devicedebug_0700.json | 14 -- ...sub_startup_appspawn_devicedebug_0800.json | 14 -- .../sub_startup_appspawn_devicedebug_0800.py | 62 ------- ...sub_startup_appspawn_devicedebug_0900.json | 14 -- .../sub_startup_appspawn_devicedebug_0900.py | 61 ------- ...tartup_appspawn_selinuxlabelconf_1000.json | 14 ++ ..._startup_appspawn_selinuxlabelconf_1000.py | 52 ++++++ ...tartup_appspawn_selinuxlabelconf_1100.json | 14 ++ ..._startup_appspawn_selinuxlabelconf_1100.py | 50 ++++++ 37 files changed, 985 insertions(+), 814 deletions(-) rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json => SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.json} (67%) create mode 100644 test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.py rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json => SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.json} (67%) create mode 100644 test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.py create mode 100644 test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.json create mode 100644 test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.py create mode 100644 test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.json create mode 100644 test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.py create mode 100644 test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.json create mode 100644 test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.py rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json => sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json} (67%) rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py => sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py} (40%) rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json => sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json} (67%) rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py => sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py} (36%) create mode 100644 test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json rename test/autotest/{sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py => sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py} (36%) create mode 100644 test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json create mode 100644 test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json create mode 100644 test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json delete mode 100644 test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py create mode 100644 test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.json create mode 100644 test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py create mode 100644 test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.json create mode 100644 test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.py diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json b/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.json similarity index 67% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json rename to test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.json index b764571d..5a1ba3bb 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.json +++ b/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.json @@ -1,14 +1,14 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py" - ] - } +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.py" + ] + } } \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.py b/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.py new file mode 100644 index 00000000..96fc21df --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.py @@ -0,0 +1,54 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100.py +#文件说明: +#作 者: cWX1257337 +#生成日期: 2024-02-18 +#!!================================================================ +''' + +# -*- coding: utf-8 -*- +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import * + +from aw import Common + + +class SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0100(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("asan.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + Step("校验hap显示Hello World.................") + assert self.driver.find_component(BY.text("Hello World")) + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json b/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.json similarity index 67% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json rename to test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.json index e560671a..55e6bf6b 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.json +++ b/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.json @@ -1,14 +1,14 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py" - ] - } +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.py" + ] + } } \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.py b/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.py new file mode 100644 index 00000000..290d834c --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY/SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.py @@ -0,0 +1,59 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_0200.py +#文件说明: +#作 者: cWX1257337 +#生成日期: 2024-02-18 +#!!================================================================ +''' + +# -*- coding: utf-8 -*- +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import * + +from aw import Common + + +class SUB_STARTUP_APPSPAWN_SUPPLEMENTARY_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("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("sn.hap", "SUB_STARTUP_APPSPAWN_SUPPLEMENTARY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + Step("检查存在device info.................") + assert self.driver.find_component(BY.text("3333333", MatchPattern.CONTAINS)) + print("点击菜单device info.................") + self.driver.touch(BY.text(" device info ")) + sleep(1) + Step("校验serial为空.................") + assert self.driver.find_component(BY.text("serial: " + "\n" + " deviceType", MatchPattern.CONTAINS)) + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.json b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.json new file mode 100644 index 00000000..f97c4eb5 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.py b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.py new file mode 100644 index 00000000..cd00b88a --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.py @@ -0,0 +1,72 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100.py +#文件说明: UBSAN +#作 者: zwx1148735 +#生成日期: 2024-08-21 +#!!================================================================ +''' +import os + +# -*- coding: utf-8 -*- +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + +class SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0100(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D -D 0xC02C11") + self.driver.shell("hilog -b DEBUG -T APPSPAWN") + self.driver.shell("hilog -b D -D 0xDC02C11") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledTrueProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if(ishap): + self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledtrueprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + device_logger.check_log('SetAsanEnabledEnv 22,(null),(null),(null)') + device_logger.check_log('print_stacktrace=1:print_module_map=2:log_exe_name=1,(null)') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartenabledtrueprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.json b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.json new file mode 100644 index 00000000..46f9857d --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.py b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.py new file mode 100644 index 00000000..b509d9dd --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.py @@ -0,0 +1,71 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0200.py +#文件说明: 环境变量 +#作 者: zwx1148735 +#生成日期: 2024-08-21 +#!!================================================================ +''' +import os + +# -*- coding: utf-8 -*- +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class SUB_STARTUP_APPSPAWN_UBSANVARIABLE_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("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartEnabledFalseProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if (ishap): + self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartenabledfalseprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartenabledfalseprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.json b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.json new file mode 100644 index 00000000..a3a2f20e --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.json @@ -0,0 +1,13 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": ["SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.py"] + } +} \ No newline at end of file diff --git a/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.py b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.py new file mode 100644 index 00000000..7f205a25 --- /dev/null +++ b/test/autotest/SUB_STARTUP_APPSPAWN_UBSANVARIABLE/SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.py @@ -0,0 +1,71 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300.py +#文件说明: 环境变量 +#作 者: zwx1148735 +#生成日期: 2024-08-21 +#!!================================================================ +''' +import os + +# -*- coding: utf-8 -*- +from devicetest.core.test_case import TestCase, Step, CheckPoint +from devicetest.core.test_case import Step, TestCase +from hypium import * +from hypium.action.os_hypium.device_logger import DeviceLogger +from hypium.model import UiParam, WindowFilter +import time + + +class SUB_STARTUP_APPSPAWN_UBSANVARIABLE_0300(TestCase): + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + self.driver = UiDriver(self.device1) + Step("预置工作:检测屏幕是否亮.................") + self.driver.enable_auto_wakeup(self.device1) + Step("预置工作:滑动解锁.................") + self.driver.swipe(UiParam.UP, side=UiParam.BOTTOM) + Step('设置屏幕常亮') + self.driver.Screen.enable_stay_awake() + Step('开启DEBUG日志') + self.driver.shell("hilog -b D") + self.driver.shell("hilog -G 16M") + + def test_step1(self): + Step("步骤1:过滤关键日志") + device_logger = DeviceLogger(self.driver) + device_logger.set_filter_string("SetAsanEnabledEnv") + Step("步骤2:安装测试hap") + path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + hap = os.path.abspath(os.path.join(os.path.join(path, "testFile"), + "SUB_STARTUP_APPSPAWN_UBSANVARIABLE/ActsStartNoConfigEnabledProcessTest.hap")) + ishap = self.driver.has_app("com.example.actsstartenabledtrueprocesstest") + if (ishap): + self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") + else: + pass + self.driver.install_app(hap) + Step("步骤3:开始抓取日志") + device_logger.start_log(path + '\\testFile\\log\\%s.log' % (self.TAG)) + Step("步骤4:启动测试应用") + self.driver.shell("aa start -a EntryAbility -b com.example.actsstartnoconfigenabledprocesstest") + time.sleep(8) + Step("步骤4:关闭日志") + device_logger.stop_log() + time.sleep(2) + device_logger.check_not_exist_keyword('SetAsanEnabledEnv 22') + + def teardown(self): + Step("收尾工作:删除测试应用") + self.driver.uninstall_app("com.example.actsstartnoconfigenabledprocesstest") + self.driver.shell("hilog -b I") diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json similarity index 67% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json rename to test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json index cb9198c7..a235e5f5 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.json +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.json @@ -1,14 +1,14 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py" - ] - } +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_CGROUPS/SUB_STARTUP_APPSPAWN_CGROUPS_0100.py" + ] + } } \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py similarity index 40% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py rename to test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py index 6bc95411..3a14abb7 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0100.py @@ -1,81 +1,71 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0700(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.exe_sys_cmd" - hap_path = Common.sourcepath('debug_fork.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - self.driver.AppManager.start_app(bundle_name) - result01 = self.driver.shell("ps -ef|grep exe_sys_cmd|grep -v grep").split("\n") - childprocess_pid = result01[1].split()[1] - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - self.driver.shell("devicedebug kill -9 %s" % childprocess_pid) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("appspawn devicedebug get app info unsuccess, pid=%s" % childprocess_pid) - assert device_logger.check_log("devicedebug manager process exit. ret=218103837") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) +# -*- coding: utf-8 -*- +''' +#!!================================================================ +#版权 (C) 2024, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_CGROUPS_0100.py +#文件说明: +#作 者: lWX1283052 +#生成日期: 2024-05-11 +#!!================================================================ +''' +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * + +from aw import Common + +class SUB_STARTUP_APPSPAWN_CGROUPS_0100(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.shell("power-shell setmode 602") + + def process(self): + hap_path = Common.sourcepath('ForkTest1.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + global bundle_name + bundle_name = "com.example.exe_sys_cmd" + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef |grep %s" % bundle_name) + cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" %(bundle_name, pid)).split() + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 2: + count += 1 + self.driver.Assert.equal(count, 1) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.clear_app_data(bundle_name) self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json similarity index 67% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json rename to test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json index 9b0248bf..25d6f724 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.json +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.json @@ -1,14 +1,14 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py" - ] - } +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_CGROUPS/SUB_STARTUP_APPSPAWN_CGROUPS_0200.py" + ] + } } \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py similarity index 36% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py rename to test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py index f958bb79..f830af1a 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0100.py +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0200.py @@ -1,82 +1,69 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0100(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('release.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - self.driver.AppManager.start_app(bundle_name) - pid1 = self.driver.System.get_pid(bundle_name) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - self.driver.shell("devicedebug kill -9 %d" % pid1) - pid2 = self.driver.System.get_pid(bundle_name) - self.driver.Assert.equal(pid1, pid2) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid1) - assert device_logger.check_log("appspawn devicedebug process is not debuggable, pid=%d" % pid1) - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file +# -*- coding: utf-8 -*- +''' +#!!================================================================ +#版权 (C) 2024, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_CGROUPS_0200.py +#文件说明: +#作 者: lWX1283052 +#生成日期: 2024-05-21 +#!!================================================================ +''' +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * + +from aw import Common + +class SUB_STARTUP_APPSPAWN_CGROUPS_0200(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.shell("power-shell timeout -o 86400000") + + def process(self): + hap_path = Common.sourcepath('ForkTest2.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name = "com.example.exe_sys_cmd" + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef |grep %s" % bundle_name) + cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" %(bundle_name, pid)).split() + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 3: + count += 1 + self.driver.Assert.equal(count, 1) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.uninstall_app("com.example.exe_sys_cmd") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json new file mode 100644 index 00000000..49cef16f --- /dev/null +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_CGROUPS/SUB_STARTUP_APPSPAWN_CGROUPS_0300.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py similarity index 36% rename from test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py rename to test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py index a16ae9e2..495da1fa 100644 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py +++ b/test/autotest/sub_startup_appspawn_cgroups/sub_startup_appspawn_cgroups_0300.py @@ -1,83 +1,69 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0500(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - self.driver.AppManager.start_app(bundle_name) - pid1 = self.driver.System.get_pid(bundle_name) - self.driver.shell("devicedebug kill %d" % pid1) - pid2 = self.driver.System.get_pid(bundle_name) - self.driver.Assert.equal(pid1, pid2) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("devicedebug manager process start.") - assert device_logger.check_log("devicedebug cmd operator num is 3 < 4") - assert device_logger.check_log("devicedebug manager process exit. ret=18") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file +# -*- coding: utf-8 -*- +''' +#!!================================================================ +#版权 (C) 2024, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_CGROUPS_0300.py +#文件说明: +#作 者: lWX1283052 +#生成日期: 2024-05-21 +#!!================================================================ +''' +import time +from devicetest.core.test_case import TestCase, Step +from hypium import * + +from aw import Common + +class SUB_STARTUP_APPSPAWN_CGROUPS_0300(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step(self.devices[0].device_id) + global device + device = self.driver.shell("param get const.product.model") + device = device.replace("\n", "").replace(" ", "") + device = str(device) + Step(device) + # 解锁屏幕 + wake = self.driver.Screen.is_on() + time.sleep(0.5) + if wake: + self.driver.ScreenLock.unlock() + else: + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.shell("power-shell timeout -o 86400000") + + def process(self): + hap_path = Common.sourcepath('ForkTest3.hap', "SUB_STARTUP_APPSPAWN_CGROUPS") + bundle_name = "com.example.exe_sys_cmd" + hap = self.driver.AppManager.has_app(bundle_name) + if hap: + self.driver.AppManager.clear_app_data(bundle_name) + self.driver.AppManager.uninstall_app(bundle_name) + self.driver.AppManager.install_app(hap_path) + else: + self.driver.AppManager.install_app(hap_path) + self.driver.AppManager.start_app(bundle_name) + pid = self.driver.System.get_pid(bundle_name) + result1 = self.driver.shell("ps -ef |grep %s" % bundle_name) + cgroup1 = self.driver.shell("cat /dev/pids/100/%s/app_%d/cgroup.procs" %(bundle_name, pid)).split() + count = 0 + for i in cgroup1: + self.driver.Assert.contains(result1.split(), i) + if result1.count(i) == 2: + count += 1 + self.driver.Assert.equal(count, 2) + result2 = self.driver.shell("kill -9 %d" % pid) + self.driver.Assert.equal(result2, '') + result3 = self.driver.shell("ps -ef |grep %s|grep -v grep " % bundle_name) + self.driver.Assert.equal(result3, '') + + def teardown(self): + Step("收尾工作.................") + self.driver.AppManager.uninstall_app("com.example.exe_sys_cmd") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json new file mode 100644 index 00000000..68160522 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_COLDSTART/SUB_STARTUP_APPSPAWN_COLDSTART_0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py new file mode 100644 index 00000000..0109fdf8 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstart/sub_startup_appspawn_coldstart_0100.py @@ -0,0 +1,54 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_COLDSTART_0100.py +#文件说明: +#作 者: cWX1257337 +#生成日期: 2023-07-17 +#!!================================================================ +''' + +# -*- coding: utf-8 -*- +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import * + +class SUB_STARTUP_APPSPAWN_COLDSTART_0100(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + + def test_step1(self): + Step("设置冷启动全局参数.................") + result = self.driver.shell('param set startup.appspawn.cold.boot 1') + sleep(3) + if "Set parameter startup.appspawn.cold.boot 1 success" in result: + pass + else: + raise ValueError('设置冷启动全局参数失败!') + Step("通过命令启动日历.................") + result = self.driver.shell("aa start -C -d 123456 -a MainAbility -b com.huawei.hmos.calendar") + sleep(3) + self.driver.Assert.contains(result, "start ability successfully.", "通过命令启动日历失败!") + Step("检查日历冷启动进程.................") + result_ps = self.driver.shell("ps -ef|grep com.huawei.hmos.calendar") + result_ps = result_ps.split('\n')[0] + Step("日历进程信息如下:" + str(result_ps)) + assert '"' not in result_ps + + + def teardown(self): + Step("收尾工作.................") + pid = self.driver.System.get_pid('com.huawei.hmos.calendar') + self.driver.shell("kill -9 " + str(pid)) + diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json new file mode 100644 index 00000000..887bd70e --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY/SUB_STARTUP_APPSPAWN_COLDSTARTABLITY_0100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py new file mode 100644 index 00000000..92bf71db --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0100.py @@ -0,0 +1,58 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_COLDSTARTABLITY_0100.py +#文件说明: +#作 者: cWX1257337 +#生成日期: 2024-05-16 +#!!================================================================ +''' + +# -*- coding: utf-8 -*- +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import * + +from aw import Common + + +class SUB_STARTUP_APPSPAWN_COLDSTARTABLITY_0100(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("asan-enable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + pid = self.driver.System.get_pid('com.example.myapplication') + Step(pid) + Step("校验hap应用的maps.................") + result = self.driver.shell('cat /proc/' + str(pid) + '/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("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json new file mode 100644 index 00000000..80a3e1a5 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.json @@ -0,0 +1,15 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY/SUB_STARTUP_APPSPAWN_COLDSTARTABLITY_0200.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py new file mode 100644 index 00000000..c9858550 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_coldstartablity/sub_startup_appspawn_coldstartablity_0200.py @@ -0,0 +1,58 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_COLDSTARTABLITY_0200.py +#文件说明: +#作 者: cWX1257337 +#生成日期: 2024-05-16 +#!!================================================================ +''' + +# -*- coding: utf-8 -*- +from time import sleep +from devicetest.core.test_case import Step, TestCase +from hypium import * + +from aw import Common + + +class SUB_STARTUP_APPSPAWN_COLDSTARTABLITY_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.................") + sourpath = Common.sourcepath("asan-disable.hap", "SUB_STARTUP_APPSPAWN_COLDSTARTABLITY") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.wake_up() + self.driver.ScreenLock.unlock() + self.driver.Screen.enable_stay_awake() + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + sleep(3) + pid = self.driver.System.get_pid('com.example.myapplication') + Step(pid) + Step("校验hap应用的maps.................") + result = self.driver.shell('cat /proc/' + str(pid) + '/maps|grep libclang_rt.asan.so') + Step(result) + self.driver.Assert.equal(result, '') + + + def teardown(self): + Step("收尾工作.................") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py deleted file mode 100644 index 3c846505..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0200.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0200(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - self.driver.AppManager.start_app(bundle_name) - pid1 = self.driver.System.get_pid(bundle_name) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - self.driver.shell("devicedebug kill -9 %d" % pid1) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid1) - assert device_logger.check_log("appspawn devicedebug debugable=1, pid=%d, signal=9" % pid1) - assert device_logger.check_log("devicedebug manager process exit. ret=0") - self.driver.AppManager.start_app(bundle_name) - pid2 = self.driver.System.get_pid(bundle_name) - self.driver.Assert.not_equal(pid1, pid2) - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py deleted file mode 100644 index 9d1359d3..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0300.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - -SubStartupAppspawnDevicedebug0300(TestCase): - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - signal_lst = [1, 9, 11, 15, 64] - log_dict = {} - # 本地跑1-64的 但是由于太费时间,流水线跑signal_lst中这几个有代表性的就可以了 - for signal in signal_lst: # range(1, 65)替换signal_lst - self.driver.AppManager.start_app(bundle_name) - pid = self.driver.System.get_pid(bundle_name) - log_dict.update({signal: pid}) - self.driver.shell("devicedebug kill -%d %d" % (signal, pid)) - self.driver.AppManager.stop_app(bundle_name) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - for signal, pid in log_dict.items(): - assert device_logger.check_log("devicedebug cmd kill start signal[%d], pid[%d]" % (signal, pid)) - assert device_logger.check_log("appspawn devicedebug debugable=1, pid=%d, signal=%d" % (pid, signal)) - assert device_logger.check_log("devicedebug manager process exit. ret=0") - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py deleted file mode 100644 index 023bb122..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0400.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0400(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("安装测试hap并打开") - global bundle_name - bundle_name = "com.example.myapplication" - hap_path = Common.sourcepath('debug.hap', "sub_startup_appspawn_devicedebug") - hap = self.driver.AppManager.has_app(bundle_name) - if hap: - self.driver.AppManager.clear_app_data(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) - self.driver.AppManager.install_app(hap_path) - else: - self.driver.AppManager.install_app(hap_path) - - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - signal_lst = ["65", "0", "SIGKILL", "null", "undefined", "sigkill"] - for signal in signal_lst: - self.driver.AppManager.start_app(bundle_name) - pid1 = self.driver.System.get_pid(bundle_name) - self.driver.shell("devicedebug kill -%s %d" % (signal, pid1)) - pid2 = self.driver.System.get_pid(bundle_name) - self.driver.Assert.equal(pid1, pid2) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - for i in range(len(signal_lst)): - assert device_logger.check_log("devicedebug manager process start.") - assert device_logger.check_log("devicedebug manager process exit. ret=22") - assert device_logger.check_log("signal is 65 not in [1, 64]") - assert device_logger.check_log("signal is 0 not in [1, 64]", expect_match_times=len(signal_lst)-1) - - - def teardown(self): - Step("收尾工作.................") - self.driver.AppManager.stop_app(bundle_name) - self.driver.AppManager.uninstall_app(bundle_name) \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json deleted file mode 100644 index eff74779..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0500.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json deleted file mode 100644 index acbcf0b7..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py deleted file mode 100644 index 8446d1c5..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0600.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0600(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - Step("开启日志") - device_logger = DeviceLogger(self.driver).set_filter_string("C02C11") - log_name = 'LOG_' + os.path.basename(__file__).split('.')[0] - device_logger.start_log("testFile/sub_startup_appspawn_devicedebug/%s.txt" % log_name) - - Step("devicedebug发送kill信号") - pid = self.driver.System.get_pid("nwebspawn") - self.driver.shell("devicedebug kill -9 %d" % pid) - - Step("匹配日志") - device_logger.stop_log() - time.sleep(10) - assert device_logger.check_log("devicedebug cmd kill start signal[9], pid[%d]" % pid) - assert device_logger.check_log("appspawn devicedebug process is not debuggable, pid=%d" % pid) - assert device_logger.check_log("devicedebug manager process exit. ret=218103838") - - def teardown(self): - Step("收尾工作.................") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json deleted file mode 100644 index 2fc5b2e4..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0700.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json deleted file mode 100644 index aab5e2c2..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py deleted file mode 100644 index f37c3217..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0800.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0800(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - devicedebug_help_dict = [ - "devicedebug: 'aaa' is not a valid devicedebug command. See 'devicedebug help'.", - "usage: devicedebug ", - "These are common devicedebug commands list:", - " help list available commands", - " kill send a signal(1-64) to a process" - ] - result_dict = list(filter(lambda x: x != "\r", self.driver.shell("devicedebug aaa").split("\n"))) - result_dict = list(filter(None, result_dict)) - for result in result_dict: - self.driver.Assert.contains(devicedebug_help_dict, result.rstrip("\r")) - - def teardown(self): - Step("收尾工作.................") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json deleted file mode 100644 index 93b61870..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "description": "Config for OpenHarmony devicetest test cases", - "environment": [ - { - "type": "device" - } - ], - "driver": { - "type": "DeviceTest", - "py_file": [ - "sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py" - ] - } -} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py b/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py deleted file mode 100644 index f7d2d294..00000000 --- a/test/autotest/sub_startup_appspawn_devicedebug/sub_startup_appspawn_devicedebug_0900.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import time -from devicetest.core.test_case import TestCase, Step -from hypium import * -from hypium.action.os_hypium.device_logger import DeviceLogger -from aw import Common - - -SubStartupAppspawnDevicedebug0900(TestCase): - - def __init__(self, controllers): - self.tag = self.__class__.__name__ - TestCase.__init__(self, self.tag, controllers) - self.driver = UiDriver(self.device1) - - def setup(self): - Step(self.devices[0].device_id) - global device - device = self.driver.shell("param get const.product.model") - device = device.replace("\n", "").replace(" ", "") - device = str(device) - Step(device) - # 解锁屏幕 - wake = self.driver.Screen.is_on() - time.sleep(0.5) - if wake: - self.driver.ScreenLock.unlock() - else: - self.driver.Screen.wake_up() - self.driver.ScreenLock.unlock() - self.driver.Screen.enable_stay_awake() - - def process(self): - devicedebug_help_dict = [ - "usage: devicedebug ", - "These are common devicedebug commands list:", - " help list available commands", - " kill send a signal(1-64) to a process" - ] - result_dict = list(filter(lambda x: x != "\r", self.driver.shell("devicedebug help").split("\n"))) - result_dict = list(filter(None, result_dict)) - for result in result_dict: - self.driver.Assert.contains(devicedebug_help_dict, result.rstrip("\r")) - - def teardown(self): - Step("收尾工作.................") \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.json b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.json new file mode 100644 index 00000000..e70019a0 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_SELINUXLABELCONF/SUB_STARTUP_APPSPAWN_SELINUXLABELCONF_1000.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py new file mode 100644 index 00000000..aa74d391 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1000.py @@ -0,0 +1,52 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_SELINUXLABELCONF_1000.py +#文件说明: +#作 者: cWX1257337 +#生成日期: 2023-07-21 +#!!================================================================ +''' + +# -*- coding: utf-8 -*- +from time import sleep +from hypium import * +from devicetest.core.test_case import Step, TestCase +from aw import Common + +class SUB_STARTUP_APPSPAWN_SELINUXLABELCONF_1000(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("安装测试hap.................") + sourpath = Common.sourcepath("selinux.hap", "SUB_STARTUP_APPSPAWN_SELINUXLABELCONF") + Step(sourpath) + self.driver.AppManager.install_app(sourpath) + sleep(3) + + def test_step1(self): + Step("打开测试hap.................") + self.driver.start_app("com.example.myapplication", "EntryAbility") + result_el1 = self.driver.shell('ls -lZ /data/app/el1/100/base/ | grep com.example.myapplication') + Step(result_el1) + result_el2 = self.driver.shell('ls -lZ /data/app/el2/100/base/ | grep com.example.myapplication') + Step(result_el2) + self.driver.Assert.contains(result_el1, "hap_data_file", "安装非预置应用,对应标签为normal_hap") + self.driver.Assert.contains(result_el2, "hap_data_file", "安装非预置应用,对应标签为normal_hap") + + def teardown(self): + Step("TestCase: teardown") + Step("收尾工作:卸载hap......................") + self.driver.AppManager.clear_app_data('com.example.myapplication') + self.driver.AppManager.uninstall_app('com.example.myapplication') diff --git a/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.json b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.json new file mode 100644 index 00000000..2af6d26c --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.json @@ -0,0 +1,14 @@ +{ + "description": "Config for OpenHarmony devicetest test cases", + "environment": [ + { + "type": "device" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "SUB_STARTUP_APPSPAWN_SELINUXLABELCONF/SUB_STARTUP_APPSPAWN_SELINUXLABELCONF_1100.py" + ] + } +} \ No newline at end of file diff --git a/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.py b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.py new file mode 100644 index 00000000..9990ae31 --- /dev/null +++ b/test/autotest/sub_startup_appspawn_selinuxlabelconf/sub_startup_appspawn_selinuxlabelconf_1100.py @@ -0,0 +1,50 @@ +''' +#!!================================================================ +#版权 (C) 2022, Huawei Technologies Co., HUTAF xDevice +#================================================================== +#文 件 名: SUB_STARTUP_APPSPAWN_SELINUXLABELCONF_1100.py +#文件说明: +#作 者: cWX1257337 +#生成日期: 2023-07-21 +#!!================================================================ +''' + +# -*- coding: utf-8 -*- +from time import sleep +from hypium import * +from devicetest.core.test_case import Step, TestCase +from hypium.model import UiParam + + +class SUB_STARTUP_APPSPAWN_SELINUXLABELCONF_1100(TestCase): + + def __init__(self, controllers): + self.TAG = self.__class__.__name__ + self.tests = [ + "test_step1" + ] + TestCase.__init__(self, self.TAG, controllers) + self.driver = UiDriver(self.device1) + + def setup(self): + Step("TestCase: setup") + Step("预置工作:初始化手机开始.................") + Step(self.devices[0].device_id) + Step("预置工作:检测屏幕是否亮.................") + self.driver.Screen.enable_stay_awake() + self.driver.ScreenLock.unlock() + sleep(3) + + def test_step1(self): + Step("拉起设置........................................") + self.driver.start_app("com.huawei.hmos.settings", "com.huawei.hmos.settings.MainAbility") + result_el1 = self.driver.shell('ls -lZ /data/app/el1/100/base/ | grep permissionmanager') + Step(result_el1) + result_el2 = self.driver.shell('ls -lZ /data/app/el2/100/base/ | grep permissionmanager') + Step(result_el2) + self.driver.Assert.contains(result_el1, "permissionmanager_hap_data_file", "预置应用,对应标签为自定义的标签") + self.driver.Assert.contains(result_el2, "permissionmanager_hap_data_file", "预置应用,对应标签为自定义的标签") + + def teardown(self): + Step("TestCase: teardown") + self.driver.stop_app("com.huawei.hmos.settings") -- Gitee