• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# This file does only contain a selection of the most common options. For a
18# full list see the documentation:
19# http://www.sphinx-doc.org/en/master/config
20
21from functools import cached_property
22from pathlib import Path
23from runner.options.options_general import GeneralOptions
24
25
26class CoverageDir:
27    def __init__(self, general: GeneralOptions, work_dir: Path):
28        self.__general = general
29        self.__work_dir = work_dir
30
31    @cached_property
32    def root(self) -> Path:
33        root = self.__work_dir / "coverage"
34        root.mkdir(parents=True, exist_ok=True)
35        return root
36
37    @property
38    def html_report_dir(self) -> Path:
39        if self.__general.coverage.llvm_cov_html_out_path:
40            html_out_path = Path(self.__general.coverage.llvm_cov_html_out_path)
41        else:
42            html_out_path = self.root / "html_report_dir"
43        html_out_path.mkdir(parents=True, exist_ok=True)
44        return html_out_path
45
46    @cached_property
47    def profdata_dir(self) -> Path:
48        if self.__general.coverage.llvm_profdata_out_path:
49            profdata_out_path = Path(self.__general.coverage.llvm_profdata_out_path)
50        else:
51            profdata_out_path = self.root / "profdata_dir"
52        profdata_out_path.mkdir(parents=True, exist_ok=True)
53        return profdata_out_path
54
55    @cached_property
56    def coverage_work_dir(self) -> Path:
57        work_dir = self.root / "work_dir"
58        work_dir.mkdir(parents=True, exist_ok=True)
59        return work_dir
60
61    @property
62    def info_file(self) -> Path:
63        return self.coverage_work_dir / "coverage_lcov_format.info"
64
65    @property
66    def profdata_files_list_file(self) -> Path:
67        return self.coverage_work_dir / "profdatalist.txt"
68
69    @property
70    def profdata_merged_file(self) -> Path:
71        return self.coverage_work_dir / "merged.profdata"
72