1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# Copyright (C) 2024 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16import pytest 17import re 18from utils import * 19 20def CheckSAList(output): 21 ret = "System ability list:" in output 22 return ret 23 24def CheckSAHelp(output): 25 result1 = re.search(r"-+HiviewService-+\n([^\n]+){4,}", output) 26 result2 = re.search(r"-+HiDumperService-+", output, re.DOTALL) 27 ret = all([result1, result2]) 28 return ret 29 30def CheckSAInterface(output): 31 result = re.search(r"-+WindowManagerService-+\n([^\n]+){4,}", output) 32 return result is not None 33 34class TestHidumperSA: 35 36 @pytest.mark.L0 37 def test_sa_ls(self): 38 command = "hidumper -ls" 39 # 校验命令行输出 40 CheckCmd(command, CheckSAList) 41 # 校验命令行重定向输出 42 CheckCmdRedirect(command, CheckSAList) 43 # 校验命令行输出到zip文件 44 CheckCmdZip(command, CheckSAList) 45 46 @pytest.mark.L0 47 def test_sa_help(self): 48 command = "hidumper -s 1201 1212" 49 # 校验命令行输出 50 CheckCmd(command, CheckSAHelp) 51 # 校验命令行重定向输出 52 CheckCmdRedirect(command, CheckSAHelp) 53 # 校验命令行输出到zip文件 54 CheckCmdZip(command, CheckSAHelp) 55 56 @pytest.mark.L0 57 def test_sa_interface(self): 58 command = "hidumper -s WindowManagerService -a -h" 59 # 校验命令行输出 60 CheckCmd(command, CheckSAInterface) 61 # 校验命令行重定向输出 62 CheckCmdRedirect(command, CheckSAInterface) 63 # 校验命令行输出到zip文件 64 CheckCmdZip(command, CheckSAInterface)