• 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
15set -e
16
17declare -i ret_error=1
18
19function init()
20{
21    CUR_PATH=$(dirname "$(readlink -f "$0")")
22    TMP_PATH=$CUR_PATH/tmp
23}
24
25function check_command_exist()
26{
27    command=$1
28    type "$command" >/dev/null 2>&1
29    echo  $?
30}
31
32function check_pip_component()
33{
34    pip3 list|grep "$1"
35    return $?
36}
37
38function download_js_test_files()
39{
40    code_path="$TMP_PATH"/code/arkjs-perf-test
41    if [ -d "$code_path" ];then
42        JS_TEST_PATH=$code_path/js-perf-test
43        return
44    fi
45
46    mkdir -p "$code_path"
47    echo "$code_path"
48    git clone -b builtins_test1110 https://gitee.com/dov1s/arkjs-perf-test.git "$code_path"
49    JS_TEST_PATH=$code_path/js-perf-test
50}
51
52main()
53{
54    init
55    js_perf_test_archive_path=$1
56    OPENHARMONY_OUT_PATH=$2
57    D8_BINARY_PATH=$3
58    VER_PLATFORM="full_x86_64"
59    if [ $# == 4 ]; then
60        VER_PLATFORM=$4
61    fi
62    cur_path=$(dirname "$(readlink -f "$0")")
63
64    if [ ! -d "$js_perf_test_archive_path" ];then
65        mkdir -p "js_perf_test_archive_path"
66    fi
67
68    check_command_exist git || { echo "git is not available"; return $ret_error; }
69    check_command_exist unzip || { echo "unzip is not available"; return $ret_error; }
70    check_command_exist jq || { echo "jq is not available"; return $ret_error; }
71    check_command_exist python3 || { echo "python3 is not available"; return $ret_error; }
72    check_pip_component "openpyxl"  || { pip3 install openpyxl; }
73
74    [ -f "$cur_path/run_js_test.py" ] || { echo "no run_js_test.py, please check it";return $ret_error;}
75
76    download_js_test_files || { return $ret_error; }
77
78    echo "LD_LIBRARY_PATH:$LD_LIBRARY_PATH"
79    python3  "$cur_path"/run_js_test.py -bp "$OPENHARMONY_OUT_PATH" -p "$JS_TEST_PATH" -o "$js_perf_test_archive_path"\
80        -v "$D8_BINARY_PATH" -e "$VER_PLATFORM"
81}
82
83main "$@"
84exit $?
85