1#!/usr/bin/env python3 2# 3# Copyright (C) 2019 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6# use this file except in compliance with the License. You may obtain a copy of 7# 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, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations under 15# the License. 16""" 17Script for initializing a cmd line tool for PTS and other purposes. 18Required custom config parameters: 19'target_mac_address': '00:00:00:00:00:00' 20 21""" 22from acts.base_test import BaseTestClass 23from command_input import CommandInput 24 25 26class BluetoothCmdLineTest(BaseTestClass): 27 target_device_name = "" 28 29 def setup_class(self): 30 super().setup_class() 31 dut = self.user_params.get('dut', None) 32 if dut: 33 if dut == 'fuchsia_devices': 34 self.dut = self.fuchsia_devices[0] 35 self.dut.sl4f.bts_lib.initBluetoothSys() 36 self.dut.sl4f.sdp_lib.init() 37 elif dut == 'android_devices': 38 self.dut = self.android_devices[0] 39 else: 40 raise ValueError('Invalid DUT specified in config. (%s)' % 41 self.user_params['dut']) 42 else: 43 # Default is an Fuchsia device 44 self.dut = self.fuchsia_devices[0] 45 if not "target_device_name" in self.user_params.keys(): 46 self.log.warning("Missing user config \"target_device_name\"!") 47 self.target_device_name = "" 48 else: 49 self.target_device_name = self.user_params["target_device_name"] 50 51 def test_cmd_line_helper(self): 52 cmd_line = CommandInput() 53 cmd_line.setup_vars(self.dut, self.target_device_name, self.log) 54 cmd_line.cmdloop() 55 return True 56