autotest: Detect ambiguous hostapd SSID references
LinuxRouter.get_ssid() will default to using the first instance of
hostapd that was configured, but this may not be desirable in those
rare cases where we configure multiple instances. When a developer
makes an ambiguous reference, detect this and raise an error rather
than behaving in an unexpected way.
TEST=wifi_matfunc runs correctly with this change after the remaining
WiFiManager tests are migrated.
BUG=None
CQ-DEPEND=CL:176149
CQ-DEPEND=CL:176403
Change-Id: I77ffa7063da998d89ebbd2d54480f203cb67d1f5
Reviewed-on: https://chromium-review.googlesource.com/176466
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index 779497c..0e94f5c 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -759,8 +759,14 @@
self.router.run('grep -q "%s" %s' % (pmksa_match, instance['log_file']))
- def get_ssid(self, instance=0):
+ def get_ssid(self, instance=None):
"""@return string ssid for the network stemming from this router."""
+ if instance is None:
+ instance = 0
+ if len(self.hostapd_instances) > 1:
+ raise error.TestFail('No instance of hostapd specified with '
+ 'multiple instances present.')
+
if self.hostapd_instances:
return self.hostapd_instances[instance]['ssid']