import pytest
import os
import argparse
import json
from hiperf_utils import dir_check
from hiperf_utils import file_check
from hiperf_utils import get_used_binaries
from hiperf_utils import validate_json
class TestReport:
def setup(self):
print("TestReport setup")
@pytest.mark.L0
def test_report(self):
parser = argparse.ArgumentParser(description=""" To make a report, you
need to enter the data source and the path of the report.""")
parser.add_argument('-i', '--perf_data', default='perf.data',
type=file_check, help=""" The path of profiling
data.""")
parser.add_argument('-r', '--report_html', default='hiperf_report.html',
help="""the path of the report.""")
parser.add_argument('-l', '--local_lib_dir', type=dir_check, default='./testModule/binary_cache',
help="""Path to find symbol dir use to
do offline unwind stack""")
args = parser.parse_args()
get_used_binaries(args.perf_data, args.report_html, args.local_lib_dir)
with open('./json.txt', 'r') as file:
json_data = file.read()
assert validate_json(json_data) == True
jo = json.loads(json_data)
record = jo['recordSampleInfo']
for a in record:
processes = a['processes']
for b in processes:
threads = b['threads']
for c in threads:
print(c['tid'])
call_stack = c['CallOrder']['callStack']
assert len(call_stack) > 0
assert os.path.exists('./hiperf_report.html') == True