• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 subprocess
18import re
19import sys
20sys.path.append("..")
21from tools.utils import *
22
23OUTPUT_PATH = "testModule/output"
24LIB_PATH = "/system/lib64"
25MB_SIZE = 1024
26ROM_THRESH = 9000
27SIZE_INDEX = 4
28
29
30def check_rom(output):
31    result = output.split()[SIZE_INDEX]
32    multi = False
33    if (result[-1] == 'M'):
34        multi = True
35    result = float(result[:-1])
36    if multi:
37        result *= MB_SIZE
38    return result
39
40
41class TestHiprofilerRom:
42    @pytest.mark.L0
43    def test_rom(self):
44        # 校验命令行输出
45        rom_cpu = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libcpudataplugin*", text=True, encoding="utf-8")
46        rom_cpu = check_rom(rom_cpu)
47
48        rom_gpu = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libgpudataplugin*", text=True, encoding="utf-8")
49        rom_gpu = check_rom(rom_gpu)
50
51        rom_disk = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libdiskiodataplugin*", text=True, encoding="utf-8")
52        rom_disk = check_rom(rom_disk)
53
54        rom_ftrace = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libftrace_plugin*", text=True, encoding="utf-8")
55        rom_ftrace = check_rom(rom_ftrace)
56
57        rom_hidump = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libhidumpplugin*", text=True, encoding="utf-8")
58        rom_hidump = check_rom(rom_hidump)
59
60        rom_hilog = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libhilogplugin*", text=True, encoding="utf-8")
61        rom_hilog = check_rom(rom_hilog)
62
63        rom_hiperf = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libhiperfplugin*", text=True, encoding="utf-8")
64        rom_hiperf = check_rom(rom_hiperf)
65
66        rom_hisys = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libhisyseventplugin*", text=True, encoding="utf-8")
67        rom_hisys = check_rom(rom_hisys)
68
69        rom_memory = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libmemdataplugin*", text=True, encoding="utf-8")
70        rom_memory = check_rom(rom_memory)
71
72        rom_network = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libnetworkplugin*", text=True, encoding="utf-8")
73        rom_network = check_rom(rom_network)
74
75        rom_process = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libprocessplugin*", text=True, encoding="utf-8")
76        rom_process = check_rom(rom_process)
77
78        rom_xpower = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libxpowerplugin*", text=True, encoding="utf-8")
79        rom_xpower = check_rom(rom_xpower)
80
81        rom_hook = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libnative_hook*", text=True, encoding="utf-8")
82        rom_hook = check_rom(rom_hook)
83
84        rom_netprofiler = subprocess.check_output(f"hdc shell ls -lh /system/lib64/libnetwork_profiler*", text=True, encoding="utf-8")
85        rom_netprofiler = check_rom(rom_netprofiler)
86
87        rom_daemon = subprocess.check_output(f"hdc shell ls -lh /system/bin/native_daemon*", text=True, encoding="utf-8")
88        rom_daemon = check_rom(rom_daemon)
89
90        rom_hiprofilerd = subprocess.check_output(f"hdc shell ls -lh /system/bin/hiprofilerd*", text=True, encoding="utf-8")
91        rom_hiprofilerd = check_rom(rom_hiprofilerd)
92
93        rom_cmd = subprocess.check_output(f"hdc shell ls -lh /system/bin/hiprofiler_cmd*", text=True, encoding="utf-8")
94        rom_cmd = check_rom(rom_cmd)
95
96        rom_plugins = subprocess.check_output(f"hdc shell ls -lh /system/bin/hiprofiler_plugins*", text=True, encoding="utf-8")
97        rom_plugins = check_rom(rom_plugins)
98
99        assert (rom_cpu + rom_gpu + rom_disk + rom_ftrace + rom_hidump + rom_hilog + rom_hiperf + rom_hisys + rom_memory + rom_network + rom_process + rom_xpower + rom_hook + rom_daemon + rom_hiprofilerd + rom_cmd + rom_plugins + rom_netprofiler < ROM_THRESH)