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