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 time 19import threading 20 21LIB_PATH = "/system/lib" 22THRESH = 25000000000 23SLEEP_TIME = 2 24CONFIG_INDEX = 8 25 26 27def task(index): 28 indexstr = str(index) 29 subprocess.check_output("hdc shell hiprofiler_cmd -c /data/local/tmp/config" + indexstr + ".txt -o /data/local/tmp/test" + indexstr + ".htrace -t 20 -s -k") 30 31 32class TestHiprofilerFtrace: 33 @pytest.mark.L0 34 def test_allplugin(self): 35 subprocess.check_output(r"hdc file send .\..\inputfiles\ftrace\config8.txt /data/local/tmp/", text=True, encoding="utf-8") 36 subprocess.check_output(r"hdc file send .\..\inputfiles\hookDecoder /data/local/tmp/", text=True, encoding="utf-8") 37 subprocess.check_output(r"hdc file send .\..\inputfiles\malloctest /data/local/tmp/", text=True, encoding="utf-8") 38 task_thread = threading.Thread(target=task, args=(CONFIG_INDEX, )) 39 time.sleep(SLEEP_TIME) 40 task_thread.start() 41 subprocess.check_output(f"hdc shell uitest uiInput drag 100 100 800 100 1000") 42 subprocess.check_output(f"hdc shell uitest uiInput drag 800 100 100 100 1000") 43 task_thread.join() 44 45 subprocess.check_output("hdc shell chmod 777 /data/local/tmp/hookDecoder") 46 subprocess.check_output("hdc shell ./data/local/tmp/hookDecoder -f /data/local/tmp/test8.htrace > /data/local/tmp/test8_result.txt") 47 subprocess.check_output(f"hdc file recv /data/local/tmp/test8.htrace .\..\outputfiles\ ", text=True, encoding="utf-8") 48 subprocess.check_output(f"hdc file recv /data/local/tmp/test8_result.txt .\..\outputfiles\ ", text=True, encoding="utf-8") 49 check_sceneboard = False 50 check_cpu = False 51 with open(r'.\..\outputfiles\test8_result.txt', 'r') as file: 52 lines = file.readlines() 53 for line in lines: 54 if "com.ohos.launcher" in line: 55 check_sceneboard = True 56 if "cpu5" in line: 57 check_cpu = True 58 assert (check_sceneboard and check_cpu)