• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#   Copyright (c) 2021 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 sys
17import os.path
18from ctypes import *
19from hiperf_utils import get_lib
20
21libhiperf_report = get_lib()
22
23if libhiperf_report is not None:
24    libhiperf_report.EchoLoopBack.restype = c_char_p
25    libhiperf_report.Report.restype = c_bool
26    libhiperf_report.Dump.restype = c_bool
27    libhiperf_report.ReportGetSymbolFiles.restype = c_char_p
28    libhiperf_report.ReportGetSymbolFiles.argtypes = [c_char_p]
29    libhiperf_report.ReportGetBuildId.restype = c_char_p
30    libhiperf_report.ReportGetElfArch.restype = c_char_p
31
32    ret = libhiperf_report.EchoLoopBack(b'123')
33    sys.stdout.flush()
34    print("\nfrom Python EchoLoopBack: ", ret)
35
36    ret = libhiperf_report.EchoLoopBack(b'test')
37    sys.stdout.flush()
38    print("\nfrom Python EchoLoopBack: ", ret)
39
40    ret = libhiperf_report.EchoLoopBack(b'test123')
41    sys.stdout.flush()
42    print("\nfrom Python EchoLoopBack: ", ret)
43
44    ret = libhiperf_report.EchoLoopBack(b'')
45    sys.stdout.flush()
46    print("\nfrom Python EchoLoopBack: ", ret)
47
48    ret = libhiperf_report.EchoLoopBack(None)
49    sys.stdout.flush()
50    print("\nfrom Python EchoLoopBack: ", ret)
51
52    ret = libhiperf_report.Report(b'perf.data', b'report.txt', b'-s')
53    print("\nfrom Python Report: ", ret)
54
55    ret = libhiperf_report.SetDebug(True)
56    print("\nfrom Python SetDebug: ", ret)
57
58    ret = libhiperf_report.ReportJson(b'perf.data', b'json.txt')
59    print("\nfrom Python ReportJson: ", ret)
60
61    ret = libhiperf_report.ReportGetSymbolFiles(b'perf.data')
62    print("\nfrom Python ReportGetSymbolFiles: ", ret)
63
64    ret = libhiperf_report.ReportGetBuildId(b'elf32_test')
65    print("\nfrom Python ReportGetBuildId: ", ret)
66
67    ret = libhiperf_report.ReportGetBuildId(b'elf32_test_stripped_nobuildid')
68    print("\nfrom Python ReportGetBuildId: ", ret)
69
70    ret = libhiperf_report.ReportGetElfArch(b'elf32_test')
71    print("\nfrom Python ReportGetElfArch: ", ret)
72
73    ret = libhiperf_report.ReportGetElfArch(b'elf_test')
74    print("\nfrom Python ReportGetElfArch: ", ret)
75
76    ret = libhiperf_report.ReportGetElfArch(b'hiperf')
77    print("\nfrom Python ReportGetElfArch: ", ret)
78