bluetooth autotests: Remove reconnection logic after suspend
Add a wrapper function to allow test functions to fail without
failing the batch.
TEST=Ran bluetooth_AdapterCL sanity on Fizz/RPI
BUG=b:140202638, b:138694929
Change-Id: Ib6764dc43a6fa1cc3900c48a77aef96bc38efcd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1980932
Tested-by: Shijin Abraham <shijinabraham@google.com>
Reviewed-by: Daniel Winkler <danielwinkler@google.com>
Commit-Queue: Shijin Abraham <shijinabraham@google.com>
Auto-Submit: Shijin Abraham <shijinabraham@google.com>
diff --git a/server/cros/bluetooth/bluetooth_adapter_pairing_tests.py b/server/cros/bluetooth/bluetooth_adapter_pairing_tests.py
index 951c284..4b16675 100644
--- a/server/cros/bluetooth/bluetooth_adapter_pairing_tests.py
+++ b/server/cros/bluetooth/bluetooth_adapter_pairing_tests.py
@@ -81,10 +81,15 @@
time.sleep(self.PAIR_TEST_SLEEP_SECS)
self.test_device_is_paired(device.address)
- # After a suspend/resume, we need to wake the peripheral
- # as it is not connected.
+
+ # check if peripheral is connected after suspend resume
+ if not self.ignore_failure(check_connected_method, device):
+ logging.info("device not connected after suspend_resume")
+ self.test_connection_by_device(device)
+ else:
+ logging.info("device remains connected after suspend_resume")
+
time.sleep(self.PAIR_TEST_SLEEP_SECS)
- self.test_connection_by_device(device)
check_connected_method(device)
time.sleep(self.PAIR_TEST_SLEEP_SECS)
diff --git a/server/cros/bluetooth/bluetooth_adapter_tests.py b/server/cros/bluetooth/bluetooth_adapter_tests.py
index 780d270..46d8af7 100644
--- a/server/cros/bluetooth/bluetooth_adapter_tests.py
+++ b/server/cros/bluetooth/bluetooth_adapter_tests.py
@@ -823,6 +823,23 @@
logging.error('%s: unexpected error', method_name)
return False
+ def ignore_failure(instance, test_method, *args, **kwargs):
+ """ Wrapper to prevent a test_method failure from failing the test batch
+
+ Sometimes a test method needs to be used as a normal function, for its
+ result. This wrapper prevent test_method failure being recorded in
+ instance.fails and causing a failure of the quick test batch.
+
+ @param test_method: test_method
+ @returns: result of the test_method
+ """
+
+ original_fails = instance.fails[:]
+ test_result = test_method(*args, **kwargs)
+ if not test_result:
+ logging.info("%s failure is ignored",test_method.__name__)
+ instance.fails = original_fails
+ return test_result
# -------------------------------------------------------------------
# Adater standalone tests