diff options
author | Yabin Cui <yabinc@google.com> | 2021-05-14 22:33:17 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-14 22:33:17 +0000 |
commit | d6e22ee6c4d52319f03010986382aade9e765bba (patch) | |
tree | 17acc9a18c48a67531f14d96136d5c77dd88f176 | |
parent | 31f4af9ce9c2c4cf0a9ab7706f1a5c1fb3c56302 (diff) | |
parent | c4e6bd2e74d2d2b4ec387e56e6eb8bd7951618e0 (diff) | |
download | extras-d6e22ee6c4d52319f03010986382aade9e765bba.tar.gz |
Merge "simpleperf: add --only-host-test option in do_test.py." am: 3c6d3fe723 am: 5e06f4fc31 am: c4e6bd2e74
Original change: https://android-review.googlesource.com/c/platform/system/extras/+/1708911
Change-Id: Ibed46aa8a19ce3132713dccfb4c1cf40e7de6703
-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) |