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 sys 19 20current_dir = os.path.abspath(os.path.dirname(__file__)) 21rootPath = os.path.split(current_dir)[0] 22awPath = os.path.split(rootPath)[0] 23sys.path.append(rootPath) 24sys.path.append(os.path.join(awPath, "aw")) 25 26from devicetest.core.test_case import TestCase, CheckPoint 27from hypium import UiDriver 28from get_source_path import get_source_path 29from push_remove_source import push_source, remove_source 30 31 32class case23_process002(TestCase): 33 34 def __init__(self, configs): 35 self.TAG = self.__class__.__name__ 36 TestCase.__init__(self, self.TAG, configs) 37 self.tests = [ 38 "test_step" 39 ] 40 self.driver = UiDriver(self.device1) 41 self.sn = self.device1.device_sn 42 self.source_path = {} 43 44 def setup(self): 45 self.log.info("case23_process002 start") 46 need_source = {"cfg": False, "listen_test": False, "audio_ability": False, "ondemand": False, 47 "proxy": False, "para": False} 48 self.source_path = get_source_path(need_source=need_source, casename="level0/case23_process002") 49 push_source(source_path=self.source_path, driver=self.driver, sn=self.sn) 50 51 def test_step(self): 52 driver = self.driver 53 CheckPoint("Print death callback information") 54 result = driver.System.execute_command("ondemand proc initp") 55 assert "OnSystemProcessStopped, processName: media_service" in result 56 assert "OnSystemProcessStarted, processName: media_service" in result 57 target_str = 'OnSystemProcessStopped, processName: media_service' 58 count = result.count(target_str) 59 assert count == 1 60 target_str = 'OnSystemProcessStarted, processName: media_service' 61 count = result.count(target_str) 62 assert count == 1 63 64 def teardown(self): 65 remove_source(source_path=self.source_path, driver=self.driver, sn=self.sn) 66 self.log.info("case23_process002 down") 67