From 853fdcc36c181102fd63aefbb741e72b976a838a Mon Sep 17 00:00:00 2001 From: binaryfz Date: Tue, 22 Mar 2022 15:55:48 +0800 Subject: [PATCH] update doc --- Makefile | 2 +- doc/cn/DeveloperGuide.md | 4 +- doc/en/DeveloperGuide.md | 16 +- test/README.md | 13 +- test/testsuite/android_maple.py | 356 ---------------------- test/testsuite/android_run.py | 292 ------------------ test/testsuite/ouroboros/test_android.cfg | 16 - 7 files changed, 21 insertions(+), 678 deletions(-) delete mode 100644 test/testsuite/android_maple.py delete mode 100644 test/testsuite/android_run.py delete mode 100644 test/testsuite/ouroboros/test_android.cfg diff --git a/Makefile b/Makefile index c8eae8ea2f..1ed845bf51 100644 --- a/Makefile +++ b/Makefile @@ -127,7 +127,7 @@ java-core-def: install cp -rp $(MAPLE_ROOT)/libjava-core/* $(LIB_CORE_PATH)/; \ cd $(LIB_CORE_PATH); \ ln -f -s $(MAPLE_ROOT)/build/core/libcore.mk ./makefile; \ - $(MAKE) gen-def OPT=$(OPT) DEBUG=$(DEBUG) OPS_ANDROID=$(OPS_ANDROID) + $(MAKE) gen-def OPT=$(OPT) DEBUG=$(DEBUG) .PHONY: install install: maple dex2mpl_install irbuild hir2mpl diff --git a/doc/cn/DeveloperGuide.md b/doc/cn/DeveloperGuide.md index c99545f42b..969f52b088 100644 --- a/doc/cn/DeveloperGuide.md +++ b/doc/cn/DeveloperGuide.md @@ -27,17 +27,17 @@ make - `make` 编译OpenArkCompiler的Release版本; - `make BUILD_TYPE=DEBUG` 编译OpenArkCompiler的Debug版本。 -在openarkcompiler目录下执行以下命令,编译出OpenArkCompiler及maple runtime部分,默认输出路径 openarkcompiler/output/TYPE。 +在openarkcompiler目录下执行以下命令,编译出OpenArkCompiler及maple runtime部分,默认输出路径 openarkcompiler/output/TYPE, TYPE: aarch64-clang-release。 ``` source build/envsetup.sh arm release +make setup make libcore ``` 命令说明: - `make libcore` 编译OpenArkCompiler及maple runtime部分的Release版本; -- `make libcore OPS_ANDROID=1` 编译Android版本的OpenArkCompiler及maple runtime部分的Release版本; - `make libcore BUILD_TYPE=DEBUG` 编译OpenArkCompiler及maple runtime部分的Debug版本; 此外,方舟编译器还提供了源码编译脚本,开发者也可以通过在openarkcompiler目录下执行该脚本,默认编译出OpenArkCompiler及maple runtime部分的Release版本。执行命令如下: diff --git a/doc/en/DeveloperGuide.md b/doc/en/DeveloperGuide.md index d5ecfa04d3..7b604e2540 100644 --- a/doc/en/DeveloperGuide.md +++ b/doc/en/DeveloperGuide.md @@ -17,10 +17,11 @@ You can download the OpenArkCompiler source code in `Clone` or `Download` mode. ## Compiling Source Code -Run the following command in the openarkcompiler directory to compile OpenArkCompiler. The output path is openarkcompiler/output/bin by default. +Run the following command in the openarkcompiler directory to compile OpenArkCompiler. The output path is openarkcompiler/output/TYPE/bin, TYPE: aarch64-clang-release by default. ``` source build/envsetup.sh +make setup make ``` Command description: @@ -29,6 +30,19 @@ Command description: - `make`: Compile the release version of OpenArkCompiler. - `make BUILD_TYPE=DEBUG`: Compile the debug version of OpenArkCompiler. +Run the following command in the openarkcompiler directory to compile OpenArkCompiler and maple runtime. The output path is openarkcompiler/output/TYPE, TYPE: aarch64-clang-release by default. + +``` +source build/envsetup.sh arm release +make setup +make libcore +``` + +命令说明: + +- `make libcore` Compile the release version of OpenArkCompiler; +- `make libcore BUILD_TYPE=DEBUG` Compile the debug version of OpenArkCompiler; + In addition, the OpenArkCompiler also provides a shell script which contains the command to compile OpenArkCompiler. The developer can run the script in the openarkcompiler directory to compile OpenArkCompiler. The command to run the script: ``` diff --git a/test/README.md b/test/README.md index 7393a79763..4b49d3cb3e 100644 --- a/test/README.md +++ b/test/README.md @@ -21,12 +21,9 @@ test ├── irbuild_test irbuild测试套 ├── ouroboros ouroboros测试套 │ ├──test.cfg 测试套配置文件 - │ ├──test_android.cfg 测试套手机执行配置文件 │ └──testlist 测试内容 ├──maple.py 用例编译脚本 - ├──run.py 用例执行脚本 - ├──android_maple.py Android用例编译脚本 - └──android_run.py Android用例执行脚本 + └──run.py 用例执行脚本 ``` ## 运行要求 @@ -141,19 +138,15 @@ Log arguments: ## ouroboros 测试套 -ouroboros测试套是基于 `Java` 测试用例的测试套,当前ouroboros测试支持本地测试及系统版本为华为emui10的android手机测试。 +ouroboros测试套是基于 `Java` 测试用例的测试套。 ### 测试环境准备 * 本地测试前请首先执行完成`make libcore`。 -* android测试前请首先执行完成`make libcore OPS_ANDROID=1`。之后将`openarkcompiler/output/ops/host-x86_64-O2`中的`libcore-all.so`、`libmplandroid.so`和`libmplopenjdk.so`推送至测试手机的`/system/lib64/`下,文件名保持不变。将`openarkcompiler/output/ops/mplsh`推送至测试手机的`/system/bin/`下,并将文件重命名为`mplsh_arm64`。 - ### 运行测试套 -* 参数`--test_cfg`设定选择的测试套配置,默认使用`test.cfg`进行本地测试,使用`test_android.cfg`将进行android版本的测试。 - -* 在运行android版本的测试前,需要在test_android.cfg中配置测试机所在服务器的ssh及测试机sn,并提前配置完成本地与服务器间的ssh互信。 +* 参数`--test_cfg`设定选择的测试套配置,默认使用`test.cfg`进行本地测试。 批量运行ouroboros:参数 `-j20` 设定并行为20。 diff --git a/test/testsuite/android_maple.py b/test/testsuite/android_maple.py deleted file mode 100644 index 6711a5bf50..0000000000 --- a/test/testsuite/android_maple.py +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/python3 -# -*- coding:utf-8 -*- -# -# Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. -# -# OpenArkCompiler is licensed under Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# -# http://license.coscl.org.cn/MulanPSL2 -# -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR -# FIT FOR A PARTICULAR PURPOSE. -# See the Mulan PSL v2 for more details. -# - -import argparse -import collections -import logging -import os -import subprocess -import time -import re -from functools import wraps - - -limitation = 0 -output_name = "" -input_name = "" -logger = logging.getLogger("COMPILE") -logger.setLevel(logging.DEBUG) -ch = logging.StreamHandler() -ch.setLevel(logging.DEBUG) -# create formatter and add it to the handlers -formatter = logging.Formatter("%(asctime)-18s - %(name)s - %(levelname)s - %(message)s") -ch.setFormatter(formatter) -# add the handlers to the logger -logger.addHandler(ch) - - -def timing(func): - # Decorator that reports the execution time. - @wraps(func) - def wrapper(*args, **kwargs): - start = time.time() - result = func(*args, **kwargs) - end = time.time() - logger.info("Time Consuming:" + str(end - start) + "s") - return result - - return wrapper - - -# exec the compile command -@timing -def build(cmd): - global limitation - run_cmd = " ".join(cmd) - logger.info(run_cmd) - com = subprocess.Popen(run_cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=True, - cwd="./", - universal_newlines=True) - com_out, com_err = "", "" - try: - com_out, com_err = com.communicate(timeout=limitation) - if com_out is not None: - logger.debug(com_out) - if not com.returncode == 0: - logger.error(com_err) - exit(1) - except subprocess.TimeoutExpired as e: - com.kill() - logger.error(e) - exit(3) - except Exception as ee: - com.kill() - logger.error(ee) - exit(1) - return com_out, com_err, com.returncode - - -class MultiCompiler: - def __init__(self, name, in_suffix, out_suffix, options): - self._in_files_name = "" - self._out_file_name = "" - self._is_skipped = True - self._name = name - self._in_suffix = in_suffix - self._out_suffix = out_suffix - self._options = options - - def get_in_suffix(self): - return self._in_suffix - - def update_info(self, path, options): - if path is not None: - self._name = path + self._name - if options is not None: - self._options = self._options + " " + options - - def prepare(self, file_list): - temp_list = file_list.copy() - for in_file in temp_list: - name = in_file[0:-len(self._in_suffix)] - if in_file == name + self._in_suffix: - self._is_skipped = False - file_list.remove(in_file) - self._in_files_name = self._in_files_name + in_file + " " - self._out_file_name = name + self._out_suffix - file_list.append(self._out_file_name) - else: - continue - - def build(self): - if not self._is_skipped: - return build(self._gen_cmd()) - - def _gen_cmd(self): - cmd = [self._name] - cmd.extend(self._make_opts()) - cmd.extend(re.sub(r"\s+", " ", self._in_files_name).strip().split(" ")) - return cmd - - def _make_opts(self): - options = self._options.strip() - opts = [] - opts.append(options) - return opts - -class java2mpl(MultiCompiler): - def prepare(self, file_list): - global output_name - temp_list = file_list.copy() - for in_file in temp_list: - name = in_file[0:-len(self._in_suffix)] - if in_file == name + self._in_suffix: - self._is_skipped = False - file_list.remove(in_file) - self._in_files_name = self._in_files_name + in_file + " " - else: - continue - # Use the first input file name as the output file name - if not self._is_skipped: - self._out_file_name = output_name.split("/")[-1].split(".")[0] + self._out_suffix - file_list.append(self._out_file_name) - -class SingleCompiler(MultiCompiler): - def prepare(self, file_list): - is_single = 0 - temp_list = file_list.copy() - for in_file in temp_list: - name = in_file[0:-len(self._in_suffix)] - if in_file == name + self._in_suffix: - self._is_skipped = False - is_single = is_single + 1 - if is_single > 1: - logger.error("Not support multi .jar") - exit(1) - file_list.remove(in_file) - self._in_files_name = in_file - self._out_file_name = name + self._out_suffix - file_list.append(self._out_file_name) - else: - continue - - -class Ld(MultiCompiler): - def _gen_cmd(self): - # Specify the output file name - cmd = [self._name] - cmd.extend(re.sub(r"\s+", " ", self._in_files_name).strip().split(" ")) - cmd.extend(self._make_opts()) - return cmd - - -# ------------------------------------------------------------------------ -# -# initial parser and parse the args -# Add parser arguments by tool chain components name -# -# ------------------------------------------------------------------------ -def do_init(components): - parser = argparse.ArgumentParser(prog="maple", usage="maple [options] ") - # choose toolchain target - parser.add_argument("-p", "--platform", dest="target", choices=["aarch64"], default="aarch64", - help="choose toolchain target, default is aarch64") - # Select compile phase - parser.add_argument("-s", "--stage", dest="stage", choices=["java2d8", "dex2mpl", "maple", "as", "ld"], default="ld", - help="Select the compiler stage, default is ld") - # set timeout limitation - parser.add_argument("--timeout", metavar="TIMEOUT", dest="timeout", default=None, type=int, - help="set the timeout limitation") - # set the output name - parser.add_argument("-o", metavar="OUTPUT", dest="output", default="", - help="set the output file name") - suffixes = set() - for name in components.keys(): - parser.add_argument("--" + name, metavar=name.upper(), - help="set the options for component " + name) - suffixes.add(components[name].get_in_suffix()) - # check the legal inputs - parser.add_argument("filename", metavar="", nargs="+", - help="legal input files include: " + str(suffixes)) - args = parser.parse_args() - return vars(args) - - -# ------------------------------------------------------------------------ -# -# set the tool path and compile options -# -# ----------------------------------------------------------------------- -def do_prepare(components, info, maple_root): - global output_name - maple_out_path = maple_root + "/output" - maple_out_lib_path = maple_out_path + "/ops" - maple_out_bin_path = maple_out_path + "/bin/" - maple_android_path = maple_root + "/android" - gnu_bin_path = maple_root + "/tools/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/" - - # 编译选项 java2d8和dex2mpl没有 - # javac_options = "-g -d . " - # jar_options = "-cvf " - - as_options = "-g3 -O2 -x assembler-with-cpp -march=armv8-a -target aarch64-linux-android -c " - cc_options = "-g3 -O2 -c -march=armv8-a -target aarch64-linux-android" - cxx_options = "-g3 -O2 -c -fPIC -march=armv8-a -target aarch64-linux-android" - linker_options_head = "-march=armv8-a -target aarch64-linux-android -shared -o "\ - + output_name + " " + maple_android_path + "/out/soong/.intermediates/bionic/libc/crtbegin_so/android_arm64_armv8-a/crtbegin_so.o "\ - + maple_out_lib_path + "/mrt_module_init.o "\ - + maple_root + "/tools/clang-r353983c/lib64/clang/9.0.3/lib/linux/libclang_rt.builtins-aarch64-android.a "\ - + maple_root + "/tools/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/lib64/libatomic.a "\ - + maple_root + "/tools/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/lib/gcc/aarch64-linux-android/4.9.x/libgcc.a "\ - + maple_android_path + "/out/soong/.intermediates/bionic/libc/crtend_so/android_arm64_armv8-a/obj/bionic/libc/arch-common/bionic/crtend_so.o "\ - + "-fuse-ld=lld -lcore-all -lc -ldl -lcommon_bridge -lc++ -lm -Wl,-T "\ - + maple_out_lib_path + "/linker/maplelld.so.lds "\ - + maple_root + "/tools/clang-r353983c/lib64/clang/9.0.3/lib/linux/libclang_rt.ubsan_minimal-aarch64-android.a "\ - + "-Wl,--exclude-libs,libclang_rt.ubsan_minimal-aarch64-android.a -nostdlib" - - - components["java2d8"].update_info(maple_out_bin_path, info["java2d8"]) - components["dex2mpl"].update_info(maple_out_bin_path, info["dex2mpl"]) - components["maple"].update_info(maple_out_bin_path, info["maple"]) - components["as"].update_info(gnu_bin_path, info["as"]) - components["cc"].update_info(gnu_bin_path, info["cc"]) - components["cxx"].update_info(gnu_bin_path, info["cxx"]) - components["ld"].update_info(gnu_bin_path, info["ld"]) - - components["as"].update_info(None, as_options) - components["cc"].update_info(None, cc_options) - components["cxx"].update_info(None, cxx_options) - components["ld"].update_info(None, linker_options_head) - - - -# ------------------------------------------------------------------------ -# -# Select compile phase: "javac", "jar", "maple", "as", "ld" -# -# ----------------------------------------------------------------------- -def do_update(components, file_type): - if file_type == "java2d8": - components.pop("dex2mpl") - components.pop("maple") - components.pop("as") - components.pop("cc") - components.pop("cxx") - components.pop("ld") - elif file_type == "dex2mpl": - components.pop("maple") - components.pop("as") - components.pop("cc") - components.pop("cxx") - components.pop("ld") - elif file_type == "maple": - components.pop("as") - components.pop("cc") - components.pop("cxx") - components.pop("ld") - elif file_type == "as": - components.pop("ld") - - -# ------------------------------------------------------------------------ -# -# compile files one by one -# -# ----------------------------------------------------------------------- -def do_check(components, file_list): - # del the repeat input files - for in_file in file_list: - while file_list.count(in_file) > 1: - file_list.remove(in_file) - if not os.path.isfile(in_file): - logger.error("No such file or directory: " + in_file) - exit(1) - # compile accord with pre-install phases - for phase in list(components.keys()): - components[phase].prepare(file_list) - - -# ------------------------------------------------------------------------ -# -# Main entry for maple java driver -# -# ------------------------------------------------------------------------ -def main(): - maple_root = os.environ.get("MAPLE_ROOT") - if maple_root is None: - logger.error("Not found system environment: MAPLE_ROOT") - exit(1) - # initial all tool chain components: - # set the default name, input suffix, output suffix, and if it support multi-inputs - components = collections.OrderedDict() - # components["javac"] = Javac("/usr/bin/javac", ".java", ".class", "") - # components["jar"] = Jar("/usr/bin/jar", ".class", ".jar", "") - # components["jbc2mpl"] = SingleCompiler("jbc2mpl", ".jar", ".mpl", "") - - components["java2d8"] = java2mpl("java2d8", ".java", ".dex", "") - components["dex2mpl"] = java2mpl("dex2mpl", ".dex", ".mpl", "") - components["maple"] = SingleCompiler("maple", ".mpl", ".s", "") - components["as"] = MultiCompiler("clang++", ".s", ".o", "") - components["cc"] = MultiCompiler("clang", ".c", ".o", "") - components["cxx"] = MultiCompiler("clang++", ".cpp", ".o", "") - components["ld"] = Ld("clang++", ".o", ".so", "") - - # set the parser and collect the args - info = do_init(components) - # set the limitation and output file name - global limitation, output_name, input_name - limitation = info["timeout"] - output_name = info["output"] - file_list = info["filename"] - file_type = info["stage"] - input_name = file_list[0] - input_name = input_name.split("/")[-1].split(".")[0] - if output_name == "": - output_name = input_name + ".so" - # set the compile options and tool path - do_prepare(components, info, maple_root) - # Select compile phase - do_update(components, file_type) - # check files one by one - do_check(components, file_list) - # compile accord with pre-install phases - for phase in list(components.keys()): - components[phase].build() - logger.info("Compile Finished!") - -if __name__ == "__main__": - main() - diff --git a/test/testsuite/android_run.py b/test/testsuite/android_run.py deleted file mode 100644 index a0951a991c..0000000000 --- a/test/testsuite/android_run.py +++ /dev/null @@ -1,292 +0,0 @@ -# -# Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. -# -# OpenArkCompiler is licensed under Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# -# http://license.coscl.org.cn/MulanPSL2 -# -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR -# FIT FOR A PARTICULAR PURPOSE. -# See the Mulan PSL v2 for more details. -# - -import argparse -import logging -import os -import shlex -import subprocess -import sys -import uuid - -# from assistant.SSH import SSH -from collections import OrderedDict -from textwrap import indent - -sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) -from maple_test.utils import ENCODING, complete_path, add_run_path - -EXIT_CODE = 0 - - -class MapleRunError(Exception): - pass - - -def run(cmd, work_dir, timeout): - process_command = subprocess.Popen( - cmd, - shell=True, - cwd=str(work_dir), - env=add_run_path(str(work_dir)), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True, - ) - try: - com_out, com_err = process_command.communicate(timeout=timeout) - except subprocess.CalledProcessError as err: - raise err - else: - return_code = process_command.returncode - com_out = com_out.decode(ENCODING, errors="ignore") - com_err = com_err.decode(ENCODING, errors="ignore") - return return_code, com_out, com_err - finally: - process_command.terminate() - -def pre_path(execute_cmd, execute_option): - SSH_USER = execute_option["ssh_user"] - SSH_IP = execute_option["ssh_ip"] - SN = execute_option["sn"] - remote_path = execute_option["remote_path"] - android_path = execute_option["android_path"] - args = "mkdir -p {remote_path}; adb -s {SN} shell mkdir -p {android_path}".format(SN=SN, - remote_path=remote_path, android_path=android_path) - execute_cmd["run_case"] = ( - '/usr/bin/ssh ' - '-o ControlMaster=auto -o ControlPath=~/.ssh/ssh-control-sock-%r@%h:%p -o ControlPersist=1h -o ' - 'User={SSH_USER} -o StrictHostKeyChecking=no ' - '{SSH_IP} "{args}"' - .format( - SSH_USER=SSH_USER, SSH_IP=SSH_IP, args=args - ) - ) - logging.debug("pre_path "+execute_cmd["run_case"]) - -def scp_so_cmd(execute_cmd, execute_option): - SSH_USER = execute_option["ssh_user"] - SSH_IP = execute_option["ssh_ip"] - remote_path = execute_option["remote_path"] - android_path = execute_option["android_path"] - execute_option["source_files"] = ":".join( - [str(file) for file in execute_option["source_files"]] - ) - execute_cmd["run_case"] = ( - "/usr/bin/scp " - "-o ControlMaster=auto -o ControlPath=~/.ssh/ssh-control-sock-%r@%h:%p -o ControlPersist=1h -o " - "User={SSH_USER} -o StrictHostKeyChecking=no {source_files} " - "{SSH_IP}:{remote_path} >/dev/null".format( - SSH_USER=SSH_USER, SSH_IP=SSH_IP, **execute_option - ) - ) - logging.debug("scp_so_cmd "+execute_cmd["run_case"]) - -def push_so_cmd(execute_cmd, execute_option): - SSH_USER = execute_option["ssh_user"] - SSH_IP = execute_option["ssh_ip"] - SN = execute_option["sn"] - remote_path = execute_option["remote_path"] - android_path = execute_option["android_path"] - execute_file = execute_option["execute_file"] - args = "adb -s {SN} push {remote_path}{execute_file} {android_path};".format(SN=SN, - execute_file=execute_file, remote_path=remote_path, android_path=android_path) - execute_cmd["run_case"] = ( - '/usr/bin/ssh ' - '-o ControlMaster=auto -o ControlPath=~/.ssh/ssh-control-sock-%r@%h:%p -o ControlPersist=1h -o ' - 'User={SSH_USER} -o StrictHostKeyChecking=no ' - '{SSH_IP} "{args}"' - .format( - SSH_USER=SSH_USER, SSH_IP=SSH_IP, args=args - ) - ) - logging.debug("push_so_cmd "+execute_cmd["run_case"]) - - -def run_so_cmd(execute_cmd, execute_option): - SSH_USER = execute_option["ssh_user"] - SSH_IP = execute_option["ssh_ip"] - SN = execute_option["sn"] - remote_path = execute_option["remote_path"] - android_path = execute_option["android_path"] - execute_file = execute_option["execute_file"] - execute_class = execute_option["execute_class"] - args = "adb -s {SN} shell ' timeout 300 /system/bin/mplsh_arm64 -XX:HeapMaxFree=8m \ - -XX:HeapTargetUtilization=0.75 -Xbootclasspath:libcore-all.so \ - -cp {android_path}{execute_file} {execute_class}'".format(SN=SN, execute_file=execute_file, - execute_class=execute_class, android_path=android_path) - execute_cmd["run_case"] = ( - '/usr/bin/ssh ' - '-o ControlMaster=auto -o ControlPath=~/.ssh/ssh-control-sock-%r@%h:%p -o ControlPersist=1h -o ' - 'User={SSH_USER} -o StrictHostKeyChecking=no ' - '{SSH_IP} "{args}"' - .format( - SSH_USER=SSH_USER, SSH_IP=SSH_IP, remote_path=remote_path, args=args - ) - ) - logging.debug("run_so_cmd "+execute_cmd["run_case"]) - - -def parse_cli(): - parser = argparse.ArgumentParser(prog="android_run") - parser.add_argument( - "--run_type", - default="aarch64", - choices=["aarch64"], - help="run type", - ) - - parser.add_argument( - "execute_file", metavar="[:file2:file3...]", help="execute file, ", - ) - parser.add_argument("execute_class", help="execute class") - - parser.add_argument("--execute_args", dest="execute_args", default="", help="execute args") - parser.add_argument( - "--timeout", help="run test case timeout", type=float, default=None - ) - parser.add_argument( - "--mrt_type", - dest="mrt_type", - default="O2", - choices=["O0", "O2"], - help="Add mrt type to the extra option", - ) - - parser.add_argument( - "--ssh_user", - dest="ssh_user", - help="your ssh user" - ) - - parser.add_argument( - "--ssh_ip", - dest="ssh_ip", - help="your ssh ip" - ) - - parser.add_argument( - "--sn", - dest="sn", - help="your phone sn" - ) - - connection_options = parser.add_argument_group("Script options") - connection_options.add_argument( - "--verbose", action="store_true", dest="verbose", help="enable verbose output", - ) - - opts = parser.parse_args() - return opts - - -def main(): - opts = parse_cli() - run_type = opts.run_type - - parser = shlex.shlex(opts.execute_file) - parser.whitespace = ":" - parser.whitespace_split = True - source_files = [complete_path(file) for file in parser] - - execute_file = opts.execute_file - execute_class = opts.execute_class - execute_args = opts.execute_args - mrt_type = opts.mrt_type - timeout = opts.timeout - ssh_user = opts.ssh_user - ssh_ip = opts.ssh_ip - sn = opts.sn - - tmp_id = str(uuid.uuid1()) - remote_path = "~/ndk_test/tmp/" + execute_class + "_" + tmp_id + "/" - android_path = "/data/local/ndk_test/tmp/" + execute_class + "_" + tmp_id + "/" - - execute_option = { - "source_files": source_files, - "execute_file" : execute_file, - "execute_class" : execute_class, - "execute_args": execute_args, - "mrt_type": mrt_type, - "timeout": timeout, - "ssh_user": ssh_user, - "ssh_ip": ssh_ip, - "sn": sn, - "remote_path": remote_path, - "android_path": android_path, - } - - logging.basicConfig( - format="\t%(asctime)s %(message)s", - datefmt="%H:%M:%S", - level=logging.DEBUG if opts.verbose else logging.INFO, - stream=sys.stderr, - ) - - execute_cmd = OrderedDict() - execute_cmd["run_case"] = None - - # check_env_cmd(execute_cmd, execute_option) - # isInit = run_case(execute_cmd, ".", timeout) - # if isInit != 'yes': - # print(1234) - # init_env_cmd(execute_cmd, execute_option) - # run_case(execute_cmd, ".", timeout) - - pre_path(execute_cmd, execute_option) - run_case(execute_cmd, ".", timeout) - scp_so_cmd(execute_cmd, execute_option) - run_case(execute_cmd, ".", timeout) - push_so_cmd(execute_cmd, execute_option) - run_case(execute_cmd, ".", timeout) - run_so_cmd(execute_cmd, execute_option) - run_case(execute_cmd, ".", timeout) - - -def run_case(execute_cmd, work_dir, timeout): - for stage, cmd in execute_cmd.items(): - ret = run_cmd(stage, cmd, work_dir, timeout) - return ret - - -def run_cmd(stage, cmd, work_dir, timeout): - return_code, com_out, com_err = run(cmd, work_dir, timeout) - logging.debug("execute command: %s", cmd) - logging.debug("execute return code: %d", return_code) - logging.debug("execute out: \n%s", indent(com_out, "\t", lambda line: True)) - logging.debug("execute error: \n%s", indent(com_err, "\t", lambda line: True)) - global EXIT_CODE - EXIT_CODE = return_code - print(com_out, end="") - print(com_err, file=sys.stderr, end="") - if return_code != 0: - logging.error("execute command: %s", cmd) - logging.error("execute return code: %d", return_code) - logging.error("execute out: \n%s", indent(com_out, "\t", lambda line: True)) - logging.error( - "execute error: \n%s", indent(com_err, "\t", lambda line: True) - ) - reason = "Maple run stage: {} failed at command: {}, reason: {}".format( - "run_case".upper(), cmd, com_err - ) - raise MapleRunError(reason) - return com_out - -if __name__ == "__main__": - try: - main() - except MapleRunError as e: - sys.exit(EXIT_CODE) - diff --git a/test/testsuite/ouroboros/test_android.cfg b/test/testsuite/ouroboros/test_android.cfg deleted file mode 100644 index 3e0c94967c..0000000000 --- a/test/testsuite/ouroboros/test_android.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[suffix] -java = // - -[internal-var] -maple = python3 ${MAPLE_ROOT}/test/testsuite/android_maple.py - -# please set your ssh and sn -run = python3 ${MAPLE_ROOT}/test/testsuite/android_run.py --ssh_user=c00520302 --ssh_ip=10.175.96.96 --sn=66J5T19401008041 - -build_option = --dex2mpl="-mplt ${MAPLE_BUILD_OUTPUT}/libjava-core/libcore-all.mplt -litprofile=${MAPLE_ROOT}/src/mrt/codetricks/profile.pv/meta.list" --maple="-O0" --ld=" -L${MAPLE_ROOT}/android/out/target/product/generic_arm64/apex/com.android.runtime/lib64 -L${MAPLE_ROOT}/android/out/target/product/generic_arm64/apex/com.android.runtime/lib64/bionic -L${MAPLE_ROOT}/src/mrt/deplibs -L${MAPLE_ROOT}/tools/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/27 -L${MAPLE_ROOT}/output/ops/host-x86_64-O2" --cxx="-I${MAPLE_ROOT}/output/ops/libnativehelper/include_jni" - -run_option = - -[description] -title = Maple Ouroboros Test - -- Gitee