bluetooth: Rename chameleon to btpeer
Change references to chameleon in code to btpeer to avoid confusion.
Initialize peer_list to avoid failure in standalone tests.
TEST=Run tests locally and on lab DUTs
BUG=b:142486063
Cq-Depend: chromium:2061270
Change-Id: Ib4780a0f961a63c62199e3b49020a38d330dfa88
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2061273
Reviewed-by: Daniel Winkler <danielwinkler@google.com>
Commit-Queue: Shijin Abraham <shijinabraham@google.com>
Tested-by: Shijin Abraham <shijinabraham@google.com>
diff --git a/server/cros/bluetooth/bluetooth_adapter_quick_tests.py b/server/cros/bluetooth/bluetooth_adapter_quick_tests.py
index 13de10f..27ddf41 100644
--- a/server/cros/bluetooth/bluetooth_adapter_quick_tests.py
+++ b/server/cros/bluetooth/bluetooth_adapter_quick_tests.py
@@ -68,14 +68,16 @@
def start_peers(self, devices):
"""Start peer devices"""
# Start the link to devices
- logging.info('Starting peer devices...')
- self.get_device_rasp(devices)
+ if self.use_btpeer:
+ logging.info('Starting peer devices...')
+ self.get_device_rasp(devices)
def _print_delimiter(self):
logging.info('=======================================================')
- def quick_test_init(self, host, use_chameleon=True, flag='Quick Sanity'):
+ def quick_test_init(self, host, use_btpeer=True, use_chameleon=False,
+ flag='Quick Sanity'):
"""Inits the test batch"""
self.host = host
#factory can not be declared as local variable, otherwise
@@ -100,8 +102,14 @@
# Raise the original exception
raise
- self.use_chameleon = use_chameleon
- if self.use_chameleon:
+ # Common list to track old/new Bluetooth peers
+ # Adding chameleon to btpeer_list causes issue in cros_labels
+ self.host.peer_list = []
+
+ # Keep use_chameleon for any unmodified tests
+ # TODO(b:149637050) Remove use_chameleon
+ self.use_btpeer = use_btpeer or use_chameleon
+ if self.use_btpeer:
self.input_facade = self.factory.create_input_facade()
self.check_btpeer()
@@ -115,7 +123,6 @@
logging.info('%s Bluetooth peers found',
len(self.host.btpeer_list))
- # Adding hostname-chameleon to same list causes issue in cros_labels
self.host.peer_list = self.host.btpeer_list[:]
if (self.host._chameleon_host is not None and
@@ -207,7 +214,7 @@
self._print_delimiter()
return False
- # Check that chameleon has all required devices before running
+ # Check that btpeer has all required devices before running
for device_type, number in devices.items():
if self.available_devices.get(device_type, 0) < number:
logging.info('SKIPPING TEST %s', test_name)
@@ -310,12 +317,13 @@
# Repopulate btpeer_group for next tests
# Clear previous tets's leftover entries. Don't delete the
# btpeer_group dictionary though, it'll be used as it is.
- for device_type in self.btpeer_group:
- if len(self.btpeer_group[device_type]) > 0:
- del self.btpeer_group[device_type][:]
+ if self.use_btpeer:
+ for device_type in self.btpeer_group:
+ if len(self.btpeer_group[device_type]) > 0:
+ del self.btpeer_group[device_type][:]
- # Repopulate
- self.group_btpeers_type()
+ # Repopulate
+ self.group_btpeers_type()
# Close the connection between peers
self.cleanup(test_state='NEW')
diff --git a/server/cros/bluetooth/bluetooth_adapter_tests.py b/server/cros/bluetooth/bluetooth_adapter_tests.py
index 51244fc..a839908 100644
--- a/server/cros/bluetooth/bluetooth_adapter_tests.py
+++ b/server/cros/bluetooth/bluetooth_adapter_tests.py
@@ -38,16 +38,16 @@
# Delay binding the methods since host is only available at run time.
SUPPORTED_DEVICE_TYPES = {
- 'MOUSE': lambda chameleon: chameleon.get_bluetooth_hid_mouse,
- 'KEYBOARD': lambda chameleon: chameleon.get_bluetooth_hid_keyboard,
- 'BLE_MOUSE': lambda chameleon: chameleon.get_ble_mouse,
- 'BLE_KEYBOARD': lambda chameleon: chameleon.get_ble_keyboard,
- 'A2DP_SINK': lambda chameleon: chameleon.get_bluetooth_a2dp_sink,
+ 'MOUSE': lambda btpeer: btpeer.get_bluetooth_hid_mouse,
+ 'KEYBOARD': lambda btpeer: btpeer.get_bluetooth_hid_keyboard,
+ 'BLE_MOUSE': lambda btpeer: btpeer.get_ble_mouse,
+ 'BLE_KEYBOARD': lambda btpeer: btpeer.get_ble_keyboard,
+ 'A2DP_SINK': lambda btpeer: btpeer.get_bluetooth_a2dp_sink,
# This is a base object that does not emulate any Bluetooth device.
# This object is preferred when only a pure XMLRPC server is needed
- # on the chameleon host, e.g., to perform servod methods.
- 'BLUETOOTH_BASE': lambda chameleon: chameleon.get_bluetooth_base,
+ # on the btpeer host, e.g., to perform servod methods.
+ 'BLUETOOTH_BASE': lambda btpeer: btpeer.get_bluetooth_base,
}
@@ -86,10 +86,10 @@
return result
-def get_bluetooth_emulated_device(chameleon, device_type):
+def get_bluetooth_emulated_device(btpeer, device_type):
"""Get the bluetooth emulated device object.
- @param chameleon: the chameleon host
+ @param btpeer: the Bluetooth peer device
@param device_type : the bluetooth device type, e.g., 'MOUSE'
@returns: the bluetooth device object
@@ -118,7 +118,7 @@
step and retry the device method. The remediation steps are
1) re-creating the serial device.
2) reset (powercycle) the bluetooth dongle.
- 3) reboot chameleond host.
+ 3) reboot Bluetooth peer.
If the device method still fails after these steps, we fail the test
The default values exist for uses of this function before the options
@@ -148,7 +148,7 @@
logging.error('%s failed the %s time. Attempting to %s',
method_name,i,description)
- if not fix_serial_device(chameleon, device, action):
+ if not fix_serial_device(btpeer, device, action):
logging.info('%s failed', description)
else:
logging.info('%s successful', description)
@@ -167,10 +167,10 @@
device_type)
# Get the bluetooth device object and query some important properties.
- device = SUPPORTED_DEVICE_TYPES[device_type](chameleon)()
+ device = SUPPORTED_DEVICE_TYPES[device_type](btpeer)()
# Get some properties of the kit
- # NOTE: Strings updated here must be kept in sync with Chameleon.
+ # NOTE: Strings updated here must be kept in sync with Btpeer.
device._capabilities = _retry_device_method('GetCapabilities')
device._transports = device._capabilities["CAP_TRANSPORTS"]
device._is_le_only = ("TRANSPORT_LE" in device._transports and
@@ -264,8 +264,8 @@
logging.info('The device is created successfully after %s.', operation)
return True
-def _reboot_chameleon(chameleon, device):
- """ Reboot chameleond host
+def _reboot_btpeer(btpeer, device):
+ """ Reboot Bluetooth peer device.
Also power cycle the device since reboot may not do that.."""
@@ -279,11 +279,11 @@
logging.info("Powercycling the device")
device.PowerCycle()
time.sleep(RESET_SLEEP_SECS)
- logging.info('rebooting chameleon...')
- chameleon.reboot()
+ logging.info('rebooting Bluetooth peer...')
+ btpeer.reboot()
- # Every chameleon reboot would take a bit more than REBOOT_SLEEP_SECS.
- # Sleep REBOOT_SLEEP_SECS and then begin probing the chameleon board.
+ # Every btpeer reboot would take a bit more than REBOOT_SLEEP_SECS.
+ # Sleep REBOOT_SLEEP_SECS and then begin probing the btpeer board.
time.sleep(REBOOT_SLEEP_SECS)
return _check_device_init(device, 'reboot')
@@ -320,21 +320,21 @@
return truthiness_of_result or result in legal_falsy_values
-def fix_serial_device(chameleon, device, operation='reset'):
+def fix_serial_device(btpeer, device, operation='reset'):
"""Fix the serial device.
This function tries to fix the serial device by
(1) re-creating a serial device, or
(2) power cycling the usb port to which device is connected
- (3) rebooting the chameleon board.
+ (3) rebooting the Bluetooth peeer
Argument operation determine which of the steps above are perform
- Note that rebooting the chameleon board or reseting the device will remove
+ Note that rebooting the btpeer board or resetting the device will remove
the state on the peripheral which might cause test failures. Please use
reset/reboot only before or after a test.
- @param chameleon: the chameleon host
+ @param btpeer: the Bluetooth peer
@param device: the bluetooth device.
@param operation: Recovery operation to perform 'recreate/reset/reboot'
@@ -363,9 +363,9 @@
return _reset_device_power(device)
elif operation == 'reboot':
- # Reboot the chameleon host.
- # The device is power cycled before rebooting chameleon host
- return _reboot_chameleon(chameleon, device)
+ # Reboot the Bluetooth peer device.
+ # The device is power cycled before rebooting Bluetooth peer device
+ return _reboot_btpeer(btpeer, device)
else:
logging.error('fix_serial_device Invalid operation %s', operation)
@@ -398,13 +398,13 @@
time.sleep(1)
- if not hasattr(instance, 'use_chameleon'):
+ if not hasattr(instance, 'use_btpeer'):
return _is_successful(_run_method(test_method, test_method.__name__,
instance, *args, **kwargs))
for device_type in SUPPORTED_DEVICE_TYPES:
for device in getattr(instance, 'devices')[device_type]:
- #fix_serial_device in 'recreate' mode doesn't require chameleon
- #so just pass None for convinent.
+ #fix_serial_device in 'recreate' mode doesn't require btpeer
+ #so just pass None for convenient.
if not fix_serial_device(None, device, "recreate"):
return False
@@ -638,7 +638,7 @@
def clear_raspi_device(self, device):
- """Clears a device on a raspi chameleon by resetting bluetooth stack
+ """Clears a device on a raspi peer by resetting bluetooth stack
@param device: proxy object of peripheral device
"""
@@ -675,7 +675,7 @@
def get_device_rasp(self, device_num, on_start=True):
- """Get all bluetooth device objects from Bluetooth peers.
+ """Get all bluetooth device objects from Bluetooth peer devices
This method should be called only after group_btpeers_type
@param device_num : dict of {device_type:number}, to specify the number
of device needed for each device_type.
@@ -768,15 +768,15 @@
return self.devices[device_type][-1]
- def is_device_available(self, chameleon, device_type):
- """Determines if the named device is available on the linked chameleon
+ def is_device_available(self, btpeer, device_type):
+ """Determines if the named device is available on the linked peer
@param device_type: the bluetooth HID device type, e.g., 'MOUSE'
@returns: True if it is able to resolve the device, false otherwise
"""
- device = SUPPORTED_DEVICE_TYPES[device_type](chameleon)()
+ device = SUPPORTED_DEVICE_TYPES[device_type](btpeer)()
try:
# The proxy prevents us from checking if the object is None directly
# so instead we call a fast method that any peripheral must support.
diff --git a/server/site_tests/bluetooth_AdapterCLSanity/bluetooth_AdapterCLSanity.py b/server/site_tests/bluetooth_AdapterCLSanity/bluetooth_AdapterCLSanity.py
index 762722a..637cf64 100644
--- a/server/site_tests/bluetooth_AdapterCLSanity/bluetooth_AdapterCLSanity.py
+++ b/server/site_tests/bluetooth_AdapterCLSanity/bluetooth_AdapterCLSanity.py
@@ -154,6 +154,6 @@
"""
# Initialize and run the test batch or the requested specific test
- self.quick_test_init(host, use_chameleon=True, flag=flag)
+ self.quick_test_init(host, use_btpeer=True, flag=flag)
self.cl_sanity_batch_run(num_iterations, test_name)
self.quick_test_cleanup()
diff --git a/server/site_tests/bluetooth_AdapterLEBetterTogether/bluetooth_AdapterLEBetterTogether.py b/server/site_tests/bluetooth_AdapterLEBetterTogether/bluetooth_AdapterLEBetterTogether.py
index 7d6ba6f..6a51a5a 100644
--- a/server/site_tests/bluetooth_AdapterLEBetterTogether/bluetooth_AdapterLEBetterTogether.py
+++ b/server/site_tests/bluetooth_AdapterLEBetterTogether/bluetooth_AdapterLEBetterTogether.py
@@ -99,6 +99,6 @@
"""
# Initialize and run the test batch or the requested specific test
- self.quick_test_init(host, use_chameleon=True, flag=flag)
+ self.quick_test_init(host, use_btpeer=True, flag=flag)
self.better_together_batch_run(num_iterations, test_name)
self.quick_test_cleanup()
diff --git a/server/site_tests/bluetooth_AdapterLESanity/bluetooth_AdapterLESanity.py b/server/site_tests/bluetooth_AdapterLESanity/bluetooth_AdapterLESanity.py
index b585e97..ec57dd4 100644
--- a/server/site_tests/bluetooth_AdapterLESanity/bluetooth_AdapterLESanity.py
+++ b/server/site_tests/bluetooth_AdapterLESanity/bluetooth_AdapterLESanity.py
@@ -156,6 +156,6 @@
"""
# Initialize and run the test batch or the requested specific test
- self.quick_test_init(host, use_chameleon=True, flag=flag)
+ self.quick_test_init(host, use_btpeer=True, flag=flag)
self.le_sanity_batch_run(num_iterations, test_name)
self.quick_test_cleanup()
diff --git a/server/site_tests/bluetooth_AdapterMDSanity/bluetooth_AdapterMDSanity.py b/server/site_tests/bluetooth_AdapterMDSanity/bluetooth_AdapterMDSanity.py
index 95613f4..4d63363 100644
--- a/server/site_tests/bluetooth_AdapterMDSanity/bluetooth_AdapterMDSanity.py
+++ b/server/site_tests/bluetooth_AdapterMDSanity/bluetooth_AdapterMDSanity.py
@@ -66,8 +66,6 @@
@param num_iterations: the number of rounds to execute the test
"""
# Initialize and run the test batch or the requested specific test
- self.quick_test_init(host, use_chameleon=True, flag=flag)
+ self.quick_test_init(host, use_btpeer=True, flag=flag)
self.md_sanity_batch_run(num_iterations, test_name)
self.quick_test_cleanup()
-
-
diff --git a/server/site_tests/bluetooth_AdapterQuickSanity/bluetooth_AdapterQuickSanity.py b/server/site_tests/bluetooth_AdapterQuickSanity/bluetooth_AdapterQuickSanity.py
index 39d0ae7..e9e11d6 100644
--- a/server/site_tests/bluetooth_AdapterQuickSanity/bluetooth_AdapterQuickSanity.py
+++ b/server/site_tests/bluetooth_AdapterQuickSanity/bluetooth_AdapterQuickSanity.py
@@ -33,7 +33,7 @@
"""
# Init the quick test and start the package
- self.quick_test_init(host, use_chameleon=True, flag=flag)
+ self.quick_test_init(host, use_btpeer=True, flag=flag)
self.quick_test_package_start('BT Quick Sanity')
# Run sanity package
diff --git a/server/site_tests/bluetooth_AdapterSASanity/bluetooth_AdapterSASanity.py b/server/site_tests/bluetooth_AdapterSASanity/bluetooth_AdapterSASanity.py
index 83fd880..35d2e47 100644
--- a/server/site_tests/bluetooth_AdapterSASanity/bluetooth_AdapterSASanity.py
+++ b/server/site_tests/bluetooth_AdapterSASanity/bluetooth_AdapterSASanity.py
@@ -245,6 +245,6 @@
@param num_iterations: the number of rounds to execute the test
"""
# Initialize and run the test batch or the requested specific test
- self.quick_test_init(host, use_chameleon=False, flag=flag)
+ self.quick_test_init(host, use_btpeer=False, flag=flag)
self.sa_sanity_batch_run(num_iterations, test_name)
self.quick_test_cleanup()