OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import common, fnmatch, logging, os, re, string, threading, time | 5 import common, fnmatch, logging, os, re, string, threading, time |
6 | 6 |
7 from autotest_lib.server import autotest, hosts, subcommand | 7 from autotest_lib.server import autotest, hosts, subcommand |
8 from autotest_lib.server import site_bsd_router | 8 from autotest_lib.server import site_bsd_router |
9 from autotest_lib.server import site_linux_router | 9 from autotest_lib.server import site_linux_router |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 by adding a new class and auto-selecting it in __init__. | 59 by adding a new class and auto-selecting it in __init__. |
60 | 60 |
61 The WiFiTest class could be generalized to handle clients other than | 61 The WiFiTest class could be generalized to handle clients other than |
62 ChromeOS; this would useful for systems that use Network Manager or | 62 ChromeOS; this would useful for systems that use Network Manager or |
63 wpa_supplicant directly. | 63 wpa_supplicant directly. |
64 """ | 64 """ |
65 | 65 |
66 def __init__(self, name, steps, config): | 66 def __init__(self, name, steps, config): |
67 self.name = name | 67 self.name = name |
68 self.steps = steps | 68 self.steps = steps |
| 69 router = config['router'] |
69 | 70 |
70 router = config['router'] | |
71 self.router = hosts.create_host(router['addr']) | 71 self.router = hosts.create_host(router['addr']) |
72 # NB: truncate SSID to 32 characters | 72 # NB: truncate SSID to 32 characters |
73 self.defssid = self.__get_defssid(router['addr'])[0:32] | 73 self.defssid = self.__get_defssid(router['addr'])[0:32] |
74 | 74 |
75 if 'type' not in router: | 75 if 'type' not in router: |
76 # auto-detect router type | 76 # auto-detect router type |
77 if site_linux_router.isLinuxRouter(self.router): | 77 if site_linux_router.isLinuxRouter(self.router): |
78 router['type'] = 'linux' | 78 router['type'] = 'linux' |
79 if site_bsd_router.isBSDRouter(self.router): | 79 elif site_bsd_router.isBSDRouter(self.router): |
80 router['type'] = 'bsd' | 80 router['type'] = 'bsd' |
81 else: | 81 else: |
82 raise Exception('Unable to autodetect router type') | 82 raise Exception('Unable to autodetect router type') |
83 if router['type'] == 'linux': | 83 if router['type'] == 'linux': |
84 self.wifi = site_linux_router.LinuxRouter(self.router, router, | 84 self.wifi = site_linux_router.LinuxRouter(self.router, router, |
85 self.defssid) | 85 self.defssid) |
86 elif router['type'] == 'bsd': | 86 elif router['type'] == 'bsd': |
87 self.wifi = site_bsd_router.BSDRouter(self.router, router, | 87 self.wifi = site_bsd_router.BSDRouter(self.router, router, |
88 self.defssid) | 88 self.defssid) |
89 else: | 89 else: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 self.cleanup(params) | 163 self.cleanup(params) |
164 break | 164 break |
165 else: | 165 else: |
166 logging.error("%s: Step '%s' unknown; abort test", | 166 logging.error("%s: Step '%s' unknown; abort test", |
167 self.name, method) | 167 self.name, method) |
168 self.cleanup(params) | 168 self.cleanup(params) |
169 break | 169 break |
170 | 170 |
171 | 171 |
172 def __get_connect_script(self, params): | 172 def __get_connect_script(self, params): |
| 173 # Something is off in our current setup so we'll set the assoc_timeout |
| 174 # to 60. When all is fixed, it should go back to 15. |
173 return ''' | 175 return ''' |
174 import dbus, dbus.mainloop.glib, gobject, logging, re, sys, time | 176 import dbus, dbus.mainloop.glib, gobject, logging, re, sys, time |
175 | 177 |
176 ssid = "''' + params['ssid'] + '''" | 178 ssid = "''' + params['ssid'] + '''" |
177 security = "''' + params['security'] + '''" | 179 security = "''' + params['security'] + '''" |
178 psk = "''' + params.get('psk', "") + '''" | 180 psk = "''' + params.get('psk', "") + '''" |
179 assoc_timeout = ''' + params.get('assoc_timeout', "15") + ''' | 181 assoc_timeout = ''' + params.get('assoc_timeout', "60") + ''' |
180 config_timeout = ''' + params.get('config_timeout', "15") + ''' | 182 config_timeout = ''' + params.get('config_timeout', "15") + ''' |
181 | 183 |
182 bus_loop = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | 184 bus_loop = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
183 bus = dbus.SystemBus(mainloop=bus_loop) | 185 bus = dbus.SystemBus(mainloop=bus_loop) |
184 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"), | 186 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"), |
185 "org.moblin.connman.Manager") | 187 "org.moblin.connman.Manager") |
186 | 188 |
187 try: | 189 try: |
188 path = manager.GetService(({ | 190 path = manager.GetService(({ |
189 "Type": "wifi", | 191 "Type": "wifi", |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 def __print_pingstats(self, label, stats): | 434 def __print_pingstats(self, label, stats): |
433 logging.info("%s: %s%s/%s, %s%% loss, rtt %s/%s/%s", | 435 logging.info("%s: %s%s/%s, %s%% loss, rtt %s/%s/%s", |
434 self.name, label, stats['xmit'], stats['recv'], stats['loss'], | 436 self.name, label, stats['xmit'], stats['recv'], stats['loss'], |
435 stats['min'], stats['avg'], stats['max']) | 437 stats['min'], stats['avg'], stats['max']) |
436 | 438 |
437 | 439 |
438 def client_ping(self, params): | 440 def client_ping(self, params): |
439 """ Ping the server from the client """ | 441 """ Ping the server from the client """ |
440 ping_ip = params.get('ping_ip', self.server_wifi_ip) | 442 ping_ip = params.get('ping_ip', self.server_wifi_ip) |
441 count = params.get('count', 10) | 443 count = params.get('count', 10) |
442 # set timeout for 3s / ping packet | 444 # set timeout for 5s / ping packet |
443 result = self.client.run("ping %s %s" % \ | 445 result = self.client.run("ping %s %s" % \ |
444 (self.__ping_args(params), ping_ip), timeout=3*int(count)) | 446 (self.__ping_args(params), ping_ip), timeout=5*int(count)) |
445 | 447 |
446 self.__print_pingstats("client_ping ", | 448 self.__print_pingstats("client_ping ", |
447 self.__get_pingstats(result.stdout)) | 449 self.__get_pingstats(result.stdout)) |
448 | 450 |
449 | 451 |
450 def client_ping_bg(self, params): | 452 def client_ping_bg(self, params): |
451 """ Ping the server from the client """ | 453 """ Ping the server from the client """ |
452 ping_ip = params.get('ping_ip', self.server_wifi_ip) | 454 ping_ip = params.get('ping_ip', self.server_wifi_ip) |
453 cmd = "ping %s %s" % (self.__ping_args(params), ping_ip) | 455 cmd = "ping %s %s" % (self.__ping_args(params), ping_ip) |
454 self.ping_thread = HelperThread(self.client, cmd) | 456 self.ping_thread = HelperThread(self.client, cmd) |
455 self.ping_thread.start() | 457 self.ping_thread.start() |
456 | 458 |
457 | 459 |
458 def client_ping_bg_stop(self, params): | 460 def client_ping_bg_stop(self, params): |
459 if self.ping_thread is not None: | 461 if self.ping_thread is not None: |
460 self.client.run("pkill ping") | 462 self.client.run("pkill ping") |
461 self.ping_thread.join() | 463 self.ping_thread.join() |
462 self.ping_thread = None | 464 self.ping_thread = None |
463 | 465 |
464 | 466 |
465 def server_ping(self, params): | 467 def server_ping(self, params): |
466 """ Ping the client from the server """ | 468 """ Ping the client from the server """ |
467 if self.server is None: | 469 if self.server is None: |
468 self.__unreachable("server_ping") | 470 self.__unreachable("server_ping") |
469 return | 471 return |
470 ping_ip = params.get('ping_ip', self.client_wifi_ip) | 472 ping_ip = params.get('ping_ip', self.client_wifi_ip) |
471 count = params.get('count', 10) | 473 count = params.get('count', 10) |
472 # set timeout for 3s / ping packet | 474 # set timeout for 5s / ping packet |
473 result = self.server.run("ping %s %s" % \ | 475 result = self.server.run("ping %s %s" % \ |
474 (self.__ping_args(params), ping_ip), timeout=3*int(count)) | 476 (self.__ping_args(params), ping_ip), timeout=5*int(count)) |
475 | 477 |
476 self.__print_pingstats("server_ping ", | 478 self.__print_pingstats("server_ping ", |
477 self.__get_pingstats(result.stdout)) | 479 self.__get_pingstats(result.stdout)) |
478 | 480 |
479 | 481 |
480 def server_ping_bg(self, params): | 482 def server_ping_bg(self, params): |
481 """ Ping the client from the server """ | 483 """ Ping the client from the server """ |
482 if self.server is None: | 484 if self.server is None: |
483 self.__unreachable("server_ping_bg") | 485 self.__unreachable("server_ping_bg") |
484 return | 486 return |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 669 |
668 server = config['server'] | 670 server = config['server'] |
669 if server_addr is not None: | 671 if server_addr is not None: |
670 server['addr'] = server_addr; | 672 server['addr'] = server_addr; |
671 # TODO(sleffler) check for wifi_addr when no control address | 673 # TODO(sleffler) check for wifi_addr when no control address |
672 | 674 |
673 # tag jobs w/ the router's address on the control network | 675 # tag jobs w/ the router's address on the control network |
674 config['tagname'] = router['addr'] | 676 config['tagname'] = router['addr'] |
675 | 677 |
676 return config | 678 return config |
OLD | NEW |