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.gd_sl4a.hci.le_advanced_scanning_test import LeAdvancedScanningTest 18from blueberry.tests.gd_sl4a.security.oob_pairing_sl4a_test import OobPairingSl4aTest 19from blueberry.tests.gd_sl4a.gatt.gatt_connect_low_layer_test import GattConnectLowLayerTest 20 21from mobly import suite_runner 22import argparse 23 24ALL_TESTS = [LeAdvancedScanningTest, OobPairingSl4aTest, GattConnectLowLayerTest] 25 26 27def main(): 28 """ 29 Local test runner that allows to specify list of tests to and customize 30 test config file location 31 """ 32 parser = argparse.ArgumentParser(description="Run local GD SL4A tests.") 33 parser.add_argument( 34 '-c', '--config', type=str, required=True, metavar='<PATH>', help='Path to the test configuration file.') 35 parser.add_argument( 36 '--tests', 37 '--test_case', 38 nargs='+', 39 type=str, 40 metavar='[ClassA[.test_a] ClassB[.test_b] ...]', 41 help='A list of test classes and optional tests to execute.') 42 parser.add_argument("--all_tests", "-A", type=bool, dest="all_tests", default=False, nargs="?") 43 parser.add_argument("--presubmit", type=bool, dest="presubmit", default=False, nargs="?") 44 parser.add_argument("--postsubmit", type=bool, dest="postsubmit", default=False, nargs="?") 45 args = parser.parse_args() 46 test_list = ALL_TESTS 47 if args.all_tests: 48 test_list = ALL_TESTS 49 elif args.presubmit: 50 test_list = ALL_TESTS 51 elif args.postsubmit: 52 test_list = ALL_TESTS 53 # Do not pass this layer's cmd line argument to next layer 54 argv = ["--config", args.config] 55 if args.tests: 56 argv.append("--tests") 57 for test in args.tests: 58 argv.append(test) 59 60 suite_runner.run_suite(test_list, argv=argv) 61 62 63if __name__ == "__main__": 64 main() 65