1import site 2 3site.main() 4 5import argparse 6import logging 7import os 8import sys 9 10from argparse import Namespace 11from mobly import suite_runner 12from typing import List, Tuple 13 14_BUMBLE_BTSNOOP_FMT = 'bumble_btsnoop_{pid}_{instance}.log' 15 16# Import test cases modules. 17import asha_test 18import avatar.cases.host_test 19import avatar.cases.le_host_test 20import avatar.cases.le_security_test 21import avatar.cases.security_test 22import gatt_test 23import hfpclient_test 24import sdp_test 25import pairing.smp_test as smp_test 26 27_TEST_CLASSES_LIST = [ 28 avatar.cases.host_test.HostTest, 29 avatar.cases.le_host_test.LeHostTest, 30 avatar.cases.security_test.SecurityTest, 31 avatar.cases.le_security_test.LeSecurityTest, 32 sdp_test.SdpTest, 33 smp_test.SmpTest, 34 gatt_test.GattTest, 35 asha_test.AshaTest, 36 hfpclient_test.HfpClientTest, 37] 38 39 40def _parse_cli_args() -> Tuple[Namespace, List[str]]: 41 parser = argparse.ArgumentParser(description='Avatar test runner.') 42 parser.add_argument('-o', '--log_path', type=str, metavar='<PATH>', help='Path to the test configuration file.') 43 return parser.parse_known_args() 44 45 46if __name__ == "__main__": 47 logging.basicConfig(level=logging.INFO) 48 49 # This is a hack for `tradefed` because of `b/166468397`. 50 if '--' in sys.argv: 51 index = sys.argv.index('--') 52 sys.argv = sys.argv[:1] + sys.argv[index + 1:] 53 54 # Enable bumble snoop logger. 55 ns, argv = _parse_cli_args() 56 if ns.log_path: 57 os.environ.setdefault('BUMBLE_SNOOPER', f'btsnoop:file:{ns.log_path}/{_BUMBLE_BTSNOOP_FMT}') 58 59 # Run the test suite. 60 suite_runner.run_suite(_TEST_CLASSES_LIST, argv) # type: ignore 61