Home | History | Annotate | Download | only in webservd_BasicDBusAPI
      1 # Copyright 2015 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import dbus
      6 
      7 from autotest_lib.client.bin import test
      8 from autotest_lib.client.common_lib import error
      9 
     10 
     11 SERVICE_NAME = 'org.chromium.WebServer'
     12 MANAGER_INTERFACE = 'org.chromium.WebServer.Manager'
     13 MANAGER_OBJECT_PATH = '/org/chromium/WebServer/Manager'
     14 
     15 EXPECTED_PING_RESPONSE = 'Web Server is running'
     16 
     17 class webservd_BasicDBusAPI(test.test):
     18     """Check that basic webservd daemon DBus APIs are functional."""
     19     version = 1
     20 
     21     def run_once(self):
     22         """Test entry point."""
     23         bus = dbus.SystemBus()
     24         manager_proxy = dbus.Interface(
     25                 bus.get_object(SERVICE_NAME, MANAGER_OBJECT_PATH),
     26                 dbus_interface=MANAGER_INTERFACE)
     27         ping_response = manager_proxy.Ping()
     28         if EXPECTED_PING_RESPONSE != ping_response:
     29             raise error.TestFail(
     30                     'Expected Manager.Ping to return %s but got %s instead.' %
     31                     (EXPECTED_PING_RESPONSE, ping_response))
     32