1#!/usr/bin/env python3 2#-*- coding: utf-8 -*- 3 4# Copyright (c) 2024 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 time 18from devicetest.core.test_case import TestCase, CheckPoint, get_report_dir 19from hypium import UiDriver 20from hypium.action.os_hypium.device_logger import DeviceLogger 21from tools.get_source_path import get_source_path 22from tools.push_remove_source import push_source, remove_source 23 24 25class case21_add001(TestCase): 26 27 def __init__(self, configs): 28 self.TAG = self.__class__.__name__ 29 TestCase.__init__(self, self.TAG, configs) 30 self.tests = [ 31 "test_step" 32 ] 33 self.driver = UiDriver(self.device1) 34 self.sn = self.device1.device_sn 35 self.source_path = {} 36 37 def setup(self): 38 self.log.info("case21_add001 start") 39 need_source = {"cfg": True, "fwk": True, "listen_test": True, "audio_ability": True, "ondemand": True, 40 "proxy": True, "para": False} 41 self.source_path = get_source_path(need_source=need_source, casename="level0/case21_add001") 42 push_source(source_path=self.source_path, driver=self.driver, sn=self.sn) 43 44 def test_step(self): 45 driver = self.driver 46 driver.Screen.close() 47 time.sleep(20) 48 result = driver.System.execute_command("hidumper -ls") 49 max_wait_time = 5 50 wait_time = 0 51 while ("1494" in result and wait_time <= max_wait_time): 52 wait_time += 1 53 time.sleep(1) 54 result = driver.System.execute_command("hidumper -ls") 55 CheckPoint("Initially, 1494 was not loaded") 56 assert "1494" not in result 57 58 device_logger = DeviceLogger(driver).set_filter_string("01800") 59 device_logger.start_log(get_report_dir() + "//case21_add001.txt") 60 driver.System.execute_command("./system/bin/sa_main /system/profile/listen_test.json") 61 device_logger.stop_log() 62 device_logger.check_log("AddSystemProcessInner PERMISSION DENIED!", EXCEPTION=True) 63 64 result = driver.System.execute_command("hidumper -ls") 65 max_wait_time = 5 66 wait_time = 0 67 while ("1494" in result and wait_time <= max_wait_time): 68 wait_time += 1 69 time.sleep(1) 70 result = driver.System.execute_command("hidumper -ls") 71 CheckPoint("Non native process add intercepted, 1494 not loaded") 72 assert "1494" not in result 73 74 def teardown(self): 75 self.driver.Screen.close() 76 remove_source(source_path=self.source_path, driver=self.driver, sn=self.sn) 77 self.log.info("case21_add001 down") 78