Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# This script generates test code coverage for Android.
# The prerequistes:
#     1. The Onnxruntime build with coverage option to compile/link the source files using --coverage optoin
#     2. The tests are run on the target emulator and *.gcda files are available on the emulator
#     3. The emulator which ran tests must be running. Otherwise this script will fail
 
import argparse
import os
import sys
 
from build import run_subprocess
 
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
REPO_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, "..", ".."))
 
sys.path.append(os.path.join(REPO_DIR, "tools", "python"))
 
import util.android as android  # noqa: E402
 
 
def parse_arguments():
    parser = argparse.ArgumentParser()
    parser.add_argument("--build_dir", required=True, help="Path to the build directory.")
    parser.add_argument(
        "--config",
        default="Debug",
        choices=["Debug", "MinSizeRel", "Release", "RelWithDebInfo"],
        help="Configuration(s) to run code coverage.",
    )
    parser.add_argument("--android_sdk_path", required=True, help="The Android SDK root.")
    return parser.parse_args()
 
 
def main():
    args = parse_arguments()
 
    sdk_tool_paths = android.get_sdk_tool_paths(args.android_sdk_path)
 
    def adb_pull(src, dest, **kwargs):
        return run_subprocess([sdk_tool_paths.adb, "pull", src, dest], **kwargs)
 
    def adb_shell(*args, **kwargs):
        return run_subprocess([sdk_tool_paths.adb, "shell", *args], **kwargs)
 
    script_dir = os.path.realpath(os.path.dirname(__file__))
    source_dir = os.path.normpath(os.path.join(script_dir, "..", ".."))
    cwd = os.path.abspath(os.path.join(args.build_dir, args.config))
    adb_shell("cd /data/local/tmp && tar -zcf gcda_files.tar.gz *.dir")
    adb_pull("/data/local/tmp/gcda_files.tar.gz", cwd)
    os.chdir(cwd)
    run_subprocess(["tar", "-zxf", "gcda_files.tar.gz", "-C", "CMakeFiles"])
    cmd = ["gcovr", "-s", "-r"]
    cmd.append(os.path.join(source_dir, "onnxruntime"))
    cmd.extend([".", "-o"])
    cmd.append(os.path.join(cwd, "coverage_rpt.txt"))
    run_subprocess(cmd, cwd=os.path.join(cwd, "CMakeFiles"))
 
 
if __name__ == "__main__":
    main()