blob: b2608067859b87254b714a205d88778826662f6e [file] [log] [blame]
# Copyright (c) 2014 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.
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib import utils
class network_TwoShills(test.test):
"""Test that only one shill runs at a time"""
version = 1
def is_shill_running():
Check if shill is running.
@return True or False.
return utils.get_service_pid("shill") != 0
def get_default_netdev():
Get the name of the network device with the default route.
@return A string such as "eth0" or "wlan0".
cmd_result =
"ip route show default match 0/0 table 0 | awk '{print $5}'")
return cmd_result.stdout
def run_once(self):
"""Test main loop."""
if not self.is_shill_running():
raise error.TestFail("shill not running at start")
default_netdev = self.get_default_netdev()
if len(default_netdev) < 1:
raise error.TestFail("unable to determine default network device")
# Run shill, expecting it to abort quickly. If the new
# process does not exit within the allotted time,
# will kill the new process
# explicitly. (First with SIGTERM, then SIGKILL.)
cmd_result =
"shill --foreground --device-black-list=%s" % default_netdev,
ignore_status = True)
except error.CmdTimeoutError:
raise error.TestFail("shill did not exit within %d seconds" %