• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2023 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15script_path=$(cd $(dirname $0);pwd)
16pre_dir_path=$(dirname ${script_path})
17pre_dir_path=$(dirname ${pre_dir_path})
18root_path=$(dirname ${pre_dir_path})
19echo $root_path
20
21CONFIG_PATH=$root_path/build/test/example/build_example.json
22SRC_BUNDLE_PATH=$root_path/build/test/example/test_build.json
23DEST_BUNDLE_PATH=$root_path/build/common/bundle.json
24echo $CONFIG_PATH
25
26
27
28function read_file() {
29    FILENAME=$1;KEY=$2
30    RESULT=`cat $FILENAME | grep $KEY | awk -F\" '{ print $4 }'`
31    echo $RESULT
32}
33
34function generate_build_option_report() {
35    option_report_path=$(read_file $CONFIG_PATH option_report_path)
36    option_script_path=$(read_file $CONFIG_PATH option_script_path)
37    pytest -vs --html $root_path$option_report_path $root_path$option_script_path
38    pkill -f '/pyd.py --root .*/.pycache --start'
39}
40
41function generate_gn_template_report() {
42    gn_template_report_path=$(read_file $CONFIG_PATH gn_template_report_path)
43    gn_template_script_path=$(read_file $CONFIG_PATH gn_template_script_path)
44    pytest -vs --html $root_path$gn_template_report_path $root_path$gn_template_script_path
45}
46
47function generate_performance_report() {
48    performance_script_path=$(read_file $CONFIG_PATH performance_script_path)
49    python3 $root_path$performance_script_path
50}
51
52function start() {
53    if [[ $# -eq 1 && $1 == 'all' ]]; then
54      generate_build_option_report
55      generate_performance_report
56      generate_gn_template_report
57    elif [[ $# -eq 1 && $1 == 'option' ]]; then
58      generate_build_option_report
59    elif [[ $# -eq 1 && $1 == 'template' ]]; then
60      generate_gn_template_report
61    elif [[ $# -eq 1 && $1 == 'performance' ]]; then
62      generate_performance_report
63    else
64      echo 'args wrong'
65    fi
66}
67
68rm -rf $root_path/out
69product_path=$(read_file $CONFIG_PATH product_path)
70mkdir -p $root_path$product_path
71
72cp $SRC_BUNDLE_PATH $DEST_BUNDLE_PATH
73
74start "$@"
75
76
77
78
79