From 0d3d72be0d58a5152b6606502c760fa25fb8a8be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=98=89=E5=AE=9D?= Date: Thu, 26 Dec 2024 23:05:17 +0800 Subject: [PATCH] commit msg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄嘉宝 --- .../level1/lifecycle/lifecycle_state_001.py | 98 +++++++++++++++ .../level1/lifecycle/lifecycle_state_002.json | 17 ++- .../level1/lifecycle/lifecycle_state_002.py | 110 ++++++++++++++++- .../level1/lifecycle/lifecycle_state_003.json | 17 ++- .../level1/lifecycle/lifecycle_state_003.py | 112 ++++++++++++++++- .../level1/lifecycle/lifecycle_state_004.json | 17 ++- .../level1/lifecycle/lifecycle_state_004.py | 110 ++++++++++++++++- .../level1/lifecycle/lifecycle_state_005.json | 17 ++- .../level1/lifecycle/lifecycle_state_005.py | 111 ++++++++++++++++- .../level1/lifecycle/lifecycle_state_006.json | 17 ++- .../level1/lifecycle/lifecycle_state_006.py | 108 +++++++++++++++- .../level1/lifecycle/lifecycle_state_007.json | 17 ++- .../level1/lifecycle/lifecycle_state_007.py | 109 +++++++++++++++- .../level1/lifecycle/lifecycle_state_008.json | 17 ++- .../level1/lifecycle/lifecycle_state_008.py | 107 +++++++++++++++- .../level1/lifecycle/lifecycle_state_009.json | 17 ++- .../level1/lifecycle/lifecycle_state_009.py | 113 ++++++++++++++++- .../level1/lifecycle/lifecycle_state_010.json | 17 ++- .../level1/lifecycle/lifecycle_state_010.py | 116 +++++++++++++++++- 19 files changed, 1220 insertions(+), 27 deletions(-) diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_001.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_001.py index 40b08804..c944f2b5 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_001.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_001.py @@ -14,6 +14,104 @@ # 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, get_report_dir, ACTUAL +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger, AsyncCommand +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_001/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_001/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) +class LifeCycle_State_001(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + driver = self.driver + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + host.shell("hdc -t {} target mount".format(self.sn)) + driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "Scheduler SA" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 + # Hilog打印: [SA Scheduler][SA: 1494] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("Scheduler SA:1494") + device_logger.start_log(get_report_dir() + 'lifecycle_state_001_txt') + result = driver.System.execute_command("ondemand test 1") + assert "OnLoadSystemAbilitySuccesss systemAbilityId:1494" in result + # 停止日志 + device_logger.stop_log() + # 检查日志输出 + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + # self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + # self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_002.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_002.json index 67b186e5..c3436e69 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_002.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_002.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_002.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_002.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_002.py index 68bc19fc..f232d452 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_002.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_002.py @@ -12,4 +12,112 @@ # 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. \ No newline at end of file +# limitations under the License. + +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger, AsyncCommand +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_002/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_002/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) + +class LifeCycle_State_002(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + driver = self.driver + # 清理日志 + driver.shell('hilog -r') + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + # host.shell("hdc -t {} target mount".format(self.sn)) + # driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + # host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + # host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + # driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 + # Hilog打印: [SA Scheduler][SA: 1494] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("Scheduler SA:1494") + device_logger.start_log(get_report_dir() + 'lifecycle_state_002_txt') + result = driver.System.execute_command("ondemand test 2") + assert "OnLoadSystemAbilitySuccesss systemAbilityId:1494" in result + # 停止日志 + device_logger.stop_log() + # 检查日志输出 + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + + def teardown(self): + # self.driver.System.execute_command("kill -9 `pidof listen_test`") + # self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + # self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_003.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_003.json index 67b186e5..8a5d5d03 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_003.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_003.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_003.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_003.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_003.py index 68bc19fc..c54f6c95 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_003.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_003.py @@ -12,4 +12,114 @@ # 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. \ No newline at end of file +# limitations under the License. + +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger, AsyncCommand +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_003/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_003/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) + +class LifeCycle_State_003(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + driver = self.driver + # 清理日志 + driver.shell('hilog -r') + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + # host.shell("hdc -t {} target mount".format(self.sn)) + # driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + # host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + # host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + # driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 + # Hilog打印: + # [SA Scheduler][SA: 1494] remove pending unload event + # [SA Scheduler][SA: 1494] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("Scheduler SA:1494") + device_logger.start_log(get_report_dir() + 'lifecycle_state_003_txt') + result = driver.System.execute_command("ondemand test 3") + assert "OnLoadSystemAbilitySuccesss systemAbilityId:1494" in result + # 停止日志 + device_logger.stop_log() + # 检查日志输出 + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + # self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + # self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_004.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_004.json index 67b186e5..eee728d9 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_004.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_004.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_004.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_004.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_004.py index 68bc19fc..de607dfd 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_004.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_004.py @@ -12,4 +12,112 @@ # 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. \ No newline at end of file +# limitations under the License. + +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger, AsyncCommand +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_004/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_004/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) + +class LifeCycle_State_004(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + driver = self.driver + # 清理日志 + driver.shell('hilog -r') + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + host.shell("hdc -t {} target mount".format(self.sn)) + driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 + # Hilog打印: [SA Scheduler][SA: 1494] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("Scheduler SA:1494") + device_logger.start_log(get_report_dir() + 'lifecycle_state_004_txt') + result = driver.System.execute_command("ondemand test 4") + assert "OnLoadSystemAbilitySuccesss systemAbilityId:1494" in result + # 停止日志 + device_logger.stop_log() + # 检查日志输出 + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + # self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + # self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_005.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_005.json index 67b186e5..820d3e24 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_005.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_005.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_005.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_005.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_005.py index 68bc19fc..eeacd655 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_005.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_005.py @@ -12,4 +12,113 @@ # 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. \ No newline at end of file +# limitations under the License. + +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_005/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_005/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) + +class LifeCycle_State_005(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + # driver = self.driver + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + # host.shell("hdc -t {} target mount".format(self.sn)) + # driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + # host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + # host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + # driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 + # Hilog打印: + # [SA Scheduler][SA: 1494] remove pending unload event + # [SA Scheduler][SA: 1494] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("Scheduler SA:1494") + device_logger.start_log(get_report_dir() + 'lifecycle_state_005_txt') + result = driver.System.execute_command("ondemand test 5") + assert "OnLoadSystemAbilitySuccesss systemAbilityId:1494" in result + # 停止日志 + device_logger.stop_log() + # 检查日志输出 + device_logger.check_log("Scheduler SA:1494 unloadable", EXCEPTION=True) + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + # self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + # self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_006.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_006.json index 67b186e5..100b3027 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_006.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_006.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_006.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_006.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_006.py index 4c677816..0c220736 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_006.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_006.py @@ -14,4 +14,110 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os \ No newline at end of file +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_006/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_006/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) + +class LifeCycle_State_006(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + # driver = self.driver + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + # host.shell("hdc -t {} target mount".format(self.sn)) + # driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + # host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + # host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + # driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 + # Hilog打印: + # [SA Scheduler][SA: 1494] save load event + # [SA Scheduler][process: listen_test] stopped + # [SA Scheduler][SA: 1494] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("I C018") + device_logger.start_log(get_report_dir() + 'lifecycle_state_006_txt') + result = driver.System.execute_command("ondemand test 6") + assert "OnLoadSystemAbilitySuccesss systemAbilityId:1494" in result + # 停止日志 + device_logger.stop_log() + # 检查日志输出 + device_logger.check_log("Scheduler SA:1494 save load event", EXCEPTION=True) + device_logger.check_log("Scheduler proc:listen_test stopped", EXCEPTION=True) + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + # self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + # self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_007.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_007.json index 67b186e5..9314daf2 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_007.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_007.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_007.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_007.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_007.py index 4c677816..73f8cf0b 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_007.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_007.py @@ -14,4 +14,111 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os \ No newline at end of file +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_007/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_007/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) + +class LifeCycle_State_007(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + driver = self.driver + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + host.shell("hdc -t {} target mount".format(self.sn)) + driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 + # Hilog打印: + # [SA Scheduler][SA: 1494] save load event + # [SA Scheduler][process: listen_test] stopped + # [SA Scheduler][SA: 1497] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("I C018") + device_logger.start_log(get_report_dir() + '//lifecycle_state_007_txt') + # 通过ondemand手动加载sa + driver.System.execute_command("ondemand test") + time.sleep(20) + # 停止日志 + device_logger.stop_log() + # 断言 + log_check_result = device_logger.check_log("Scheduler SA:1494 save load event", EXCEPTION=True) + log_check_result = device_logger.check_log("Scheduler proc:listen_test stopped", EXCEPTION=True) + log_check_result = device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_008.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_008.json index 67b186e5..c5338ddc 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_008.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_008.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_008.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_008.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_008.py index 4c677816..5065b719 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_008.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_008.py @@ -14,4 +14,109 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os \ No newline at end of file +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger, AsyncCommand +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_008/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_008/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) + +class LifeCycle_State_008(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + driver = self.driver + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + # host.shell("hdc -t {} target mount".format(self.sn)) + # driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + # host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + # host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + # driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + # host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + # driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 + # Hilog打印: + # [SA Scheduler][SA: 1494] save load event + # [SA Scheduler][process: listen_test] stopped + # [SA Scheduler][SA: 1497] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("I C018") + device_logger.start_log(get_report_dir() + '//lifecycle_state_008_txt') + result = driver.System.execute_command("ondemand test 8") + assert "OnLoadSystemAbilitySuccesss systemAbilityId:1494" in result + # 停止日志 + device_logger.stop_log() + # 检查日志输出 + device_logger.check_log("Scheduler SA:1499 handle load failed event", EXCEPTION=True) + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + # self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + # self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + # self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + # self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_009.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_009.json index 67b186e5..95a1978d 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_009.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_009.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_009.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_009.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_009.py index 4c677816..fce5ff72 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_009.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_009.py @@ -14,4 +14,115 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os \ No newline at end of file +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger, AsyncCommand +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_009/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_009/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) + +class LifeCycle_State_009(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + driver = self.driver + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + host.shell("hdc -t {} target mount".format(self.sn)) + driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 打印五次 + # Hilog打印: + # [SA Scheduler][SA: 1494] save load event + # [SA Scheduler][SA: 1494] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("Scheduler SA:1494") + device_logger.start_log(get_report_dir() + '//lifecycle_state_009_txt') + result = driver.System.execute_command("ondemand test 9") + # 统计控制台字符串出现次数 + countWindowResult = result.count("OnLoadSystemAbilitySuccesss systemAbilityId:1494") + assert countWindowResult == 5 + # 停止日志 + device_logger.stop_log() + # 检查日志输出 + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + device_logger.check_log("Scheduler SA:1494 not loaded", EXCEPTION=True) + + log_check_result1 = device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + Assert.equal(self, log_check_result1, True) + log_check_result2 = device_logger.check_log("Scheduler SA:1494 save load event", EXCEPTION=True) + Assert.equal(self, log_check_result2, True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_010.json b/test/autotest/testcases/level1/lifecycle/lifecycle_state_010.json index 67b186e5..f9fe11d6 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_010.json +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_010.json @@ -1,3 +1,16 @@ { - "description": "hypium自测试用例" -} \ No newline at end of file + "description": "hypium自测试用例", + "environment": [ + { + "type": "device", + "label": "phone" + } + ], + "driver": { + "type": "DeviceTest", + "py_file": [ + "testcases/level1/lifecycle/lifecycle_state_010.py" + ] + }, + "kits":[] + } \ No newline at end of file diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_010.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_010.py index 4c677816..34d53b2b 100644 --- a/test/autotest/testcases/level1/lifecycle/lifecycle_state_010.py +++ b/test/autotest/testcases/level1/lifecycle/lifecycle_state_010.py @@ -14,4 +14,118 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os \ No newline at end of file +import os +import time + +from devicetest.core.test_case import TestCase, get_report_dir +from hypium import UiExplorer +from hypium.action.host import host +from hypium.action.os_hypium.checker import Assert +from hypium.action.os_hypium.device_logger import DeviceLogger, AsyncCommand +from devicetest.utils.file_util import get_resource_path + +sa_lib_test_path = get_resource_path( + "resource/SO_RESOURCE/liblisten_test.z.so", + isdir=None) +sa_lib_ability_c_path = get_resource_path( + "resource/SO_RESOURCE/libtest_audio_ability.z.so", + isdir=None) +sa_proxy_path = get_resource_path( + "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so", + isdir=None) +sa_listen_cfg_path = get_resource_path( + "resource/level/lifecycle_state_010/listen_test.cfg", + isdir=None) +sa_listen_json_path = get_resource_path( + "resource/level/lifecycle_state_010/listen_test.json", + isdir=None) +sa_ondemand_path = get_resource_path( + "resource/SO_RESOURCE/ondemand", + isdir=None) +sa_tool_path = get_resource_path( + "resource/SO_RESOURCE/TestTool", + isdir=None) + +class LifeCycle_State_010(TestCase): + + def __init__(self, controllers): + sele.TAG = self.__class__.__name__ + TestCase.__init__(self, self.TAG, controllers) + self.tests = [ + "test_step" + ] + self.driver = UiExplore(self.driver1) + self.sn = self.driver1.device_sn + + def setup(self): + driver = self.driver + host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn)) + host.shell("hdc -t {} target mount".format(self.sn)) + driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/") + host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/") + host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn)) + + driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/") + host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn)) + + driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn)) + + driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/") + host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn)) + driver.System.reboot() + + def test_step(self): + driver = self.driver + # 用例步骤 + # 1、执行push_bat脚本, 推入测试资源 + # 2、执行"hdc shell"命令, 进入shell命令行 + # 3、执行"ondemand"命令, 执行测试程序 + # 4、输入"ondemand", 进入测试模式 + # 5、输入任意字符后回车, 开始执行test case + # 6、再打开一个cmd用来查看hilog, 执行hilog | grep "SA Scheduler" + # 预期结果 + # 控制台打印: OnLoadSystemAbilitySuccesss systemAbilityId:1494 打印五次 + # Hilog打印: + # [SA Scheduler][SA: 1494] loaded + #清理日志 + driver.shell('hilog -r') + # 开始保存日志 + device_logger = DeviceLogger(driver).set_filter_string("Scheduler SA:1494") + device_logger.start_log(get_report_dir() + '//lifecycle_state_010_txt') + log_path = os.path.join(self.get_case_report_path(), "lifecycle_state_010_txt") + command = AsyncCommand(driver).set_output_file(log_path) + command.start_device_command("ondemand test") + time.sleep(130) + # 停止后台命令 + command.stop() + # 停止日志 + device_logger.stop_log() + # 断言 + # 检查日志输出 + countResult = Disk_drop_log.count_keys_disk_dropping_logs(self.get_case_report_path(), + "OnLoadSystemAbilitySuccesss systemAbilityId:1494") + assert countResult >= 23 + device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + device_logger.check_log("Scheduler SA:1494 not loaded", EXCEPTION=True) + + log_check_result = device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True) + Assert.equal(self, log_check_result1, True) + + def teardown(self): + self.driver.System.execute_command("kill -9 `pidof listen_test`") + self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so") + self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so") + self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so") + self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg") + self.driver.Storage.remove_file("/system/etc/init/listen_test.json") + self.driver.Storage.remove_file("/system/bin/ondemand") + self.log.info("done") -- Gitee