autotest: wifi: Remove WiFiInterfaceClaimContext
This wrapper can be easily replaced with a try-catch-finally block.
BUG=chromium:628791
TEST=Ran network_WiFi_ChannelScanDwellTime, its only consumer.
Change-Id: Ieec7a6cb6a6c1840c03f0647858291988ae3023a
Signed-off-by: Kirtika Ruchandani <kirtika@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1292792
Commit-Ready: Kirtika Ruchandani <kirtika@chromium.org>
Tested-by: Kirtika Ruchandani <kirtika@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
diff --git a/server/cros/network/wifi_interface_claim_context.py b/server/cros/network/wifi_interface_claim_context.py
deleted file mode 100644
index 4d5a95b..0000000
--- a/server/cros/network/wifi_interface_claim_context.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2015 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-class WiFiInterfaceClaimContext(object):
- """Context that encapsulates claiming of a wifi interface.
-
- This context ensures that if the test fails while the interface is claimed
- we will attempt to release it before our test exits.
-
- """
-
- def __init__(self, client):
- self._client = client
-
-
- def __enter__(self):
- self._client.claim_wifi_if()
-
-
- def __exit__(self, exception, value, traceback):
- self._client.release_wifi_if()
diff --git a/server/site_tests/network_WiFi_ChannelScanDwellTime/network_WiFi_ChannelScanDwellTime.py b/server/site_tests/network_WiFi_ChannelScanDwellTime/network_WiFi_ChannelScanDwellTime.py
index bc5e62c..ec40e70 100644
--- a/server/site_tests/network_WiFi_ChannelScanDwellTime/network_WiFi_ChannelScanDwellTime.py
+++ b/server/site_tests/network_WiFi_ChannelScanDwellTime/network_WiFi_ChannelScanDwellTime.py
@@ -8,7 +8,6 @@
from autotest_lib.server.cros.network import frame_sender
from autotest_lib.server.cros.network import hostap_config
-from autotest_lib.server.cros.network import wifi_interface_claim_context
from autotest_lib.server import site_linux_system
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib import utils
@@ -186,11 +185,13 @@
# will prevent shill and wpa_supplicant from managing that interface.
# So this test can have the sole ownership of the interface and can
# perform scans without interference from shill and wpa_supplicant.
- with wifi_interface_claim_context.WiFiInterfaceClaimContext(
- self.context.client):
+ self.context.client.claim_wifi_if()
+ try:
# Get channel dwell time for single-channel scan
dwell_time = self._channel_dwell_time_test(True)
logging.info('Channel dwell time for single-channel scan: %d ms',
dwell_time)
self.write_perf_keyval(
{'dwell_time_single_channel_scan': dwell_time})
+ finally:
+ self.context.client.release_wifi_if()