summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2021-05-14 22:47:31 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-05-14 22:47:31 +0000
commitd58636dbe4b7e51ccc3181c67686acc7642c541f (patch)
tree17acc9a18c48a67531f14d96136d5c77dd88f176
parentfe74ef6cf2925ffdc60df3bcbd969c2ca1e8d404 (diff)
parentd6e22ee6c4d52319f03010986382aade9e765bba (diff)
downloadextras-d58636dbe4b7e51ccc3181c67686acc7642c541f.tar.gz
Merge "simpleperf: add --only-host-test option in do_test.py." am: 3c6d3fe723 am: 5e06f4fc31 am: c4e6bd2e74 am: d6e22ee6c4
Original change: https://android-review.googlesource.com/c/platform/system/extras/+/1708911 Change-Id: Ifc34e7236cf3d7554ce860299392e55aaf433cda
-rwxr-xr-xsimpleperf/scripts/debug_unwind_reporter.py3
-rw-r--r--simpleperf/scripts/simpleperf_utils.py3
-rwxr-xr-xsimpleperf/scripts/test/do_test.py22
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)