diff options
author | Yabin Cui <yabinc@google.com> | 2021-05-14 21:57:15 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-14 21:57:15 +0000 |
commit | 5e06f4fc31448bc91d35529d17971c73c838d57e (patch) | |
tree | f5f00049671ca852477cd44453a7221f3d1a0cd1 | |
parent | ea752c44ab12c0deeb0f951ea2556e356c73e959 (diff) | |
parent | 3c6d3fe723ef1c8310e9b1f38d432e449a38dfec (diff) | |
download | extras-5e06f4fc31448bc91d35529d17971c73c838d57e.tar.gz |
Merge "simpleperf: add --only-host-test option in do_test.py." am: 3c6d3fe723
Original change: https://android-review.googlesource.com/c/platform/system/extras/+/1708911
Change-Id: I5153ff31850b65776c4a4a3f69b0f30ee9c0e767
-rwxr-xr-x | simpleperf/scripts/debug_unwind_reporter.py | 3 | ||||
-rw-r--r-- | simpleperf/scripts/simpleperf_utils.py | 3 | ||||
-rwxr-xr-x | simpleperf/scripts/test/do_test.py | 22 |
3 files changed, 18 insertions, 10 deletions
diff --git a/simpleperf/scripts/debug_unwind_reporter.py b/simpleperf/scripts/debug_unwind_reporter.py index 7a291b27..238c9acd 100755 --- a/simpleperf/scripts/debug_unwind_reporter.py +++ b/simpleperf/scripts/debug_unwind_reporter.py @@ -37,10 +37,9 @@ Below is an example using debug_unwind_reporter.py: import argparse from collections import Counter, defaultdict -from collections.abc import Iterator from simpleperf_utils import ArgParseFormatter from texttable import Texttable -from typing import List, Dict +from typing import Dict, Iterator, List class CallChainNode: diff --git a/simpleperf/scripts/simpleperf_utils.py b/simpleperf/scripts/simpleperf_utils.py index 65652210..cf50fcb2 100644 --- a/simpleperf/scripts/simpleperf_utils.py +++ b/simpleperf/scripts/simpleperf_utils.py @@ -20,7 +20,6 @@ from __future__ import annotations import argparse -from collections.abc import Iterator import logging import os import os.path @@ -30,7 +29,7 @@ import shutil import subprocess import sys import time -from typing import Dict, List, Optional, Set, Union +from typing import Dict, Iterator, List, Optional, Set, Union def get_script_dir() -> str: diff --git a/simpleperf/scripts/test/do_test.py b/simpleperf/scripts/test/do_test.py index b2886b65..946390df 100755 --- a/simpleperf/scripts/test/do_test.py +++ b/simpleperf/scripts/test/do_test.py @@ -65,7 +65,8 @@ def get_args() -> argparse.Namespace: parser.add_argument( '-d', '--device', nargs='+', help='set devices used to run tests. Each device in format name:serial-number') - parser.add_argument('--list-tests', action='store_true', help='List all tests.') + parser.add_argument('--only-host-test', action='store_true', help='Only run host tests') + parser.add_argument('--list-tests', action='store_true', help='List tests') parser.add_argument('--ndk-path', type=extant_dir, help='Set the path of a ndk release') parser.add_argument('-p', '--pattern', nargs='+', help='Run tests matching the selected pattern.') @@ -86,8 +87,16 @@ def get_all_tests() -> List[str]: return sorted(tests) -def get_filtered_tests(test_from: Optional[str], test_pattern: Optional[List[str]]) -> List[str]: - tests = get_all_tests() +def get_host_tests() -> List[str]: + def filter_fn(test: str) -> bool: + return get_test_type(test) == 'host_test' + return list(filter(filter_fn, get_all_tests())) + + +def get_filtered_tests( + tests: List[str], + test_from: Optional[str], + test_pattern: Optional[List[str]]) -> List[str]: if test_from: try: tests = tests[tests.index(test_from):] @@ -466,12 +475,13 @@ def run_tests_in_child_process(tests: List[str], args: argparse.Namespace) -> bo def main() -> bool: args = get_args() + tests = get_host_tests() if args.only_host_test else get_all_tests() + tests = get_filtered_tests(tests, args.test_from, args.pattern) + if args.list_tests: - print('\n'.join(get_all_tests())) + print('\n'.join(tests)) return True - tests = get_filtered_tests(args.test_from, args.pattern) - test_dir = Path(args.test_dir).resolve() remove(test_dir) test_dir.mkdir(parents=True) |