diff --git a/test/autotest/testcases/level1/lifecycle/lifecycle_state_001.py b/test/autotest/testcases/level1/lifecycle/lifecycle_state_001.py index 40b0880492081eca02e61f95162dc3119dbdf62f..c944f2b5dd82235138351e7b9ab43f0911cfd9f3 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..c3436e69fd627ea78b4597bf50aaffd4942846c8 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 68bc19fc93e4e1b543d6ddf7af0861bb3678a787..f232d452d2cb86d2e82affc00946dc2c115ad270 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..8a5d5d03fd13ad5889c4ff5244c89337d9d5f9f7 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 68bc19fc93e4e1b543d6ddf7af0861bb3678a787..c54f6c951ee13efdc97350ca67c32d2597c42d66 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..eee728d9cfec02f18f045d47975e81e905851071 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 68bc19fc93e4e1b543d6ddf7af0861bb3678a787..de607dfd2fdcb07af09622ce2a43ce5d22103a99 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..820d3e241ff427d9f25dcff1b4d51a26e0f6a6c7 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 68bc19fc93e4e1b543d6ddf7af0861bb3678a787..eeacd655d643017e816e487df70f311ae583680b 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..100b3027920982ce187702e69f56a40983938cb4 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 4c677816309a3d588bc49ae8fb519b0d3a9232b8..0c220736f5e3e1c950a05c57451e323b101c4420 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..9314daf249e1e20f673b4c59db18f706d553bd2b 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 4c677816309a3d588bc49ae8fb519b0d3a9232b8..73f8cf0b3c9babf2c83362e3c9a26461cb846a96 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..c5338ddc3be25e532b1bff6f55115f2663b9fdab 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 4c677816309a3d588bc49ae8fb519b0d3a9232b8..5065b7199b55f006d6fe4296bf7da8de4c3fa48e 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..95a1978d0fd6cbaa79c97f54b77dfc9d40e4a291 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 4c677816309a3d588bc49ae8fb519b0d3a9232b8..fce5ff724f362d4c7f9764703d14316ea1ee2744 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 67b186e59bd9a2fe8ea209d01ba73906efe43128..f9fe11d66bd7049b7b6f7850e8a08adede5eb2f0 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 4c677816309a3d588bc49ae8fb519b0d3a9232b8..34d53b2b971b0abd20aea7873afa8e498fcfa71e 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")