• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# coding=utf-8
3
4#
5# Copyright (c) 2020 Huawei Device Co., Ltd.
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19import os
20import sys
21import subprocess
22
23from xdevice import IReporter
24from xdevice import Plugin
25from xdevice import TestType
26
27from _core.logger import platform_logger
28
29__all__ = ["BenchmarkReporter"]
30LOG = platform_logger("BenchmarkReporter")
31
32@Plugin(type=Plugin.REPORTER, id=TestType.benchmark)
33class BenchmarkReporter(IReporter):
34
35    def __generate_reports__(self, report_path, **kwargs):
36        del kwargs
37        LOG.info("report_path = %s" % report_path)
38        self._make_benchmark_report(report_path)
39
40    def _make_benchmark_report(self, result_path):
41        result_path = os.path.join(result_path, "benchmark")
42        reports_dir = os.path.join(result_path, "benchmark", "report")
43        if not os.path.exists(reports_dir):
44            os.makedirs(reports_dir)
45        report_generate_tool = os.path.abspath(
46            os.path.join(os.path.dirname(os.path.realpath(__file__)),
47                         "generate_report.py"))
48
49        command = [sys.executable, report_generate_tool, result_path,
50                   reports_dir]
51        LOG.info(command)
52        subprocess.call(command, shell=False)
53