• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#-*- coding: utf-8 -*-
3
4# Copyright (c) 2025 Huawei Device Co., Ltd.
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17import os
18import time
19
20from devicetest.core.test_case import TestCase, get_report_dir
21from hypium import UiExplore
22from hypium.action.host import host
23
24from hypium.action.os_hypium.checker import Assert
25from hypium.action.os_hypium.device_logger import DeviceLogger, AsyncCommand
26from devicetest.utils.file.file_util import get_resource_path
27
28
29sa_lib_test_path = get_resource_path(
30    "resource/SO_RESOURCE/liblisten_test.z.so",
31    isdir=None)
32
33sa_lib_ability_c_path = get_resource_path(
34    "resource/SO_RESOURCE/libtest_audio_ability.z.so",
35    isdir=None)
36
37sa_proxy_path = get_resource_path(
38    "resource/SO_RESOURCE/libtest_sa_proxy_cache.z.so",
39    isdir=None)
40
41sa_listen_cfg_path = get_resource_path(
42    "resource/level/lifecycle_state_022/listen_test.cfg",
43    isdir=None)
44
45sa_listen_json_path = get_resource_path(
46    "resource/level/lifecycle_state_022/listen_test.json",
47    isdir=None)
48
49sa_ondemand_path = get_resource_path(
50    "resource/SO_RESOURCE/ondemand",
51    isdir=None)
52
53sa_tool_path = get_resource_path(
54    "resource/SO_RESOURCE/TestTool",
55    isdir=None)
56
57
58class LifeCycle_State_022(TestCase):
59
60    def __init__(self, controllers):
61        sele.TAG = self.__class__.__name__
62        TestCase.__init__(self, self.TAG, controllers)
63        self.tests = [
64            "test_step"
65        ]
66        self.driver = UiExplore(self.driver1)
67        self.sn = self.driver1.device_sn
68
69    def setup(self):
70        driver = self.driver
71        host.shell("hdc -t {} shell kill -9 `pidof listen_test`".format(self.sn))
72        # host.shell("hdc -t {} target mount".format(self.sn))
73        # driver.Storage.push_file(local_path=sa_lib_test_path, device_path="/systemlib/lib/")
74        # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/liblisten_test.z.so".format(self.sn))
75
76        # driver.Storage.push_file(local_path=sa_proxy_path, device_path="/systemlib/lib/")
77        # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_sa_proxy_cache.z.so".format(self.sn))
78
79        # driver.Storage.push_file(local_path=sa_lib_ability_c_path, device_path="/systemlib/lib/")
80        # host.shell("hdc -t {} shell chmod 644 /system/lib/lib/libtest_audio_ability.z.so".format(self.sn))
81
82        # driver.Storage.push_file(local_path=sa_listen_cfg_path, device_path="/system/etc/init/")
83        # host.shell("hdc -t {} shell chmod 644 /system/etc/init/listen_test.cfg".format(self.sn))
84
85        # driver.Storage.push_file(local_path=sa_listen_json_path, device_path="/system/profile/")
86        # host.shell("hdc -t {} shell chmod 644 /system/profile/listen_test.json".format(self.sn))
87
88        # driver.Storage.push_file(local_path=sa_ondemand_path, device_path="/systemlib/bin/")
89        # host.shell("hdc -t {} shell chmod 755 /system/bin/ondemand".format(self.sn))
90
91        # driver.Storage.push_file(local_path=sa_tool_path, device_path="/systemlib/bin/")
92        # host.shell("hdc -t {} shell chmod 755 /system/bin/TestTool".format(self.sn))
93        # driver.System.reboot()
94
95    def test_step(self):
96        driver = self.driver
97        # 用例同步
98        # 执行"ondemand test 24"命令, 执行测试程序
99        # 预期结果
100        # 控制台打印:
101        # GetSystemAbility result: success
102        driver.shell('hilog -r')
103        # 开始保存日志
104        device_logger = DeviceLogger(driver).set_filter_string("Scheduler SA:1494")
105        device_logger.start_log(get_report_dir() + 'lifecycle_state_022_txt')
106        result = driver.System.execute_command("ondemand test 22")
107        assert "GetSystemAbility systemAbilityId:1494 faild" in result
108        # 停止日志
109        device_logger.stop_log()
110        # 检查日志输出
111        device_logger.check_log("Scheduler SA:1494 loaded", EXCEPTION=True)
112
113    def teardown(self):
114        self.driver.System.execute_command("kill -9 `pidof listen_test`")
115        #self.driver.Storage.remove_file("/system/lib/lib/liblisten_test.z.so")
116        #self.driver.Storage.remove_file("/system/lib/lib/libtest_sa_proxy_cache.z.so")
117        #self.driver.Storage.remove_file("/system/lib/lib/libtest_audio_ability.z.so")
118        #self.driver.Storage.remove_file("/system/etc/init/listen_test.cfg")
119        #self.driver.Storage.remove_file("/system/etc/init/listen_test.json")
120        #self.driver.Storage.remove_file("/system/bin/ondemand")
121        self.log.info("done")
122
123
124
125
126