1#!/usr/bin/env python3 2# 3# Copyright 2021 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17from blueberry.tests.sl4a_sl4a.advertising.le_advertising import LeAdvertisingTest 18from blueberry.tests.sl4a_sl4a.gatt.gatt_connect_test import GattConnectTest 19from blueberry.tests.sl4a_sl4a.gatt.gatt_connect_with_irk_test import GattConnectWithIrkTest 20from blueberry.tests.sl4a_sl4a.gatt.gatt_notify_test import GattNotifyTest 21from blueberry.tests.sl4a_sl4a.l2cap.le_l2cap_coc_test import LeL2capCoCTest 22from blueberry.tests.sl4a_sl4a.scanning.le_scanning import LeScanningTest 23from blueberry.tests.sl4a_sl4a.security.oob_pairing_test import OobPairingTest 24 25from mobly import suite_runner 26import argparse 27 28ALL_TESTS = [ 29 GattConnectTest, 30 GattConnectWithIrkTest, 31 GattNotifyTest, 32 LeAdvertisingTest, 33 LeL2capCoCTest, 34 LeScanningTest, 35 OobPairingTest, 36] 37 38 39def main(): 40 """ 41 Local test runner that allows to specify list of tests to and customize 42 test config file location 43 """ 44 parser = argparse.ArgumentParser(description="Run local GD SL4A tests.") 45 parser.add_argument('-c', 46 '--config', 47 type=str, 48 required=True, 49 metavar='<PATH>', 50 help='Path to the test configuration file.') 51 parser.add_argument('--tests', 52 '--test_case', 53 nargs='+', 54 type=str, 55 metavar='[ClassA[.test_a] ClassB[.test_b] ...]', 56 help='A list of test classes and optional tests to execute.') 57 parser.add_argument("--all_tests", "-A", type=bool, dest="all_tests", default=False, nargs="?") 58 parser.add_argument("--presubmit", type=bool, dest="presubmit", default=False, nargs="?") 59 parser.add_argument("--postsubmit", type=bool, dest="postsubmit", default=False, nargs="?") 60 args = parser.parse_args() 61 test_list = ALL_TESTS 62 if args.all_tests: 63 test_list = ALL_TESTS 64 elif args.presubmit: 65 test_list = ALL_TESTS 66 elif args.postsubmit: 67 test_list = ALL_TESTS 68 # Do not pass this layer's cmd line argument to next layer 69 argv = ["--config", args.config] 70 if args.tests: 71 argv.append("--tests") 72 for test in args.tests: 73 argv.append(test) 74 75 suite_runner.run_suite(test_list, argv=argv) 76 77 78if __name__ == "__main__": 79 main() 80