flimflam-test: Remove duplicate scripts from flimflam-test
To prevent developers from modifying these scripts, not knowing that more
recent code is in src/platform/shill/test-scripts, remove the scripts.
Leave a note in their place pointing to where they have gone. In
time, we'll delete the whole package.
BUG=chromium-os:39146
TEST=These scripts aren't being used anymore, because people have
noticed a problem where the migration missed a recently added script.
Change-Id: I54d3cc989dcd7daba4f78d9df57af2d4bdf26f6b
Reviewed-on: https://gerrit.chromium.org/gerrit/44049
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
Tested-by: Christopher Wiley <wiley@chromium.org>
diff --git a/test/WHERE_DID_THE_CODE_GO b/test/WHERE_DID_THE_CODE_GO
new file mode 100644
index 0000000..d583e63
--- /dev/null
+++ b/test/WHERE_DID_THE_CODE_GO
@@ -0,0 +1 @@
+This code has been moved to src/platform/shill/test-scripts/.
diff --git a/test/activate-service b/test/activate-service
deleted file mode 100644
index acaa7fd..0000000
--- a/test/activate-service
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <service> <carrier>" % (sys.argv[0])
- sys.exit(1)
-
-(_, service_name, carrier) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-service = flim.FindElementByNameSubstring('Service',
- service_name)
-
-if not service:
- print "Could not find service: %s" % (service_name)
- sys.exit(1)
-
-print "Activating service %s" % (service.object_path)
-
-service.ActivateCellularModem(carrier)
diff --git a/test/activation-server b/test/activation-server
deleted file mode 100644
index 6c2cc0c..0000000
--- a/test/activation-server
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-#
-# Implement an activation server
-#
-
-import BaseHTTPServer
-import dbus
-import os
-import SimpleHTTPServer
-import SocketServer
-
-def Carrier():
- bus = dbus.SystemBus()
- obj = bus.get_object('org.chromium.ModemManager',
- '/org/chromium/ModemManager/Carrier')
- return dbus.Interface(obj, 'org.chromium.ModemManager.Carrier')
-
-PORT = 8080
-
-class LocalCarrierRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
-
- @staticmethod
- def PaymentSucceeded():
- # Always recreate to allow restarts for fake-cromo
- carrier = Carrier()
- print 'user paid'
- carrier.ProcessPayment()
-
- @staticmethod
- def PaymentFailed():
- # Always recreate to allow restarts for fake-cromo
- carrier = Carrier()
- print 'user failed to pay'
- carrier.ConsumePlan()
-
-
- def do_GET(self, *args, **kwargs):
- """Handle GET request.
-
- The LocalCarrierRequestHandler handles 2 specific GET commands
- based on the path in the url. These are:
-
- payment_succeeded.html: Payment succeeded
- payment_failed.html: Payment request failed
-
- In both cases a DBUS message is sent to the fake-cromo server so
- that it can implement carrier specific behavior associated with
- payments.
- """
-
- path = self.translate_path(self.path)
- basename = os.path.basename(path)
- if basename == 'payment_succeeded.html':
- LocalCarrierRequestHandler.PaymentSucceeded()
- elif basename == 'payment_failed.html':
- LocalCarrierRequestHandler.PaymentFailed()
-
- SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self, *args, **kwargs)
-
- def send_response(self, code, message=None):
- """Send the response header
-
- This version marks all pages as non cacheable after sending
- the other default headers in the base class
-
- """
- BaseHTTPServer.BaseHTTPRequestHandler.send_response(self, code, message)
- self.send_header('Cache-Control', 'no-cache')
-
-
-class ThreadingBaseHTTPServer(SocketServer.ThreadingMixIn,
- BaseHTTPServer.HTTPServer): pass
-
-
-httpd = ThreadingBaseHTTPServer(("", PORT), LocalCarrierRequestHandler)
-
-print "serving at port", PORT
-
-httpd.serve_forever()
diff --git a/test/add-ipconfig b/test/add-ipconfig
deleted file mode 100755
index 02b0353..0000000
--- a/test/add-ipconfig
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import dbus, flimflam
-
-if (len(sys.argv) < 3):
- print "Usage: %s <device | interface> <type>" % (sys.argv[0])
- sys.exit(1)
-
-(_, name, ipconfig) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-device = flim.FindElementByNameSubstring('Device', name)
-if device is None:
- device = flim.FindElementByPropertySubstring('Device', 'Interface', name)
-
-device.AddIPConfig(ipconfig)
diff --git a/test/backchannel b/test/backchannel
deleted file mode 100644
index 9e6d34e..0000000
--- a/test/backchannel
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 2012 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.
-
-# Backchannel control script - sets up and tears down backchannel network
-# interfaces. Backchannel interfaces are hidden from flimflam and will never be
-# the default route.
-#
-# A backchannel interface can also be used to simulate a cellular
-# modem used by fake-cromo if the new interface name is set to
-# pseudo-modem0
-#
-
-test_if=eth_test
-
-usage () {
- echo "Usage: $0 <command> [args...]"
- echo " setup <iface> [new_iface_name] Sets <iface> as the backchannel device"
- echo " teardown <iface> [new_iface_name] Returns the backchannel device to normal"
- echo " reach <ip> <gw> [new_iface_name] Inserts routes to <ip> via gateway <gw>"
-}
-
-macaddr () {
- ifconfig "$1" | awk '/HWaddr/ { print $5 }'
-}
-
-ipaddr () {
- ifconfig "$1" | awk '/inet addr:/ { print $2 }' \
- | awk -F ':' '{ print $2 }'
-}
-
-netmask () {
- ifconfig "$1" | awk '/Mask:/ { print $4 }' \
- | awk -F ':' '{ print $2 }'
-}
-
-# We need to down the interface (and therefore stop flimflam) across the
-# invocation of nameif, according to nameif(1).
-renameif () {
- old="$1" ; shift
- new="$1" ; shift
- initctl stop shill
- ifconfig "$old" down
- nameif "$new" $(macaddr "$old")
- ifconfig "$new" up
- initctl start shill
-}
-
-setup () {
- oldip=$(ipaddr "$1")
- oldnetmask=$(netmask "$1")
- if [ ! -z $2 ] ; then
- test_if="$2"
- fi
- renameif "$1" "$test_if"
- ifconfig "$test_if" "$oldip" netmask "$oldnetmask"
-}
-
-teardown () {
- if [ ! -z $2 ] ; then
- test_if="$2"
- fi
- renameif "$test_if" "$1"
-}
-
-reach () {
- ip="$1" ; shift
- gw="$1" ; shift
- if [ ! -z $1 ] ; then
- test_if="$1"
- fi
- route add -host "$ip" gw "$gw" "$test_if"
-}
-
-if [ -z "$1" ]; then
- usage
- exit 1
-fi
-
-command="$1" ; shift
-case "$command" in
- setup)
- setup "$@"
- ;;
- teardown)
- teardown "$@"
- ;;
- reach)
- reach "$@"
- ;;
- *)
- usage
- ;;
-esac
diff --git a/test/check-rssi b/test/check-rssi
deleted file mode 100755
index be471cd..0000000
--- a/test/check-rssi
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-strength = {}
-
-for device in flim.GetObjectList("Device"):
- device_properties = device.GetProperties(utf8_strings = True)
- try:
- if device_properties["Type"] not in ["wifi", "wimax",
- "bluetooth", "cellular"]:
- continue
- except Exception, e:
- continue
-
- for network in flim.GetObjectList("Network", device_properties):
- network_properties = network.GetProperties(utf8_strings = True)
-
- if "Name" not in network_properties:
- continue
- name = network_properties["Name"]
-
- if "Strength" not in network_properties:
- print "No strength for network %s" % name
- continue
-
- if strength.get(name, -1) < network_properties["Strength"]:
- strength[name] = network_properties["Strength"]
-
-# print "%-14s: strength %d network %d" % \
-# (name,
-# int(strength.get(name, -1)),
-# int(network_properties.get("Strength", -1)))
-
-for service in flim.GetObjectList("Service"):
- properties = service.GetProperties(utf8_strings = True)
- if "Name" not in properties:
- continue
-
- name = properties["Name"]
-
- print "%-14s: network %d service %d" % \
- (name, int(strength.get(name, -1)), int(properties.get("Strength", -1)))
diff --git a/test/clean-profiles b/test/clean-profiles
deleted file mode 100755
index 7265ea1..0000000
--- a/test/clean-profiles
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2013 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.
-
-import dbus, flimflam
-
-def main():
- """ Pop and remove all profiles until 'default' is found. """
- flim = flimflam.FlimFlam(dbus.SystemBus())
- while True:
- active = flim.GetActiveProfile()
- properties = active.GetProperties(utf8_strings = True)
- # Convert a DBus type to a string.
- active_name = str(properties['Name'])
- if active_name == 'default':
- break
- else:
- print 'Removing profile: %s' % active_name
- flim.PopProfile(active_name)
- flim.RemoveProfile(active_name)
-
-if __name__ == '__main__':
- main()
diff --git a/test/clr-ipconfig b/test/clr-ipconfig
deleted file mode 100755
index fc731d4..0000000
--- a/test/clr-ipconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 3):
- print "Usage: %s <path> <key>" % (sys.argv[0])
- sys.exit(1)
-
-(_, path, key) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-ipconfig = flim.GetObjectInterface("IPConfig", path)
-ipconfig.ClearProperty(key)
diff --git a/test/clr-service-property b/test/clr-service-property
deleted file mode 100755
index d31ab96..0000000
--- a/test/clr-service-property
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/python
-
-import flimflam, sys
-
-if (len(sys.argv) < 3):
- print "Usage: %s <service-name> <property>" % (sys.argv[0])
- sys.exit(1)
-
-(_, name, service_property) = sys.argv
-
-flim = flimflam.FlimFlam()
-service = flim.FindElementByNameSubstring('Service', name)
-service.ClearProperty(service_property)
diff --git a/test/configure-hidden-wifi b/test/configure-hidden-wifi
deleted file mode 100644
index 088c44d..0000000
--- a/test/configure-hidden-wifi
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import dbus, flimflam
-
-if (len(sys.argv) < 2):
- print "Usage: %s <ssid> [passphrase] [security]" % (sys.argv[0])
- sys.exit(1)
-
-print "Attempting to configure hidden service %s" % (sys.argv[1])
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-ssid = sys.argv[1]
-if len(sys.argv) > 2:
- if len(sys.argv) > 3:
- security = sys.argv[3]
- else:
- security = "psk"
- passphrase = sys.argv[2]
-else:
- security = "none"
- passphrase = ""
-
-flim.manager.ConfigureService(({
- "Type" : "wifi",
- "Mode" : "managed",
- "SSID" : ssid,
- "WiFi.HiddenSSID" : True,
- "Security" : security,
- "Passphrase" : passphrase }))
diff --git a/test/configure-service b/test/configure-service
deleted file mode 100755
index c5febdb..0000000
--- a/test/configure-service
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/python
-
-import dbus
-import flimflam
-import sys
-
-if len(sys.argv) < 2:
- print "Usage: %s <GUID> [<property> <value>]" % (sys.argv[0])
- sys.exit(1)
-
-print "Attempting to configure service %s" % (sys.argv[1])
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-params = { "GUID" : sys.argv[1] }
-argv = sys.argv[2:]
-while argv:
- property_key = argv[0]
- value = argv[1]
- if property_key in ["Priority"]:
- params[property_key] = int(value)
- elif property_key in ["AutoConnect", "WiFi.HiddenSSID", "EAP.UseSystemCAS",
- "SaveCredentials"]:
- params[property_key] = dbus.Boolean(value.lower() in ("true", "1"))
- else:
- params[property_key] = value
-
- argv = argv[2:]
-
-flim.manager.ConfigureService(params)
diff --git a/test/configure-wifi b/test/configure-wifi
deleted file mode 100644
index 8200570..0000000
--- a/test/configure-wifi
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import dbus, flimflam
-
-if (len(sys.argv) < 2):
- print "Usage: %s <ssid> [passphrase] [security]" % (sys.argv[0])
- sys.exit(1)
-
-print "Attempting to configure service %s" % (sys.argv[1])
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-ssid = sys.argv[1]
-if len(sys.argv) > 2:
- if len(sys.argv) > 3:
- security = sys.argv[3]
- else:
- security = "psk"
- passphrase = sys.argv[2]
-else:
- security = "none"
- passphrase = ""
-
-flim.manager.ConfigureService(({
- "Type" : "wifi",
- "Mode" : "managed",
- "SSID" : ssid,
- "Security" : security,
- "Passphrase" : passphrase }))
diff --git a/test/connect-disconnect b/test/connect-disconnect
deleted file mode 100755
index e4c029d..0000000
--- a/test/connect-disconnect
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-
-import logging
-import logging.handlers
-import optparse
-import sys
-import syslog
-import time
-
-import dbus
-import flimflam
-
-options = None
-
-
-def SetupSyslog():
- syslog_handler = logging.handlers.SysLogHandler(address='/dev/log')
- formatter = logging.Formatter('%(pathname)s: %(message)s')
- syslog_handler.setFormatter(formatter)
- syslog_handler.setLevel(syslog.LOG_WARNING)
- logging.getLogger().addHandler(syslog_handler)
- logging.getLogger().addHandler(logging.StreamHandler())
-
-
-def GetService(service_name):
- flim = flimflam.FlimFlam(dbus.SystemBus())
- service = flim.FindElementByNameSubstring('Service', service_name)
- if not service:
- logging.error('Could not find service %s' % service_name)
- sys.exit(1)
- return (flim, service)
-
-
-def Cycle(service_name, iteration):
- try:
- (flim, service) = GetService(service_name)
-
- (connect_success, _) = flim.ConnectService(service=service,
- retry=False,
- assoc_timeout=30)
- time.sleep(options.sleep_after_connect)
-
- (disconnect_state, _) = flim.DisconnectService(service)
- time.sleep(options.sleep_after_disconnect)
-
- disconnect_success = (disconnect_state == 'idle')
- to_return = connect_success and disconnect_success
-
- if not to_return:
- logging.error('Failure at iteration %d: Connect:%-6s '
- 'Disconnect:%-6s' %
- (iteration, connect_success, disconnect_success))
- return to_return
-
- except dbus.exceptions.DBusException, e:
- logging.error('Unexpected DBus exception: %s' % e)
- return False
-
-
-def main():
- SetupSyslog()
-
- parser = optparse.OptionParser(usage='usage: %prog [options] service-name')
- parser.set_defaults(keep_going=False)
-
- parser.add_option('--continue', action='store_true', dest='keep_going',
- help='continue after an error')
-
- parser.add_option('--sleep_after_connect', default=0.5, type='float',
- help='Time (in seconds) to sleep after connect')
-
- parser.add_option('--sleep_after_disconnect', default=0, type='float',
- help='Time (in seconds) to sleep after connect')
-
- parser.add_option('--limit', default=0, type='int',
- help='Number of iterations to run (0 for infinite)')
-
-
- global options
- (options, remaining) = parser.parse_args()
-
- if len(remaining) < 1:
- parser.error('Must supply a service name')
-
- (service_name, ) = remaining
-
- (flim, service) = GetService(service_name)
- flim.DisconnectService(service)
-
- total = 0
- success = 0
- while options.limit == 0 or total < options.limit:
- rc = Cycle(service_name, total)
- total += 1
- if rc:
- success += 1
-
- message = (
- 'Fail rate %1.3f Pass %-5d Fail %-5d Total %-5d' %
- (float(total - success) / total, success, total - success, total))
-
- if (total % 10) == 0:
- # Not really a warning, but we want to get this into syslog
- logging.warning(message)
- else:
- print message
-
- if not rc:
- if options.keep_going:
- # Don't want to run in a tight loop for a persistent failure
- sleep_time = 10
- logging.warning('Sleeping %d seconds' % sleep_time)
- time.sleep(sleep_time)
- else:
- logging.error('Exiting on failure')
- sys.exit(1)
- print 'connect-disconnect: Success'
-
-
-if __name__ == '__main__':
- try:
- main()
- except KeyboardInterrupt:
- sys.exit(1)
diff --git a/test/connect-service b/test/connect-service
deleted file mode 100755
index 03f5a53..0000000
--- a/test/connect-service
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-
-import pprint, sys, time
-import dbus, flimflam
-
-if (len(sys.argv) < 2):
- print "Usage: %s <service_name>" % (sys.argv[0])
- sys.exit(1)
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-timeout = time.time() + 30
-while time.time() < timeout:
- service = flim.FindElementByPropertySubstring('Service',
- 'Name',
- sys.argv[1])
- if service:
- break
- time.sleep(.5)
-
-if service is None:
- print "Unknown service %s" % sys.argv[1]
- sys.exit(2)
-
-(success, diagnostics) = flim.ConnectService(service=service)
-
-print 'Success:', success
-pprint.pprint(diagnostics)
diff --git a/test/connect-vpn b/test/connect-vpn
deleted file mode 100755
index c74c36c..0000000
--- a/test/connect-vpn
+++ /dev/null
@@ -1,154 +0,0 @@
-#!/usr/bin/python
-# Copyright (c) 2011 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.
-
-import optparse
-import pprint, sys
-import dbus, flimflam
-
-def show_usage(parser, vpn_type):
- parser.error("Incorrect number of parameters provided for %s" % vpn_type)
-
-def main(argv):
- parser = optparse.OptionParser(
- "%prog [options]... (OpenVPN | L2TPIPSEC)\n"
- "\n"
- " OpenVPN := openvpn NetworkID Certificates\n"
- "\n"
- " L2TPIPSEC := (L2PSK | L2Cert)\n"
- " L2Cert := l2tpipsec-cert NetworkID "
- "CertificatesPkcs11 L2TPInfo\n"
- " L2PSK := l2tpipsec-psk NetworkID PSKInfo L2TPInfo\n"
- "\n"
- " NetworkID := <vpn-name> <remote-host-ip> <vpn-domain>\n"
- " Certificates := <ca-cert> <client-cert> <client-key>\n"
- " CertificatesPkcs11 := <ca-nickname> <client-cert-slot> "
- "<client-cert-id> <user-PIN>\n"
- " PSKInfo := <psk>\n"
- " L2TPInfo := <chap-username> <chap-password>\n"
- )
- parser.add_option("--verbose",
- dest = "verbose",
- action = "store_true",
- default = False,
- help = "Output diagnostic information during run.")
- parser.add_option("--complzo",
- dest = "complzo",
- action = "store_true",
- default = True,
- help = ("Enables the OpenVPN option 'complzo' "
- "(default). "
- "Ignored when not 'OpenVPN'."))
- parser.add_option("--no-complzo",
- dest = "complzo",
- action = "store_false",
- help = ("Disables the OpenVPN option 'complzo'. "
- "Ignored when not 'OpenVPN'."))
- parser.add_option("--mgmtena",
- dest = "mgmtena",
- action = "store_true",
- default = False,
- help = ("Enable the OpenVPN management ctl channel "
- "(default false). "
- "Ignored when not 'OpenVPN'."))
- parser.add_option("--remote-cert-tls",
- dest = "remote_cert_tls",
- action = "store",
- default = "server",
- type = "string",
- metavar = "(server | client | none)",
- help = ("This is passed through to OpenVPN when "
- "not 'none'. "
- "Ignored when not 'OpenVPN'."))
-
- (options, args) = parser.parse_args(argv[1:])
-
- if (len(args) > 1):
- vpn_type = args[0]
- params = { "Type" : "vpn" }
-
- if vpn_type == "openvpn":
- if (len(args) == 7):
- params["Provider.Type"] = "openvpn"
- params["Provider.Name"] = args[1]
- params["Provider.Host"] = args[2]
- params["VPN.Domain"] = args[3]
- params["OpenVPN.CACert"] = args[4]
- params["OpenVPN.Cert"] = args[5]
- params["OpenVPN.Key"] = args[6]
-
- if options.complzo: # "complzo" can only be enabled.
- params["OpenVPN.CompLZO"] = "true"
-
- if options.mgmtena: # enable management control channel
- params["OpenVPN.Mgmt.Enable"] = "true"
-
- if (options.remote_cert_tls != "server" and
- options.remote_cert_tls != "client" and
- options.remote_cert_tls != "none"):
- print("\n--remote-cert-tls argument ('%s') "
- "is invalid.\n" % options.remote_cert_tls)
- sys.exit(1)
-
- params["OpenVPN.RemoteCertTLS"] = options.remote_cert_tls
- else:
- show_usage(parser, vpn_type)
- elif (vpn_type == "l2tpipsec-cert" or
- vpn_type == "l2tpipsec-psk"):
- if len(args) > 4:
- params["Provider.Type"] = "l2tpipsec"
- params["Provider.Name"] = args[1]
- params["Provider.Host"] = args[2]
- params["VPN.Domain"] = args[3]
- if vpn_type == "l2tpipsec-cert" and len(args) == 10:
- params["L2TPIPsec.CACertNSS"] = args[4]
- params["L2TPIPsec.ClientCertSlot"] = args[5]
- params["L2TPIPsec.ClientCertID"] = args[6]
- params["L2TPIPsec.PIN"] = args[7]
- params["L2TPIPsec.PSK"] = ""
- params["L2TPIPsec.User"] = args[8]
- params["L2TPIPsec.Password"] = args[9]
- elif vpn_type == "l2tpipsec-psk" and len(args) == 7:
- params["L2TPIPsec.CACertNSS"] = ""
- params["L2TPIPsec.ClientCertSlot"] = ""
- params["L2TPIPsec.ClientCertID"] = ""
- params["L2TPIPsec.PIN"] = ""
- params["L2TPIPsec.PSK"] = args[4]
- params["L2TPIPsec.User"] = args[5]
- params["L2TPIPsec.Password"] = args[6]
- else:
- show_usage(parser, vpn_type)
- else:
- show_usage(parser, vpn_type)
- else:
- print "Unknown VPN type: '%s'" % vpn_type
- sys.exit(1)
-
- if options.verbose:
- print "\nVPN Startup Parameters:\n"
- for k, v in params.iteritems():
- print " %25s: '%s'" % (k, v)
- print ""
-
- flim = flimflam.FlimFlam(dbus.SystemBus())
- service = flim.GetService(params)
-
- if options.verbose == "true":
- print "VPN is %s, connecting..." % service.object_path
-
- (success, diagnostics) = flim.ConnectService(service_type = "vpn",
- service = service,
- assoc_timeout = 60)
- if not success or options.verbose:
- print "Success:", success
- pprint.pprint(diagnostics)
-
- if not success:
- sys.exit(1)
- else:
- parser.print_help()
- sys.exit(1)
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/test/connect-wifi b/test/connect-wifi
deleted file mode 100755
index 7904e0b..0000000
--- a/test/connect-wifi
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python
-
-import pprint, sys
-import dbus, flimflam
-
-if (len(sys.argv) < 2):
- print "Usage: %s <ssid> [passphrase] [security]" % (sys.argv[0])
- sys.exit(1)
-
-print "Attempting to connect service %s" % (sys.argv[1])
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-params = {}
-params["mode"] = "managed"
-params["ssid"] = sys.argv[1]
-if len(sys.argv) > 2:
- if len(sys.argv) > 3:
- params["security"] = sys.argv[3]
- else:
- params["security"] = "psk"
- params["passphrase"] = sys.argv[2]
-else:
- params["security"] = "none"
- params["passphrase"] = ""
-
-(success, diagnostics) = flim.ConnectService(service_type='wifi',
- **params)
-
-print 'Success:', success
-pprint.pprint(diagnostics)
diff --git a/test/connection_manager.js b/test/connection_manager.js
deleted file mode 100644
index 1f836eb..0000000
--- a/test/connection_manager.js
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-
-function chromeos() {
-}
-
-chromeos.connectionManager = function() {
-};
-
-chromeos.connectionManager.device_info_callback_ = null;
-chromeos.connectionManager.transaction_status_callback_ = null;
-chromeos.connectionManager.parent_page_url_ = 'chrome://mobilesetup';
-
-chromeos.connectionManager.getDeviceInfo = function(callback) {
- chromeos.connectionManager.device_info_callback_ = callback;
- chromeos.connectionManager.requestDeviceInfo_();
-};
-
-chromeos.connectionManager.setTransactionStatus = function(status, callback) {
- chromeos.connectionManager.transaction_status_callback_ = callback;
- chromeos.connectionManager.reportTransactionStatus_(status);
-};
-
-chromeos.connectionManager.reportTransactionStatus_ = function(status) {
- var msg = {
- 'type': 'reportTransactionStatusMsg',
- 'domain': location.href,
- 'status': status
- };
- window.parent.postMessage(msg, chromeos.connectionManager.parent_page_url_);
-};
-
-chromeos.connectionManager.requestDeviceInfo_ = function() {
- var msg = {
- 'type': 'requestDeviceInfoMsg',
- 'domain': location.href,
- };
- window.parent.postMessage(msg, chromeos.connectionManager.parent_page_url_);
-}
-
-window.addEventListener('message', function(e) {
- if (e.data.type == 'deviceInfoMsg') {
- if (chromeos.connectionManager.device_info_callback_)
- chromeos.connectionManager.device_info_callback_(e.data.payload);
- }
-});
diff --git a/test/create-profile b/test/create-profile
deleted file mode 100755
index 7de156d..0000000
--- a/test/create-profile
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Profile pathname required"
- sys.exit(1)
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-profile = flim.CreateProfile(sys.argv[1])
-print "New profile created at %s" % (profile.object_path)
diff --git a/test/debug b/test/debug
deleted file mode 100755
index d6ff8f5..0000000
--- a/test/debug
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/python
-
-import sys, dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-if len(sys.argv) == 2 and sys.argv[1] == '--list':
- print "[%s]" % flim.ListDebugTags()
-else:
- taglist = flim.GetDebugTags()
- if len(sys.argv) < 2:
- if taglist:
- print "[%s]" % taglist
- else:
- print "No debug tags are enabled"
- else:
- if sys.argv[1].startswith("+"):
- newtaglist = taglist
- if newtaglist:
- newtaglist += sys.argv[1]
- else:
- newtaglist = sys.argv[1].lstrip("+")
- elif sys.argv[1].startswith("-"):
- curr_tagset = set(taglist.split("+"))
- tagset_to_remove = set(sys.argv[1].lstrip("-").split("+"))
- newtaglist = "+".join(curr_tagset - tagset_to_remove)
- else:
- newtaglist = sys.argv[1]
- flim.SetDebugTags(newtaglist)
- print "tag list was [%s], now is [%s]" % (taglist, flim.GetDebugTags())
diff --git a/test/debug-flimflam b/test/debug-flimflam
deleted file mode 100755
index f836a89..0000000
--- a/test/debug-flimflam
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/python
-
-import gobject
-
-import dbus
-import dbus.mainloop.glib
-
-def element_signal(path, member):
- if member == "ElementAdded":
- action = "Add "
- elif member == "ElementRemoved":
- action = "Remove"
- elif member == "ElementUpdated":
- action = "Update"
- else:
- return
- print "%s [ %s ]" % (action, path)
-
-if __name__ == '__main__':
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
- bus = dbus.SystemBus()
-
- bus.add_signal_receiver(element_signal,
- bus_name="org.chromium.flimflam",
- signal_name = "ElementAdded",
- path_keyword="path",
- member_keyword="member")
- bus.add_signal_receiver(element_signal,
- bus_name="org.chromium.flimflam",
- signal_name = "ElementRemoved",
- path_keyword="path",
- member_keyword="member")
- bus.add_signal_receiver(element_signal,
- bus_name="org.chromium.flimflam",
- signal_name = "ElementUpdated",
- path_keyword="path",
- member_keyword="member")
-
- mainloop = gobject.MainLoop()
- mainloop.run()
diff --git a/test/delete-entry b/test/delete-entry
deleted file mode 100755
index 4e7c149..0000000
--- a/test/delete-entry
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/python
-
-import dbus, sys
-
-bus = dbus.SystemBus()
-
-manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"),
- "org.chromium.flimflam.Manager")
-
-profile_path = None
-if (len(sys.argv) < 2):
- print "Usage: %s <identifier> [<profile path>]" % (sys.argv[0])
- sys.exit(1)
-elif (len(sys.argv) > 2):
- profile_path = sys.argv[2]
-
-properties = manager.GetProperties(utf8_strings = True)
-
-active = properties["ActiveProfile"]
-
-for path in properties["Profiles"]:
- if (active == path):
- print "[ %s ] <== active" % (path)
- else:
- print "[ %s ]" % (path)
-
- profile = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Profile")
-
- if profile_path is None or path == profile_path:
- try:
- profile.DeleteEntry(sys.argv[1])
- print " -> delete succeeded"
- except Exception, e:
- print " -> delete failed"
diff --git a/test/disable-device b/test/disable-device
deleted file mode 100755
index 2e3b2b6..0000000
--- a/test/disable-device
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <device | interface>" % (sys.argv[0])
- sys.exit(1)
-
-(_, name) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-device = flim.FindElementByNameSubstring('Device', name)
-if device is None:
- device = flim.FindElementByPropertySubstring('Device', 'Interface', name)
-
-print "Disabling device %s" % (device.object_path)
-
-# Shill uses the Disable method, flimflam uses a SetProperty call
-try:
- device.Disable()
-except dbus.DBusException, error:
- device.SetProperty("Powered", dbus.Boolean(0))
diff --git a/test/disconnect-service b/test/disconnect-service
deleted file mode 100755
index 33255c8..0000000
--- a/test/disconnect-service
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/python
-
-import pprint, sys
-import flimflam
-
-flim = flimflam.FlimFlam()
-
-if (len(sys.argv) < 2):
- print "Usage: %s <service_name>" % (sys.argv[0])
- sys.exit(1)
-
-service = flim.FindElementByNameSubstring('Service',
- sys.argv[1])
-
-if not service:
- print "Could not find service: %s" % (sys.argv[1])
- sys.exit(1)
-
-pprint.pprint(flim.DisconnectService(service))
diff --git a/test/enable-device b/test/enable-device
deleted file mode 100755
index e9d2554..0000000
--- a/test/enable-device
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <device | interface>" % (sys.argv[0])
- sys.exit(1)
-
-(_, name) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-device = flim.FindElementByNameSubstring('Device', name)
-if device is None:
- device = flim.FindElementByPropertySubstring('Device', 'Interface', name)
-
-print "Enabling device %s" % (device.object_path)
-
-# Shill uses the Enable method, flimflam uses a SetProperty call
-try:
- device.Enable()
-except dbus.DBusException, error:
- device.SetProperty("Powered", dbus.Boolean(1))
diff --git a/test/fake-cromo b/test/fake-cromo
deleted file mode 100644
index 1ab61ae..0000000
--- a/test/fake-cromo
+++ /dev/null
@@ -1,322 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-#
-# Implement a pseudo cdma modem.
-#
-# This modem mimics a CDMA modem and allows a user to experiment with
-# a modem which starts in a factory reset state and is gradually moved
-# into a fully activated state.
-#
-# To test you'll need to have a machine with at least 1 ethernet port
-# available to simulate the cellular connection. Assume that it is
-# called eth1.
-# 1. install flimflam-test on your DUT.
-# 2. sudo backchannel setup eth0 pseudo-modem0
-# 3. activation-server &
-# 4. sudo fake-cromo
-# 5. Use the UI to "Activate Test Network"
-#
-
-
-import dbus, glib, gobject, os, subprocess, sys, time
-from optparse import OptionParser
-
-import_path = os.environ.get('SYSROOT', '/usr/local') + '/usr/lib/flimflam/test'
-sys.path.append(import_path)
-
-import flimflam_test
-
-Modem = flimflam_test.Modem
-ModemManager = flimflam_test.ModemManager
-
-class IpPoolRestrictor:
- def __init__(self, interface):
- self.interface = interface
- self.restricted = False
-
- def enter(self):
- # Reject all non local tcp traffic, but allow DNS lookups
- if self.restricted:
- return
- subprocess.call(['iptables',
- '-I', 'INPUT', '1',
- '-p', 'tcp',
- '-i', self.interface,
- '-j', 'REJECT'])
- self.restricted = True
-
- def leave(self, force=None):
- if self.restricted or force:
- subprocess.call(['iptables',
- '-D', 'INPUT',
- '-p', 'tcp',
- '-i', self.interface,
- '-j', 'REJECT'])
- self.restricted = False
-
-restrictor = IpPoolRestrictor('pseudo-modem0')
-
-
-class CarrierState(dbus.service.Object):
- def __init__(self, bus, path):
- self.payment_made = False
- self.restricted = False
- dbus.service.Object.__init__(self, bus, path)
-
- @dbus.service.method('org.chromium.ModemManager.Carrier',
- in_signature = '', out_signature = '')
- def ProcessPayment(self, *_args, **_kwargs):
- print "CarrierState: ProcessPayment"
- self.payment_made = True
- self.restricted = False
-
- @dbus.service.method('org.chromium.ModemManager.Carrier',
- in_signature = '', out_signature = '')
- def ConsumePlan(self, *_args, **_kwargs):
- print "CarrierState: ConsumePlan"
- self.payment_made = False
- self.restricted = True
-
-
-class FactoryResetModem(Modem):
-
- def __init__(self, mm, name):
- Modem.__init__(self, mm, name,
- mdn='0000001234',
- activation_state=Modem.NOT_ACTIVATED)
-
- def Activate(self, s, *_args, **_kwargs):
- print 'FactoryResetModem: Activate "%s"' % s
- self.StartActivation(Modem.PARTIALLY_ACTIVATED,
- self.manager.MakePartiallyActivatedModem,
- '0015551212')
-
- # Implement connect as a failure
- def Connect(self, _props, *_args, **_kwargs):
- print 'FactoryResetModem: Connect'
- time.sleep(self.manager.options.connect_delay_ms / 1000.0)
- self.state = flimflam_test.STATE_CONNECTING
- glib.timeout_add(500, lambda: self.ConnectDone(
- self.state,
- flimflam_test.STATE_REGISTERED,
- flimflam_test.REASON_USER_REQUESTED))
- raise flimflam_test.ConnectError()
-
- def ActivateImpl(self, _s, _args, _kwargs):
- raise NotImplementedError('Unimplemented. Must implement in subclass.')
-
-
-class PartiallyActivatedModem(Modem):
-
- def __init__(self, mm, name):
- Modem.__init__(self, mm, name,
- mdn='0015551212',
- activation_state=Modem.PARTIALLY_ACTIVATED)
-
- def Activate(self, s, *_args, **_kwargs):
- print 'Partially_ActivatedModem: Activate "%s"' % s
- carrier = self.manager.carrier
- if self.manager.options.activatable and carrier.payment_made:
- self.StartActivation(Modem.ACTIVATED,
- self.manager.MakeActivatedModem,
- '6175551212')
- else:
- # TODO(jglasgow): define carrier error codes
- carrier_error = 1
- self.StartFailedActivation(carrier_error)
-
- def ConnectDone(self, old, new, why):
- # Implement ConnectDone by manipulating the IP pool restrictor
- if new == flimflam_test.STATE_CONNECTED:
- restrictor.enter()
- else:
- restrictor.leave()
- Modem.ConnectDone(self, old, new, why)
-
- def ActivateImpl(self, _s, _args, _kwargs):
- raise NotImplementedError('Unimplemented. Must implement in subclass.')
-
-
-class ActivatedModem(Modem):
- def __init__(self, mm, name):
- Modem.__init__(self, mm, name,
- mdn='6175551212',
- activation_state=Modem.ACTIVATED)
-
- def ConnectDone(self, old, new, why):
- carrier = self.manager.carrier
- # Implement ConnectDone by manipulating the IP pool restrictor
- if new == flimflam_test.STATE_CONNECTED and carrier.restricted:
- restrictor.enter()
- else:
- restrictor.leave()
- Modem.ConnectDone(self, old, new, why)
-
- def Connect(self, props, *args, **kwargs):
- print 'ActivatedModem: Connect'
- kwargs['connect_delay_ms'] = (
- self.manager.options.connect_delay_ms)
- Modem.Connect(self, props, *args, **kwargs)
-
- def ActivateImpl(self, _s, _args, _kwargs):
- raise NotImplementedError('Unimplemented. Must implement in subclass.')
-
-
-class BrokenActivatedModem(Modem):
- """ BrokenActivatedModem is a modem that although activated always
- fails to connect to the network. This simulates errors in which the
- carrier refuses to allow connections.
- """
- def __init__(self, mm, name):
- Modem.__init__(self, mm, name,
- mdn='6175551212',
- activation_state=Modem.ACTIVATED)
-
- # Implement connect by always failing
- def Connect(self, _props, *_args, **_kwargs):
- print 'BrokenActivatedModem: Connect'
- time.sleep(self.manager.options.connect_delay_ms / 1000.0)
- self.state = flimflam_test.STATE_CONNECTING
- glib.timeout_add(500, lambda: self.ConnectDone(
- self.state,
- flimflam_test.STATE_REGISTERED,
- flimflam_test.REASON_USER_REQUESTED))
- raise flimflam_test.ConnectError()
-
- def ActivateImpl(self, _s, _args, _kwargs):
- raise NotImplementedError('Unimplemented. Must implement in subclass.')
-
-
-class Manager(ModemManager):
- def __init__(self, bus, options):
- ModemManager.__init__(self, bus, flimflam_test.OCMM)
- self.modem_number = 1
- self.options = options
- self.carrier = CarrierState(bus,
- '/org/chromium/ModemManager/Carrier')
-
- def NewModem(self, classname):
- # modem registeres itself with mm, so does not disappear
- _ = classname(self, '/TestModem/%d' % self.modem_number)
- self.modem_number += 1
-
- def MakeFactoryResetModem(self):
- self.NewModem(FactoryResetModem)
-
- def MakePartiallyActivatedModem(self):
- self.NewModem(PartiallyActivatedModem)
-
- def MakeActivatedModem(self):
- if not self.options.activatable:
- self.NewModem(PartiallyActivatedModem)
- elif self.options.connectable:
- self.NewModem(ActivatedModem)
- else:
- self.NewModem(BrokenActivatedModem)
-
-
-def main():
- usage = '''
-Run the fake cromo program to simulate different modem and carrier
-behaviors. By default with no arguments the program will simulate a
-factory reset modem which needs to be activated and requires the user
-to sign up for service.
-
-To test for error cases in which connections to the carrier network
-always fail, use the --unconnectable flag. This is particularly
-useful when the initial state is set to activated as in:
-
- sudo fake-cromo -u -s activated
-
-This can be used to simulate the conditions of crosbug.com/11355
-
-Another simulation that corresponds to many field error conditions is
-a device that fails OTASP activation. This can be simulated by using
-the -a flag. The device should start in either the factory or partial
-state.
-
- sudo fake-cromo -a
-
-To test the re-up process, start the modem in the restricted state with
-
- sudo fake-cromo -s restricted
-
-One can leave the restricted state by fetching
-http://localhost:8080/payment_succeeded.html. This can be done via
-the UI by pressing "Buy Plan", or manually. On the next reconnect the
-user should be out of the restricted IP pool.
-
-If the program is interupted while a partially activated modem is in
-the connected state it may leave the iptables set up in a way that
-causes all tcp traffic to fail, even when using other network
-interfaces. Fix this by restarting fake cromo and tell it to leave
-the restricted IP pool
-
- sudo fake-cromo -l
-
-'''
- parser = OptionParser(usage=usage)
- parser.add_option('-u', '--unconnectable',
- action='store_false', dest='connectable',
- default=True,
- help='Do not allow modem to connect')
- parser.add_option('-s', '--state', dest='initial_state',
- type='choice',
- choices=['factory', 'partial',
- 'activated', 'restricted'],
- default='factory',
- help=('Set initial state to factory,'
- 'partial, restricted or activated'))
- parser.add_option('-a', '--activation_fails',
- action='store_false', dest='activatable',
- default=True,
- help='Do not allow modem to activate')
- parser.add_option('-l', '--leave-restricted-pool',
- action='store_true', dest='leave_restricted_pool',
- default=False,
- help='Leave the restricted pool and exit')
- parser.add_option('--connect-delay', type='int',
- dest='connect_delay_ms',
- default=flimflam_test.DEFAULT_CONNECT_DELAY_MS,
- help='time in ms required to connnect')
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.error("incorrect number of arguments")
-
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SystemBus()
- mm = Manager(bus, options)
- mainloop = gobject.MainLoop()
- print "Running test modemmanager."
- _ = dbus.service.BusName(flimflam_test.CMM, bus)
-
- if options.leave_restricted_pool:
- restrictor.leave(force=True)
- return 0
-
- # Choose the type of modem to instantiate...
- if options.initial_state == 'factory':
- mm.MakeFactoryResetModem()
- elif options.initial_state == 'partial':
- mm.MakePartiallyActivatedModem()
- elif options.initial_state == 'activated':
- mm.MakeActivatedModem()
- elif options.initial_state == 'restricted':
- mm.carrier.ConsumePlan()
- mm.MakeActivatedModem()
- else:
- print 'Invalid initial state: %s' % options.initial_state
- return 1
-
- try:
- mainloop.run()
- finally:
- restrictor.leave(force=True)
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/fake-gsm-modem b/test/fake-gsm-modem
deleted file mode 100755
index 1cc4e86..0000000
--- a/test/fake-gsm-modem
+++ /dev/null
@@ -1,190 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-#
-# Implement a pseudo gsm modem.
-#
-# This modem mimics a GSM modem and allows a user test shill, flimflam
-# and UI behaviors when a supported SIM is inserted into the device.
-#
-# Flimflam Testing
-# ================
-# To test when running flimflam you can either use an extra ethernet
-# port as the pseudo modem network interface, you you create a virtual
-# interface.
-#
-# To use eth0 as your pseudo modem rename it pseudo-modem0:
-# # backchannel setup eth0 pseudo-modem0
-#
-# and then run the fake modem program:
-# # fake-gsm-modem tmobile
-#
-# When done, clean up with:
-# # backchannel teardown eth0 pseudo-modem0
-#
-# Alternatively, you can create a virtual interface which will not
-# route packets anywhere, but will allow dhcp to succeed:
-# # ip link add name pseudo-modem0 type veth peer name pseudomodem0p
-#
-# When done, clean up with:
-# # ip link del pseudo-modem0
-#
-# Shill Testing
-# ================
-# To test when running shill, create a virtual interface called
-# pseudomodem0:
-#
-# # veth pseudomodem0 172.16.1
-#
-# then run the fake modem program:
-# # fake-gsm-modem -c tmobile --shill --smscount 3 --sms_signal 5
-#
-# which will start the fake GSM modem and cause shill to receive 3 new SMS
-# notifications. Don't pass --smscount and --sms_signal, if you don't want to
-# simulate SMS.
-#
-# when done, clean up with:
-# # veth teardown pseudomodem0
-#
-
-import glib
-import gobject
-from optparse import OptionParser
-import os
-import string
-import sys
-
-import dbus
-import dbus.mainloop.glib
-
-
-import_path = os.environ.get('SYSROOT', '/usr/local') + '/usr/lib/flimflam/test'
-sys.path.append(import_path)
-
-import flimflam_test
-GSM_Modem = flimflam_test.GSM_Modem
-ModemManager = flimflam_test.ModemManager
-SIM = flimflam_test.SIM
-
-DEFAULT_CARRIER = 'att'
-
-# A list of the supported carriers.
-SIM_LIST = {
- # Format for adding sims to the dictionary:
- # <Carrier_Name> : SIM( mcc_country = <country>,
- # mnc = <MNC>,
- # operator_name = <operator name>,
- # msin = <MSIN>,
- # mcc = <MCC>
- #
- # MCC value is favored over the mcc_country if both are
- # provided.
- 'att' : SIM('us', '090', 'AT&T'),
- 'tmobile' : SIM('us', '026', 'T-Mobile'),
- 'simyo' : SIM('de', '03', 'simyo'),
- 'movistar' : SIM('es', '07', 'Movistar'),
- 'sfr' : SIM('fr', '10', 'SFR'),
- 'three' : SIM('gb', '20', '3'),
- 'threeita' : SIM('it', '99', '3ITA'),
- 'kpn' : SIM('nl', '08', 'KPN'),
-}
-
-def make_sms(index, text):
- return {
- 'index': index,
- 'text' : text or 'Test SMS at %s' % index,
- 'number' : '+16175046925',
- 'timestamp' : '110919163047-04',
- 'smsc' : '+12063130028'
- }
-
-def main():
-
- usage = '''
-Run fake-gsm-modem to simulate a gsm modem with different sims.
-This can be used to simpilify the verification process of UI features
-that use overseas sims.
-
-To Use:
- 1) Device should be read/write and running a test image.
- 2) sudo mv /etc/init/cromo.conf
- 3) Reboot Device
- 4) Connect device using ethernet port and obtain <eth interface name>
- 5) cd /usr/local/lib/flimflam/test
- 6) ./backchannel setup <eth iface name> pseudo-modem0
- 7) ./fake-gsm-modem [--carrier=<carrier name>] &
-'''
-
- parser = OptionParser(usage=usage)
- parser.add_option('-c', '--carrier', dest='carrier_name',
- metavar='<carrier name>',
- help='<carrier name> := att | tmobile | simyo | '
- 'movistar | sfr | three | threeita | kpn')
- parser.add_option('-s', '--smscount', dest='sms_count',
- default=0,
- metavar='<smscount>',
- help='<smscount> := integer')
- parser.add_option('-S', '--sms_signal', dest='sms_signal',
- default=0,
- metavar='<delay>',
- help='<delay> := integer number of seconds')
- parser.add_option('-t', '--text', dest='sms_text',
- default=None,
- metavar='<text>',
- help='<text> := text for sms messages')
- parser.add_option('-f', '--file', dest='filename',
- default=None,
- metavar='<filename>',
- help='<filename> := file with text for sms messages')
- parser.add_option('-i', '--shill', dest='shill',
- default=False,
- action="store_true",
- help='use shill device names instead of flimflam names.')
-
- (options, _) = parser.parse_args()
-
- if not options.carrier_name:
- options.carrier_name = DEFAULT_CARRIER
-
- sim_card = SIM_LIST[string.lower(options.carrier_name)]
-
- smses = {}
- if options.filename:
- f = open(options.filename, 'r')
- for index, line in enumerate(f.readlines()):
- line = line.strip()
- if line:
- smses[index] = make_sms(index, line)
- else:
- for index in xrange(int(options.sms_count)):
- smses[index] = make_sms(index, options.sms_text)
-
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SystemBus()
- _ = dbus.service.BusName(flimflam_test.CMM, bus)
- manager = ModemManager(bus, flimflam_test.OCMM)
- device = 'pseudo-modem0'
- if options.shill:
- device = 'pseudomodem0'
- if options.sms_signal == 0:
- initial_smses = smses
- else:
- initial_smses = {}
-
- testmodem0 = GSM_Modem(manager, '/TestModem/0', gsm_sim=sim_card,
- smses=initial_smses, device=device)
-
- if options.sms_signal:
- def AddSmses():
- for sms in smses.values():
- testmodem0.AddSMS(sms)
- glib.timeout_add(1000*int(options.sms_signal), AddSmses)
-
- mainloop = gobject.MainLoop()
- print "Running test modemmanager."
- mainloop.run()
-
-if __name__ == '__main__':
- main()
diff --git a/test/flimflam.py b/test/flimflam.py
deleted file mode 100755
index 82c1c69..0000000
--- a/test/flimflam.py
+++ /dev/null
@@ -1,480 +0,0 @@
-# Copyright (c) 2012 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.
-
-import logging, time
-
-import dbus
-
-def make_dbus_boolean(value):
- value = value.upper()
- if value in ["ON", "TRUE"]:
- return dbus.Boolean(1)
- elif value in ["OFF", "FALSE"]:
- return dbus.Boolean(0)
- else:
- return dbus.Boolean(int(value))
-
-#
-# Convert a DBus value to a printable value; used
-# to print properties returned via DBus
-#
-def convert_dbus_value(value, indent=0):
- spacer = ' ' * indent
- if value.__class__ == dbus.Byte:
- return int(value)
- elif value.__class__ == dbus.Boolean:
- return bool(value)
- elif value.__class__ == dbus.Dictionary:
- valstr = "{"
- for key in value:
- valstr += "\n" + spacer + " " + \
- key + ": " + str(convert_dbus_value(value[key], indent + 4))
- valstr += "\n" + spacer + "}"
- return valstr
- elif value.__class__ == dbus.Array:
- valstr = "["
- for val in value:
- valstr += "\n" + spacer + " " + \
- str(convert_dbus_value(val, indent + 4))
- valstr += "\n" + spacer + "]"
- return valstr
- else:
- return str(value)
-
-class FlimFlam(object):
-
- SHILL_DBUS_INTERFACE = "org.chromium.flimflam"
- UNKNOWN_METHOD = 'org.freedesktop.DBus.Error.UnknownMethod'
-
- DEVICE_WIMAX = 'wimax'
- DEVICE_CELLULAR = 'cellular'
-
- @staticmethod
- def _GetContainerName(kind):
- """Map shill element names to the names of their collections."""
- # For example, Device - > Devices.
- # Just pulling this out so we can use a map if we start
- # caring about "AvailableTechnologies"
- return kind + "s"
-
- @staticmethod
- def WaitForServiceState(service, expected_states, timeout,
- ignore_failure=False, property_name="State"):
- """Wait until service enters a state in expected_states or times out.
- Args:
- service: service to watch
- expected_states: list of exit states
- timeout: in seconds
- ignore_failure: should the failure state be ignored?
- property_name: name of service property
-
- Returns: (state, seconds waited)
-
- If the state is "failure" and ignore_failure is False we return
- immediately without waiting for the timeout.
- """
-
- state = None
- start_time = time.time()
- timeout = start_time + timeout
- while time.time() < timeout:
- properties = service.GetProperties(utf8_strings = True)
- state = properties.get(property_name, None)
- if ((state == "failure" and not ignore_failure) or
- state in expected_states):
- break
- time.sleep(.5)
-
- config_time = time.time() - start_time
- # str() to remove DBus boxing
- return (str(state), config_time)
-
- @staticmethod
- def DisconnectService(service, wait_timeout=15):
- try:
- service.Disconnect()
- except dbus.exceptions.DBusException, error:
- if error.get_dbus_name() not in [
- FlimFlam.SHILL_DBUS_INTERFACE + ".Error.InProgress",
- FlimFlam.SHILL_DBUS_INTERFACE + ".Error.NotConnected", ]:
- raise error
- return FlimFlam.WaitForServiceState(service, ['idle'], wait_timeout)
-
- def __init__(self, bus=None):
- if not bus:
- bus = dbus.SystemBus()
- self.bus = bus
- shill = bus.get_object(FlimFlam.SHILL_DBUS_INTERFACE, "/")
- self.manager = dbus.Interface(
- shill,
- FlimFlam.SHILL_DBUS_INTERFACE + ".Manager")
-
- def _FindDevice(self, device_type, timeout):
- """ Return the first device object that matches a given device type.
-
- Wait until the device type is avilable or until timeout
-
- Args:
- device_type: string format of the type of device.
- timeout: in seconds
-
- Returns: Device or None
- """
- timeout = time.time() + timeout
- device_obj = None
- while time.time() < timeout:
- device_obj = self.FindElementByPropertySubstring('Device',
- 'Type',
- device_type)
- if device_obj:
- break
- time.sleep(1)
- return device_obj
-
- def FindCellularDevice(self, timeout=30):
- return self._FindDevice(self.DEVICE_CELLULAR, timeout)
-
- def FindWimaxDevice(self, timeout=30):
- return self._FindDevice(self.DEVICE_WIMAX, timeout)
-
- def _FindService(self, device_type, timeout):
- """Return the first service object that matches the device type.
-
- Wait until a service is available or until the timeout.
-
- Args:
- device_type: string format of the type of device.
- timeout: in seconds
-
- Returns: service or None
- """
- start_time = time.time()
- timeout = start_time + timeout
- service = None
- while time.time() < timeout:
- service = self.FindElementByPropertySubstring('Service',
- 'Type', device_type)
- if service:
- break
- time.sleep(.5)
- return service
-
- def FindCellularService(self, timeout=30):
- return self._FindService(self.DEVICE_CELLULAR, timeout)
-
- def FindWimaxService(self, timeout=30):
- return self._FindService(self.DEVICE_WIMAX, timeout)
-
- def GetService(self, params):
- path = self.manager.GetService(params)
- return self.GetObjectInterface("Service", path)
-
- def ConnectService(self, assoc_timeout=15, config_timeout=15,
- async=False, service=None, service_type='',
- retry=False, retries=1, retry_sleep=15,
- save_creds=False,
- **kwargs):
- """Connect to a service and wait until connection is up
- Args:
- assoc_timeout, config_timeout: Timeouts in seconds.
- async: return immediately. do not wait for connection.
- service: DBus service
- service_type: If supplied, invoke type-specific code to find service.
- retry: Retry connection after Connect failure.
- retries: Number of retries to allow.
- retry_sleep: Number of seconds to wait before retrying.
- kwargs: Additional args for type-specific code
-
- Returns:
- (success, dictionary), where dictionary contains stats and diagnostics.
- """
- output = {}
- connected_states = ["ready", "portal", "online"]
-
- # Retry connections on failure. Need to call GetService again as some
- # Connect failure states are unrecoverable.
- connect_success = False
- while not connect_success:
- if service_type == "wifi":
- try:
- # Sanity check to make sure the caller hasn't provided
- # both a service and a service type. At which point its
- # unclear what they actually want to do, so err on the
- # side of caution and except out.
- if service:
- raise Exception('supplied service and service type')
- params = {
- "Type": service_type,
- "Mode": kwargs["mode"],
- "SSID": kwargs["ssid"],
- "Security": kwargs.get("security", "none"),
- "SaveCredentials": save_creds }
- # Supply a passphrase only if it is non-empty.
- passphrase = kwargs.get("passphrase", "")
- if passphrase:
- params["Passphrase"] = passphrase
- path = self.manager.GetService(params)
- service = self.GetObjectInterface("Service", path)
- except Exception, e:
- output["reason"] = "FAIL(GetService): exception %s" % e
- return (False, output)
-
- output["service"] = service
-
- try:
- service.Connect()
- connect_success = True
- except Exception, e:
- if not retry or retries == 0:
- output["reason"] = "FAIL(Connect): exception %s" % e
- return (False, output)
- else:
- logging.info("INFO(Connect): connect failed. Retrying...")
- retries -= 1
-
- if not connect_success:
- # FlimFlam can be a little funny sometimes. At least for In
- # Progress errors, even though the service state may be failed,
- # it is actually still trying to connect. As such, while we're
- # waiting for retry, keep checking the service state to see if
- # it actually succeeded in connecting.
- state = FlimFlam.WaitForServiceState(
- service=service,
- expected_states=connected_states,
- timeout=retry_sleep,
- ignore_failure=True)[0]
-
- if state in connected_states:
- return (True, output)
-
- # While service can be caller provided, it is also set by the
- # GetService call above. If service was not caller provided we
- # need to reset it to None so we don't fail the sanity check
- # above.
- if service_type != '':
- service = None
-
- if async:
- return (True, output)
-
- logging.info("Associating...")
- (state, assoc_time) = (
- FlimFlam.WaitForServiceState(service,
- ["configuration"] + connected_states,
- assoc_timeout))
- output["state"] = state
- if state == "failure":
- output["reason"] = "FAIL(assoc)"
- if assoc_time > assoc_timeout:
- output["reason"] = "TIMEOUT(assoc)"
- output["assoc_time"] = assoc_time
- if "reason" in output:
- return (False, output)
-
-
- (state, config_time) = (
- FlimFlam.WaitForServiceState(service,
- connected_states, config_timeout))
- output["state"] = state
- if state == "failure":
- output["reason"] = "FAIL(config)"
- if config_time > config_timeout:
- output["reason"] = "TIMEOUT(config)"
- output["config_time"] = config_time
-
- if "reason" in output:
- return (False, output)
-
- return (True, output)
-
- def GetObjectInterface(self, kind, path):
- return dbus.Interface(
- self.bus.get_object(FlimFlam.SHILL_DBUS_INTERFACE, path),
- FlimFlam.SHILL_DBUS_INTERFACE + "." + kind)
-
- def FindElementByNameSubstring(self, kind, substring):
- properties = self.manager.GetProperties(utf8_strings = True)
- for path in properties[FlimFlam._GetContainerName(kind)]:
- if path.find(substring) >= 0:
- return self.GetObjectInterface(kind, path)
- return None
-
- def FindElementByPropertySubstring(self, kind, prop, substring):
- properties = self.manager.GetProperties(utf8_strings = True)
- for path in properties[FlimFlam._GetContainerName(kind)]:
- obj = self.GetObjectInterface(kind, path)
- try:
- obj_properties = obj.GetProperties(utf8_strings = True)
- except dbus.exceptions.DBusException, error:
- if error.get_dbus_name() == self.UNKNOWN_METHOD:
- # object disappeared; ignore and keep looking
- continue
- else:
- raise error
- if (prop in obj_properties and
- obj_properties[prop].find(substring) >= 0):
- return obj
- return None
-
- def GetObjectList(self, kind, properties=None):
- if properties is None:
- properties = self.manager.GetProperties(utf8_strings = True)
- return [self.GetObjectInterface(kind, path)
- for path in properties[FlimFlam._GetContainerName(kind)]]
-
- def GetActiveProfile(self):
- properties = self.manager.GetProperties(utf8_strings = True)
- return self.GetObjectInterface("Profile", properties["ActiveProfile"])
-
- def CreateProfile(self, ident):
- path = self.manager.CreateProfile(ident)
- return self.GetObjectInterface("Profile", path)
-
- def RemoveProfile(self, ident):
- self.manager.RemoveProfile(ident)
-
- def PushProfile(self, ident):
- path = self.manager.PushProfile(ident)
- return self.GetObjectInterface("Profile", path)
-
- def PopProfile(self, ident):
- self.manager.PopProfile(ident)
-
- def PopAnyProfile(self):
- self.manager.PopAnyProfile()
-
- def GetSystemState(self):
- properties = self.manager.GetProperties(utf8_strings = True)
- return properties["State"]
-
- def GetDebugTags(self):
- return self.manager.GetDebugTags()
-
- def ListDebugTags(self):
- return self.manager.ListDebugTags()
-
- def SetDebugTags(self, taglist):
- try:
- self.manager.SetDebugTags(taglist)
- self.SetDebugLevel(-4)
- except dbus.exceptions.DBusException, error:
- if error.get_dbus_name() not in [
- "org.freedesktop.DBus.Error.UnknownMethod" ]:
- raise error
-
- def SetDebugLevel(self, level):
- self.manager.SetDebugLevel(level)
-
- def GetServiceOrder(self):
- return self.manager.GetServiceOrder()
-
- def SetServiceOrder(self, new_order):
- old_order = self.GetServiceOrder()
- self.manager.SetServiceOrder(new_order)
- return (old_order, new_order)
-
- def EnableTechnology(self, tech):
- try:
- self.manager.EnableTechnology(tech)
- except dbus.exceptions.DBusException, error:
- if error.get_dbus_name() not in [
- FlimFlam.SHILL_DBUS_INTERFACE + ".Error.AlreadyEnabled" ]:
- raise error
-
- def DisableTechnology(self, tech):
- self.manager.DisableTechnology(tech, timeout=60)
-
- def RequestScan(self, technology):
- self.manager.RequestScan(technology)
-
- def GetCountry(self):
- properties = self.manager.GetProperties(utf8_strings = True)
- return properties["Country"]
-
- def SetCountry(self, country):
- self.manager.SetProperty("Country", country)
-
- def GetCheckPortalList(self):
- properties = self.manager.GetProperties(utf8_strings = True)
- return properties["CheckPortalList"]
-
- def SetCheckPortalList(self, tech_list):
- self.manager.SetProperty("CheckPortalList", tech_list)
-
- def GetPortalURL(self):
- properties = self.manager.GetProperties(utf8_strings = True)
- return properties["PortalURL"]
-
- def SetPortalURL(self, url):
- self.manager.SetProperty("PortalURL", url)
-
- def GetArpGateway(self):
- properties = self.manager.GetProperties()
- return properties["ArpGateway"]
-
- def SetArpGateway(self, do_arp_gateway):
- self.manager.SetProperty("ArpGateway", do_arp_gateway)
-
-
-class DeviceManager(object):
- """Use flimflam to isolate a given interface for testing.
-
- DeviceManager can be used to turn off network devices that are not
- under test so that they will not interfere with testing.
-
- NB: Ethernet devices are special inside Flimflam. You will need to
- take care of them via other means (like, for example, the
- backchannel ethernet code in client autotests)
-
- Sample usage:
-
- device_manager = flimflam.DeviceManager()
- try:
- device_manager.ShutdownAllExcept('cellular')
- use routing.getRouteFor()
- to verify that only the expected device is used
- do stuff to test cellular connections
- finally:
- device_manager.RestoreDevices()
- """
-
- @staticmethod
- def _EnableDevice(device, enable):
- """Enables/Disables a device in shill."""
- if enable:
- device.Enable()
- else:
- device.Disable()
-
- def __init__(self, flim=None):
- self.flim_ = flim or FlimFlam()
- self.devices_to_restore_ = []
-
- def ShutdownAllExcept(self, device_type):
- """Shutdown all devices except device_type ones."""
- for device in self.flim_.GetObjectList('Device'):
- device_properties = device.GetProperties(utf8_strings = True)
- if (device_properties["Type"] != device_type):
- logging.info("Powering off %s device %s",
- device_properties["Type"],
- device.object_path)
- self.devices_to_restore_.append(device.object_path)
- DeviceManager._EnableDevice(device, False)
-
- def RestoreDevices(self):
- """Restore devices powered down in ShutdownAllExcept."""
- should_raise = False
- to_raise = Exception("Nothing to raise")
- for device_path in self.devices_to_restore_:
- try:
- logging.info("Attempting to power on device %s", device_path)
- device = self.flim_.GetObjectInterface("Device", device_path)
- DeviceManager._EnableDevice(device, True)
- except Exception, e:
- # We want to keep on trying to power things on, so save an
- # exception and continue
- should_raise = True
- to_raise = e
- if should_raise:
- raise to_raise
diff --git a/test/flimflam_test.py b/test/flimflam_test.py
deleted file mode 100644
index 7e436bf..0000000
--- a/test/flimflam_test.py
+++ /dev/null
@@ -1,498 +0,0 @@
-#!/usr/bin/env python
-# Simulates an implementation of ModemManager to test the flimflam modemmanager
-# plugin. Test cases should probably subclass Modem.
-
-import datetime
-import gobject
-import time
-
-import dbus
-import dbus.mainloop.glib
-import dbus.service
-from dbus.exceptions import DBusException
-from dbus.types import UInt32
-import glib
-
-OFDP = 'org.freedesktop.DBus.Properties'
-MM = 'org.freedesktop.ModemManager'
-CMM = 'org.chromium.ModemManager'
-OCMM = '/org/chromium/ModemManager'
-
-# Modem States
-STATE_UNKNOWN = 0
-STATE_DISABLED = 10
-STATE_DISABLING = 20
-STATE_ENABLING = 30
-STATE_ENABLED = 40
-STATE_SEARCHING = 50
-STATE_REGISTERED = 60
-STATE_DISCONNECTING = 70
-STATE_CONNECTING = 80
-STATE_CONNECTED = 90
-
-# State Change Reasons
-REASON_UNKNOWN = 0
-REASON_USER_REQUESTED = 1
-REASON_SUSPEND = 2
-
-# Miscellaneous delays to simulate a *fast* modem
-ACTIVATION_DELAY_MS = 500
-DISCARD_MODEM_DELAY_MS = 1000
-REBOOT_DELAY_MS = 2000
-DEFAULT_CONNECT_DELAY_MS = 1500
-
-# List of GSM Registration Status
-GSM_REG_STATUS_IDLE = 0
-GSM_REG_STATUS_HOME = 1
-GSM_REG_STATUS_SEARCHING = 2
-GSM_REG_STATUS_DENIED = 3
-GSM_REG_STATUS_UNKNOWN = 4
-GSM_REG_STATUS_ROAMING = 5
-
-def TimestampLog(message):
- print (unicode(datetime.datetime.now()) + message)
-
-class FakeError(RuntimeError):
- pass
-
-
-class OperationInitiated(DBusException):
- _dbus_error_name = 'org.chromium.ModemManager.Error.OperationInitiated'
- include_traceback = False
-
-
-class ConnectError(DBusException):
- _dbus_error_name = 'org.chromium.ModemManager.Error.ConnectError'
- include_traceback = False
-
-
-class SIM(object):
- """ SIM Object
-
- Mock SIM Card and the typical information it might contain.
- SIM cards of different carriers can be created by providing
- the MCC, MNC, operator name, and msin. SIM objects are passed
- to the Modem during Modem initialization.
- """
- DEFAULT_MCC = '310'
- DEFAULT_MNC = '090'
- DEFAULT_OPERATOR = 'AT&T'
- DEFAULT_MSIN = '1234567890'
-
- MCC_LIST = {
- 'us' : '310',
- 'de' : '262',
- 'es' : '214',
- 'fr' : '208',
- 'gb' : '234',
- 'it' : '222',
- 'nl' : '204',
- }
-
- def __init__(self, mcc_country='us',
- mnc=DEFAULT_MNC,
- operator_name=DEFAULT_OPERATOR,
- msin=DEFAULT_MSIN,
- mcc=None):
- if mcc:
- self.mcc = mcc
- else:
- self.mcc = SIM.MCC_LIST.get(mcc_country, '000')
- self.mnc = mnc
- self.operator_name = operator_name
- self.msin = msin
-
-
-class Modem(dbus.service.Object):
- NOT_ACTIVATED = UInt32(0)
- ACTIVATING = UInt32(1)
- PARTIALLY_ACTIVATED = UInt32(2)
- ACTIVATED = UInt32(3)
-
- MM_TYPE_GSM = UInt32(1)
- MM_TYPE_CDMA = UInt32(2)
-
- MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY = UInt32(4)
- MM_MODEM_GSM_ACCESS_TECH_HSPA = UInt32(8)
-
- # Define the default sim to have AT&T carrier information
-
- def __init__(self, manager, name,
- activation_state=NOT_ACTIVATED,
- mdn='0000001234',
- meid='A100000DCE2CA0',
- carrier='CrCarrier',
- esn='EDD1EDD1',
- payment_url=('http://localhost:8080/'
- 'mobile_activation.html'),
- usage_url='http://localhost:8080/usage.html',
- technology=UInt32(1),
- modem_type=MM_TYPE_CDMA,
- device='pseudomodem0'):
- self.state = STATE_UNKNOWN
- self.name = name
- self.path = manager.path + name
- self.manager = manager
- self.activation_state = activation_state
- self.mdn = mdn
- self.meid = meid
- self.carrier = carrier
- self.esn = esn
- self.payment_url = payment_url
- self.usage_url = usage_url
- self.technology = technology
- self.modem_type = modem_type
- self.device = device
- dbus.service.Object.__init__(self, manager.bus, self.path)
- self.manager.add(self)
- self._default_signal_quality = UInt32(100)
- self._band_class = UInt32(2)
- self._band = 'F'
- self._system_id = UInt32(2004)
- self._modem_info = ('Initech', 'Modemtron 1.00', '0.42')
-
- def DiscardModem(self):
- """
- Discard this DBUS Object
-
- Send a message that a modem has disappeared
- Deregister from DBUS
- """
- TimestampLog('DiscardModem')
- self.remove_from_connection()
- self.manager.remove(self)
-
- @dbus.service.method(OFDP, in_signature='s', out_signature='a{sv}')
- def GetAll(self, iface, *_args, **_kwargs):
- TimestampLog('Modem: GetAll %s' % iface)
- properties = {}
- if (iface == MM + '.Modem' or
- iface == MM + '.Modem.Cdma'):
- properties = {'Device': self.device,
- 'MasterDevice': '/fake',
- 'Driver': 'fake',
- 'Type': self.modem_type,
- 'Enabled': False,
- 'Meid': self.meid,
- 'IpMethod': UInt32(2)
- }
-
- return properties
-
- @dbus.service.method(OFDP, in_signature='ss', out_signature='v')
- def Get(self, iface, propname):
- TimestampLog('Modem: Get %s - %s' % (iface, propname))
- return self.GetAll(iface)[propname]
-
- @dbus.service.method(MM + '.Modem', in_signature='b', out_signature='')
- def Enable(self, on, *_args, **_kwargs):
- TimestampLog('Modem: Enable %s' % str(on))
- if on:
- self.state = STATE_ENABLED
- glib.timeout_add(50, self.OnRegistered)
- else:
- self.state = STATE_DISABLED
- return None
-
- def OnRegistered(self):
- TimestampLog('Modem: OnRegistered')
- if self.state == STATE_ENABLED:
- self.state = STATE_REGISTERED
- self.RegistrationStateChanged(UInt32(2), UInt32(2))
-
- @dbus.service.signal(MM + '.Modem.Cdma', signature='uu')
- def RegistrationStateChanged(self, cdma_1x_state, evdo_state):
- pass
-
- @dbus.service.method(MM + '.Modem.Simple', in_signature='',
- out_signature='a{sv}')
- def GetStatus(self, *_args, **_kwargs):
- TimestampLog('Modem: GetStatus')
- a = { 'state': UInt32(self.state),
- 'activation_state': self.activation_state,
- 'carrier': self.carrier,
- 'esn': self.esn,
- 'mdn': self.mdn,
- 'min': self.mdn,
- 'payment_url': self.payment_url,
- 'usage_url': self.usage_url,
- 'technology': self.technology,
- }
- if self.state >= STATE_ENABLED:
- a['carrier'] = 'Test Network'
- return a
-
- @dbus.service.signal(MM + '.Modem', signature='uuu')
- def StateChanged(self, old_state, new_state, why):
- pass
-
- def ConnectDone(self, old, new, why):
- TimestampLog('Modem: ConnectDone %s -> %s because %s' % (
- str(old), str(new), str(why)))
- self.state = new
- self.StateChanged(UInt32(old), UInt32(new), UInt32(why))
-
- @dbus.service.method(MM + '.Modem.Simple', in_signature='a{sv}',
- out_signature='')
- def Connect(self, _props, *_args, **kwargs):
- TimestampLog('Modem: Connect')
- if self.state != STATE_REGISTERED:
- raise ConnectError()
- delay_ms = kwargs.get('connect_delay_ms', DEFAULT_CONNECT_DELAY_MS)
- time.sleep(delay_ms / 1000.0)
- self.state = STATE_CONNECTING
- glib.timeout_add(50,
- lambda: self.ConnectDone(self.state,
- STATE_CONNECTED,
- REASON_USER_REQUESTED))
-
- @dbus.service.method(MM + '.Modem')
- def Disconnect(self, *_args, **_kwargs):
- TimestampLog('Modem: Disconnect')
- self.state = STATE_DISCONNECTING
- glib.timeout_add(500,
- lambda: self.ConnectDone(self.state,
- STATE_REGISTERED,
- REASON_USER_REQUESTED))
- raise OperationInitiated()
-
- @dbus.service.signal(MM + '.Modem.Cdma', signature='uua{sv}')
- def ActivationStateChanged(self, state, error, status_changes):
- pass
-
- def ActivateDone(self, new_activation_state, new_modem_factory, _new_mdn,
- discard_modem_delay_ms=DISCARD_MODEM_DELAY_MS,
- reboot_delay_ms=REBOOT_DELAY_MS):
- TimestampLog('Modem: ActivateDone: _state = %d' % new_activation_state)
- self.ActivationStateChanged(new_activation_state, 0,
- dict(mdn=str(self.mdn),
- min=str(self.mdn)))
- self.state = STATE_UNKNOWN
- glib.timeout_add(discard_modem_delay_ms, self.DiscardModem)
- glib.timeout_add(reboot_delay_ms, new_modem_factory)
-
- @dbus.service.method(MM + '.Modem.Cdma', in_signature='s',
- out_signature='')
- def Activate(self, s, *args, **kwargs):
- # It isn't entirely clear to me how inheritence works in combination
- # with dbus method decorator magic, so lets just delegate to an impl
- # stub that subclasses can override if they like.
- self.ActivateImpl(s, args, kwargs)
-
- def ActivateImpl(self, _s, _args, _kwargs):
- raise NotImplementedError('Unimplemented. Must implement in subclass.')
-
- def StartActivation(self, new_activation_state, factory, new_mdn):
- self.activation_state = self.ACTIVATING
- glib.timeout_add(ACTIVATION_DELAY_MS,
- lambda: self.ActivateDone(new_activation_state,
- factory,
- new_mdn))
- raise OperationInitiated()
-
- def FailedActivateDone(self, old_activation_state, carrier_error):
- TimestampLog('Modem: FailedActivateDone')
- self.activation_state = old_activation_state
- self.ActivationStateChanged(old_activation_state,
- carrier_error,
- dict(mdn=str(self.mdn),
- min=str(self.mdn)))
-
- def StartFailedActivation(self, carrier_error):
- old_activation_state = self.activation_state
- self.activation_state = self.ACTIVATING
- glib.timeout_add(ACTIVATION_DELAY_MS,
- lambda: self.FailedActivateDone(old_activation_state,
- carrier_error))
- raise OperationInitiated()
-
- @dbus.service.method(MM + '.Modem.Cdma', in_signature='',
- out_signature='uu')
- def GetRegistrationState(self, *_args, **_kwargs):
- TimestampLog('Modem: GetRegistrationState')
- if self.state >= STATE_REGISTERED:
- cdma_1x_state = UInt32(2)
- evdo_state = UInt32(2)
- else:
- cdma_1x_state = UInt32(0)
- evdo_state = UInt32(0)
- return (cdma_1x_state, evdo_state)
-
- @dbus.service.method(MM + '.Modem.Cdma', in_signature='',
- out_signature='u')
- def GetSignalQuality(self, *_args, **_kwargs):
- TimestampLog('Modem: GetSignalQuality')
- return self._default_signal_quality
-
- @dbus.service.method(MM + '.Modem.Cdma', in_signature='',
- out_signature='(usu)')
- def GetServingSystem(self, *_args, **_kwargs):
- TimestampLog('Modem: GetServingSystem')
- return (self._band_class, self._band, self._system_id)
-
- @dbus.service.method(MM + '.Modem.Cdma', in_signature='',
- out_signature='s')
- def GetEsn(self, *_args, **_kwargs):
- TimestampLog('Modem: GetEsn')
- return self.esn
-
- @dbus.service.method(MM + '.Modem', in_signature='',
- out_signature='(sss)')
- def GetInfo(self, *_args, **_kwargs):
- TimestampLog('Modem: GetInfo')
- return self._modem_info
-
-
-class GSM_Modem(Modem):
- def __init__(self, *args, **kwargs):
- gsm_sim = kwargs.get('gsm_sim', SIM())
- kwargs.pop('gsm_sim')
- smses = kwargs.get('smses', SIM())
- kwargs.pop('smses')
- kwargs['modem_type'] = Modem.MM_TYPE_GSM
- Modem.__init__(self, *args, **kwargs)
- self.gsm_sim = gsm_sim
- self.smses = smses
- self._imei = '490154203237518'
-
- @dbus.service.method(OFDP, in_signature='s', out_signature='a{sv}')
- def GetAll(self, iface, *args, **kwargs):
- TimestampLog('GSM_Modem: GetAll %s' % iface)
- properties = {}
- if (iface == MM + '.Modem.Gsm.Network'):
- properties = {
- 'AllowedMode' : Modem.MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY,
- 'AccessTechnology' : Modem.MM_MODEM_GSM_ACCESS_TECH_HSPA
- }
- elif (iface == MM + '.Modem.Gsm.Card'):
- properties = {
- 'EnabledFacilityLocks' : UInt32(0)
- }
- else:
- properties = Modem.GetAll(self, iface, args, kwargs)
-
- return properties
-
-
- @dbus.service.method(MM + '.Modem.Gsm.Card', in_signature='',
- out_signature='s')
- def GetImei(self, *_args, **_kwargs):
- TimestampLog('Gsm: GetImei')
- return self._imei
-
- @dbus.service.method(MM + '.Modem.Gsm.Card', in_signature='',
- out_signature='s')
- def GetImsi(self, *_args, **_kwargs):
- TimestampLog('Gsm: GetImsi')
- return self.gsm_sim.mcc + self.gsm_sim.mnc + self.gsm_sim.msin
-
- @dbus.service.method(MM + '.Modem.Gsm.Network', in_signature='s',
- out_signature='')
- def Register(self, s, *args, **kwargs):
- pass
-
- @dbus.service.signal(MM + '.Modem.Gsm.Network', signature='(uss)')
- def RegistrationInfo(self, arr, *args, **kwargs):
- pass
-
- @dbus.service.signal(MM + '.Modem.Gsm.Network', signature='u')
- def NetworkMode(self, u, *args, **kwargs):
- pass
-
- @dbus.service.method(MM + '.Modem.Gsm.Network', in_signature='',
- out_signature='s')
- def SetApn(self, *args, **kwargs):
- pass
-
- @dbus.service.method(MM + '.Modem.Gsm.Network', in_signature='',
- out_signature='u')
- def GetSignalQuality(self, *_args, **_kwargs):
- TimestampLog('Network: GetSignalQuality')
- return 100.0
-
- @dbus.service.method(MM + '.Modem.Gsm.Network', in_signature='',
- out_signature='(uss)')
- def GetRegistrationInfo(self, *_args, **_kwargs):
- TimestampLog('GSM: GetRegistrationInfo')
- registration_status = GSM_REG_STATUS_HOME
-
- return (registration_status, self.gsm_sim.mcc + self.gsm_sim.mnc,
- self.gsm_sim.operator_name)
-
- def AddSMS(self, sms):
- TimestampLog('Adding SMS to list')
- self.smses[sms['index']] = sms
- self.SmsReceived(sms['index'], True)
-
- @dbus.service.method(MM + '.Modem.Gsm.SMS', in_signature='',
- out_signature='aa{sv}')
- def List(self, *_args, **_kwargs):
- TimestampLog('Gsm.SMS: List')
- return self.smses.values()
-
- @dbus.service.method(MM + '.Modem.Gsm.SMS', in_signature='u',
- out_signature='')
- def Delete(self, index, *_args, **_kwargs):
- TimestampLog('Gsm.SMS: Delete %s' % index)
- del self.smses[index]
-
- @dbus.service.method(MM + '.Modem.Gsm.SMS', in_signature='u',
- out_signature='a{sv}')
- def Get(self, index, *_args, **_kwargs):
- TimestampLog('Gsm.SMS: Get %s' % index)
- return self.smses[index]
-
- @dbus.service.signal(MM + '.Modem.Gsm.SMS', signature='ub')
- def SmsReceived(self, index, complete):
- pass
-
- def ActivateImpl(self, _s, _args, _kwargs):
- raise NotImplementedError('Unimplemented. Must implement in subclass.')
-
-class ModemManager(dbus.service.Object):
- def __init__(self, bus, path):
- self.devices = []
- self.bus = bus
- self.path = path
- dbus.service.Object.__init__(self, bus, path)
-
- def add(self, dev):
- TimestampLog('ModemManager: add %s' % dev.name)
- self.devices.append(dev)
- self.DeviceAdded(dev.path)
-
- def remove(self, dev):
- TimestampLog('ModemManager: remove %s' % dev.name)
- self.devices.remove(dev)
- self.DeviceRemoved(dev.path)
-
- @dbus.service.method('org.freedesktop.ModemManager',
- in_signature='', out_signature='ao')
- def EnumerateDevices(self, *_args, **_kwargs):
- devices = map(lambda d: d.path, self.devices)
- TimestampLog('EnumerateDevices: %s' % ', '.join(devices))
- return devices
-
- @dbus.service.signal(MM, signature='o')
- def DeviceAdded(self, path):
- pass
-
- @dbus.service.signal(MM, signature='o')
- def DeviceRemoved(self, path):
- pass
-
-
-def main():
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SystemBus()
- _ = dbus.service.BusName(CMM, bus)
- manager = ModemManager(bus, OCMM)
- # The Modem constructor registers itself with the manager.
- Modem(manager, '/TestModem/0')
-
- mainloop = gobject.MainLoop()
- TimestampLog("Running test modemmanager.")
- mainloop.run()
-
-if __name__ == '__main__':
- main()
diff --git a/test/get-arp-gateway b/test/get-arp-gateway
deleted file mode 100644
index e9b01b5..0000000
--- a/test/get-arp-gateway
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-print "ArpGateway is %s" % flim.GetArpGateway()
diff --git a/test/get-country b/test/get-country
deleted file mode 100755
index 4533707..0000000
--- a/test/get-country
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-print "Country is %s" % flim.GetCountry()
diff --git a/test/get-portal-list b/test/get-portal-list
deleted file mode 100755
index 8769499..0000000
--- a/test/get-portal-list
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-print "Check portal list is %s" % flim.GetCheckPortalList()
diff --git a/test/get-portal-url b/test/get-portal-url
deleted file mode 100755
index c39c232..0000000
--- a/test/get-portal-url
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-print "Portal URL is %s" % flim.GetPortalURL()
diff --git a/test/get-service b/test/get-service
deleted file mode 100755
index f9c335f..0000000
--- a/test/get-service
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/python
-
-import dbus
-import flimflam
-import sys
-
-if len(sys.argv) < 2:
- print "Usage: %s <GUID> [<property> <value>]" % (sys.argv[0])
- sys.exit(1)
-
-print "Attempting to configure service %s" % (sys.argv[1])
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-params = { "GUID" : sys.argv[1] }
-argv = sys.argv[2:]
-while argv:
- property_key = argv[0]
- value = argv[1]
- if property_key in ["Priority"]:
- params[property_key] = int(value)
- elif property_key in ["AutoConnect", "WiFi.HiddenSSID", "EAP.UseSystemCAS",
- "SaveCredentials"]:
- params[property_key] = dbus.Boolean(value.lower() in ("true", "1"))
- else:
- params[property_key] = value
-
- argv = argv[2:]
-
-service = flim.GetService(params)
-properties = service.GetProperties(utf8_strings = True)
-
-print "[ %s ]" % (service.object_path)
-
-for key in properties.keys():
- print " %s = %s" % \
- (key, flimflam.convert_dbus_value(properties[key], 4))
-
-print
diff --git a/test/get-state b/test/get-state
deleted file mode 100755
index e213d3d..0000000
--- a/test/get-state
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-print "System is %s" % flim.GetSystemState()
diff --git a/test/list-devices b/test/list-devices
deleted file mode 100755
index 0e3bb3c..0000000
--- a/test/list-devices
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-for obj in flim.GetObjectList("Device"):
- obj_properties = obj.GetProperties(utf8_strings = True)
-
- print "[ %s ]" % (obj.object_path)
- for key in obj_properties.keys():
- print " %s = %s" % \
- (key, flimflam.convert_dbus_value(obj_properties[key], 4))
-
-print
diff --git a/test/list-entries b/test/list-entries
deleted file mode 100755
index e16eb47..0000000
--- a/test/list-entries
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-active = flim.GetActiveProfile()
-
-for profile in flim.GetObjectList("Profile"):
- if profile.object_path == active.object_path:
- print "[ %s ] <== active" % (profile.object_path)
- else:
- print "[ %s ]" % (profile.object_path)
-
- properties = profile.GetProperties(utf8_strings = True)
- if not "Entries" in properties:
- continue
- for ident in properties["Entries"]:
- entry = profile.GetEntry(ident)
- print " [%s] = %s" % (ident, flimflam.convert_dbus_value(entry, 4))
diff --git a/test/list-ipconfigs b/test/list-ipconfigs
deleted file mode 100755
index 99eb0b0..0000000
--- a/test/list-ipconfigs
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <device | interface>" % (sys.argv[0])
- sys.exit(1)
-
-(_, name) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-device = flim.FindElementByNameSubstring('Device', name)
-if device is None:
- device = flim.FindElementByPropertySubstring('Device', 'Interface', name)
-if device is None:
- print "No such device or interface %s" % name
- sys.exit(1)
-
-properties = device.GetProperties(utf8_strings = True)
-for path in properties["IPConfigs"]:
- ipconfig = flim.GetObjectInterface("IPConfig", path)
- ipconfig_properties = ipconfig.GetProperties(utf8_strings = True)
-
- print "[ %s ]" % (ipconfig.object_path)
-
- for key in ipconfig_properties.keys():
- print " %s = %s" % \
- (key, flimflam.convert_dbus_value(ipconfig_properties[key], 8))
-
-print
diff --git a/test/list-profiles b/test/list-profiles
deleted file mode 100755
index 9a159fd..0000000
--- a/test/list-profiles
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-active = flim.GetActiveProfile()
-
-for profile in flim.GetObjectList("Profile"):
- if profile.object_path == active.object_path:
- print "[ %s ] <== active" % (profile.object_path)
- else:
- print "[ %s ]" % (profile.object_path)
-
- properties = profile.GetProperties(utf8_strings = True)
- for key in properties.keys():
- print " %s = %s" % \
- (key, flimflam.convert_dbus_value(properties[key], 4))
-
- print
diff --git a/test/list-services b/test/list-services
deleted file mode 100755
index 97c4dc6..0000000
--- a/test/list-services
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-for service in flim.GetObjectList("Service"):
- properties = service.GetProperties(utf8_strings = True)
-
- print "[ %s ]" % (service.object_path)
-
- for key in properties.keys():
- print " %s = %s" % \
- (key, flimflam.convert_dbus_value(properties[key], 4))
-
- print
diff --git a/test/mm-activate b/test/mm-activate
deleted file mode 100755
index 38b9d20..0000000
--- a/test/mm-activate
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-import sys
-
-def Usage(prog):
- print ("Usage: %s <carrier-name> [<device path substring>]") % prog
-
-if len(sys.argv) < 2 or len(sys.argv) > 3:
- Usage(sys.argv[0])
- sys.exit(1)
-
-carrier = sys.argv[1]
-if len(sys.argv) < 3:
- modem_pattern = ''
-else:
- modem_pattern = sys.argv[2]
-
-manager, path = mm.PickOneModem(modem_pattern)
-modem = manager.CdmaModem(path)
-modem.Activate(carrier)
diff --git a/test/mm-connect b/test/mm-connect
deleted file mode 100755
index aad06b3..0000000
--- a/test/mm-connect
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-#
-# Call the Simple.Connect API.
-#
-
-import gobject
-import dbus
-import dbus.mainloop.glib
-import mm
-import sys
-from optparse import OptionParser
-
-def state_changed(_, new_state, _, modem_path):
- """
- _ (old_state): Previous modem state (but unused).
- new_state: New modem state.
- _ (reason): Reason for transition (but unused).
- modem_path: Path of the modem object for this status update.
- """
- if new_state == 90:
- print "Connection established for", modem_path
- else:
- print "Connection failed for", modem_path
- mainloop.quit()
-
-usage = '%prog [options]'
-
-parser = OptionParser(usage=usage)
-parser.add_option('--apn', type='string',
- dest='apn',
- default=None,
- help='apn to supply to the connect operation')
-parser.add_option('--username', type='string',
- dest='username',
- default=None,
- help='user name to supply to the connect operation')
-parser.add_option('--password', type='string',
- dest='password',
- default=None,
- help='password to supply to the connect operation')
-parser.add_option('--number', type='string',
- dest='number',
- default=None,
- help='phone number to supply to the connect operation')
-parser.add_option('--carrier', type='choice',
- dest='carrier',
- choices=['tmobile', 'sprint', 'att', 'verizon'],
- default=None,
- help='Specifies the carrier. Provided as a convenience '
- 'to avoid having to supply an APN or phone number.')
-parser.add_option('-w', '--wait',
- action='store_true', dest='wait',
- default=False,
- help='Wait until connection completes or fails '
- '(default: %default)')
-
-(options, args) = parser.parse_args()
-if len(args) > 1:
- parser.error("incorrect number of arguments")
-
-props = dict()
-
-carriers = dict(
- att=dict(number="*99#", apn='broadband'),
- tmobile=dict(number="*99#", apn='epc.tmobile.com'),
- sprint=dict(number="#777"),
- verizon=dict(number="#777"),
-)
-
-if len(args) < 1:
- modem_pattern = ''
-else:
- modem_pattern = args[0]
-
-if options.carrier:
- try:
- props = carriers[options.carrier]
- except KeyError:
- parser.error("Unknown carrier '%s'." % options.carrier)
- sys.exit(1)
-
-if options.apn:
- props['apn'] = options.apn
-if options.username:
- props['username'] = options.username
-if options.password:
- props['password'] = options.password
-if options.number:
- props['number'] = options.number
-
-dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
-manager, path = mm.PickOneModem(modem_pattern)
-modem = manager.CdmaModem(path)
-
-print "Connecting", path
-
-if options.wait:
- bus = dbus.SystemBus()
- bus.add_signal_receiver(state_changed,
- bus_name=manager.provider,
- signal_name="StateChanged",
- path_keyword="path")
-
-modem = manager.SimpleModem(path)
-try:
- modem.Connect(props)
- options.wait = False
-except dbus.exceptions.DBusException, e:
- if (e.get_dbus_name() !=
- "org.chromium.ModemManager.Error.OperationInitiated"):
- raise e
-
-if options.wait:
- mainloop = gobject.MainLoop()
- mainloop.run()
diff --git a/test/mm-disable b/test/mm-disable
deleted file mode 100755
index 61253bc..0000000
--- a/test/mm-disable
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-
-devices = mm.EnumerateDevices()
-
-for manager, path in devices:
- print path
-
- modem = manager.Modem(path)
-
- modem.Enable(False)
diff --git a/test/mm-disconnect b/test/mm-disconnect
deleted file mode 100755
index 6f71243..0000000
--- a/test/mm-disconnect
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-import dbus
-import dbus.mainloop.glib
-import gobject
-import sys
-
-waitcnt = 0
-def state_changed(_, new_state, _, modem_path):
- """
- _ (old_state): Previous modem state (but unused).
- new_state: New modem state.
- _ (reason): Reason for transition (but unused).
- modem_path: Path of the modem object for this status update.
- """
- global waitcnt
- if new_state == 60:
- print "Disconnect completed for", modem_path
- else:
- print "Disconnect failed for", modem_path
- waitcnt -= 1
- if waitcnt <= 0:
- mainloop.quit()
-
-waitflag = False
-if len(sys.argv) > 1 and sys.argv[1] == '-w':
- waitflag = True
- del sys.argv[1]
-
-dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
-if waitflag:
- bus = dbus.SystemBus()
- bus.add_signal_receiver(state_changed,
- bus_name=mm.ModemManager.INTERFACE,
- signal_name="StateChanged",
- path_keyword="path")
-
-devices = mm.EnumerateDevices()
-
-for manager, path in devices:
-
- print "Disconnecting", path
-
- modem = manager.Modem(path)
- try:
- modem.Disconnect()
- except dbus.exceptions.DBusException, e:
- if (e.get_dbus_name() ==
- "org.chromium.ModemManager.Error.OperationInitiated"):
- waitcnt += 1
- else:
- raise e
-
-if waitflag and waitcnt != 0:
- mainloop = gobject.MainLoop()
- mainloop.run()
diff --git a/test/mm-enable b/test/mm-enable
deleted file mode 100755
index 56cdb14..0000000
--- a/test/mm-enable
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-
-devices = mm.EnumerateDevices()
-
-for manager, path in devices:
- print path
-
- modem = manager.Modem(path)
-
- modem.Enable(True)
diff --git a/test/mm-factory-reset b/test/mm-factory-reset
deleted file mode 100644
index 3459007..0000000
--- a/test/mm-factory-reset
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-import sys
-
-def Usage(prog):
- print ("Usage: %s spc "
- "<device path substring>") % prog
-
-if len(sys.argv) < 2 or len(sys.argv) > 3:
- Usage(sys.argv[0])
- sys.exit(1)
-
-spc = sys.argv[1]
-
-if len(sys.argv) < 3:
- modem_pattern = ''
-else:
- modem_pattern = sys.argv[2]
-
-manager, path = mm.PickOneModem(modem_pattern)
-modem = manager.Modem(path)
-modem.FactoryReset(spc)
diff --git a/test/mm-list-modems b/test/mm-list-modems
deleted file mode 100755
index dca8cc1..0000000
--- a/test/mm-list-modems
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-
-devices = mm.EnumerateDevices()
-
-for manager, path in devices:
- print path
diff --git a/test/mm-mock b/test/mm-mock
deleted file mode 100644
index a7cb536..0000000
--- a/test/mm-mock
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2009 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.
-
-import os
-import unittest
-
-import dbus
-import dbus.mainloop.glib
-import dbus.service
-import gobject
-import mox
-
-
-OFDP = 'org.freedesktop.DBus.Properties'
-OFM = 'org.freedesktop.ModemManager'
-OFMM = OFM + '.Modem'
-
-
-class ModemManager(dbus.service.Object):
- """Glue between DBUS ModemManager interface and a mock ModemManager."""
-
- def __init__(self, mocker, *args, **kwargs):
- dbus.service.Object.__init__(self, *args, **kwargs)
- self.mock = mocker.CreateMock(ModemManager)
-
- @dbus.service.signal(OFM, signature='o')
- def DeviceAdded(self, o):
- pass # signal
-
- @dbus.service.signal(OFM, signature='o')
- def DeviceRemoved(self, o):
- pass # signal
-
- @dbus.service.method(OFM, in_signature='', out_signature='ao')
- def EnumerateDevices(self):
- return self.mock.EnumerateDevices()
-
-
-class Modem(dbus.service.Object):
- """Glue between DBUS Modem interface and a mock Modem."""
-
- def __init__(self, mocker, *args, **kwargs):
- dbus.service.Object.__init__(self, *args, **kwargs)
- self.mock = mocker.CreateMock(Modem)
-
- @dbus.service.method(OFDP, in_signature='s')
- def GetAll(self, interface):
- return self.mock.GetAll(interface)
-
- @dbus.service.method(OFMM, in_signature='b')
- def Enable(self, enable):
- self.mock.Enable(enable)
-
-
-class FlimflamTest(unittest.TestCase):
- """Test suite for FlimFlam."""
- def setUp(self):
- self._timed_out = 0
-
- self._mocker = mox.Mox()
-
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- self._mainloop = gobject.MainLoop()
-
- self._bus = dbus.SystemBus()
-
- # We don't have a good system for mocking signal receipt yet;
- # pymox doesn't do "expect these calls and maybe some others"
- # self._bus.add_signal_receiver(PrintSignal)
-
- self._name = dbus.service.BusName(OFM, self._bus)
-
- def QuitLoop(self, *_):
- self._mainloop.quit()
-
- def TimedOut(self, *_):
- print 'Timed out'
- self._timed_out = 1
- self._mainloop.quit()
-
- def testEnable(self):
- manager = ModemManager(self._mocker,
- self._bus,
- '/org/freedesktop/ModemManager')
- modem = Modem(self._mocker, self._bus, '%s/%s/%d' % (
- manager.__dbus_object_path__, 'Modems', os.getpid()))
- manager.mock.EnumerateDevices().AndReturn([modem.__dbus_object_path__])
-
- modem.mock.GetAll(OFMM).AndReturn(dbus.Dictionary({
- 'Device': '/dev/ttyUSB0',
- 'MasterDevice': 'really/long/path',
- 'Driver': 'driver',
- 'Type': dbus.UInt32(0),
- 'IpMethod': dbus.UInt32(0),
- }, signature='sv'))
- modem.mock.Enable(True).WithSideEffects(self.QuitLoop)
-
- self._mocker.ReplayAll()
-
- def StartTest():
- manager.DeviceAdded(modem.__dbus_object_path__)
-
- gobject.timeout_add(1, StartTest)
- gobject.timeout_add(2000, self.TimedOut)
- self._mainloop.run()
-
- self._mocker.VerifyAll()
-
- # This is belt-and-suspenders; we should have failed mock
- # verification already
- self.assert_(not self._timed_out)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/mm-poll-signal-strength b/test/mm-poll-signal-strength
deleted file mode 100755
index b179c53..0000000
--- a/test/mm-poll-signal-strength
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import sys
-import time
-
-import mm
-
-INTERFACES = ['interface_1_dbm', 'interface_2_dbm']
-
-TIME = 60
-SAMPLES = TIME * 2
-
-
-manager, path = mm.PickOneModem('')
-simple_modem = manager.SimpleModem(path)
-
-strengths = [] # list of lists where list[i] is dbm for interface #i
-start = time.time()
-finish = start + TIME
-
-for i in xrange(SAMPLES):
- next_reading_time = start + i * (float(TIME) / float(SAMPLES))
-
- # Wait for next reading time
- while True:
- delta = next_reading_time - time.time()
- if delta > 0.01:
- time.sleep(delta)
- elif delta < -1:
- raise Exception('Fell too far behind: delta = %f' % delta)
- else:
- break
-
- sprops = simple_modem.GetStatus()
-
- sample = [int(sprops.get(interface, -256)) for
- interface in INTERFACES]
- strengths.append(sample)
-
- sample_string = ['%d' % x for x in sample]
-
- remaining = '%f remaining' % (finish - time.time())
- print >> sys.stderr, '\t'.join(['%.3f' % time.time()] +
- sample_string +
- [remaining])
-
-means = []
-
-for interface in xrange(len(INTERFACES)):
- means.append(sum([sample[interface] for sample in strengths]) /
- float(len(strengths)))
-
-output = ['%.1f' % x for x in [start] + means]
-output_string = '\t'.join(output)
-
-print >> sys.stderr, (
- time.strftime('%a, %d %b %Y %H:%M:%S local: ', time.localtime()) +
- output_string)
-print output_string
diff --git a/test/mm-powercycle b/test/mm-powercycle
deleted file mode 100644
index 1a93519..0000000
--- a/test/mm-powercycle
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/dash
-
-. "$(dirname "$0")/mm.sh"
-
-cyclegobi () {
- local mm=$1
- local modem=$2
- dbus $mm $(iface2rootobj $mm)/$modem $IMODEM_GOBI.PowerCycle
-}
-
-cyclegen () {
- local mm=$1
- local modem=$2
- dbus $mm $(iface2rootobj $mm)/$modem $IMODEM.Reset
-}
-
-case $1 in
- -a)
- for mm in $(modemmanagers); do
- for m in $(modems $mm);
- do $0 $mm $m
- done
- done
- exit 0
- ;;
-esac
-
-mm=$1
-mmobj=$(iface2rootobj $mm)
-mname=$(echo $2 | sed -e "s!$mmobj/!!")
-mtype=$(echo $mname | awk -F/ '{print $1}' | tr A-Z a-z)
-case $mtype in
- gobi)
- cyclegobi $mm $mname
- ;;
- *)
- cyclegen $mm $mname
- ;;
-esac
diff --git a/test/mm-register b/test/mm-register
deleted file mode 100755
index 57bcbac..0000000
--- a/test/mm-register
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-import sys
-
-devices = mm.EnumerateDevices()
-
-network = ""
-
-if len(sys.argv) > 1:
- network = sys.argv[1]
-
-for manager, path in devices:
-
- props = manager.Properties(path)
-
- if props['Type'] == mm.ModemManager.GSM_MODEM:
- print 'Path: %s' % path
- print ''
-
- gsm_network = manager.GsmNetwork(path)
- gsm_network.Register(network, timeout=90)
diff --git a/test/mm-reset b/test/mm-reset
deleted file mode 100644
index 25280fe..0000000
--- a/test/mm-reset
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-import sys
-
-def Usage(prog):
- print ("Usage: %s "
- "<device path substring>") % prog
-
-if len(sys.argv) < 1 or len(sys.argv) > 2:
- Usage(sys.argv[0])
- sys.exit(1)
-
-if len(sys.argv) < 2:
- modem_pattern = ''
-else:
- modem_pattern = sys.argv[1]
-
-manager, path = mm.PickOneModem(modem_pattern)
-gobi_modem = manager.GobiModem(path)
-gobi_modem.SoftReset()
diff --git a/test/mm-set-carrier b/test/mm-set-carrier
deleted file mode 100644
index ee7afed..0000000
--- a/test/mm-set-carrier
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import mm
-import sys
-
-def Usage(prog):
- print ("Usage: %s carrier "
- "<device path substring>") % prog
-
-if len(sys.argv) < 2 or len(sys.argv) > 3:
- Usage(sys.argv[0])
- sys.exit(1)
-
-carrier = sys.argv[1]
-
-if len(sys.argv) < 3:
- modem_pattern = ''
-else:
- modem_pattern = sys.argv[2]
-
-manager = mm.ModemManager()
-path = mm.PickOneModem(modem_pattern)
-gobi_modem = manager.GobiModem(path)
-gobi_modem.SetCarrier(carrier)
diff --git a/test/mm-speed-test b/test/mm-speed-test
deleted file mode 100755
index cf6c9c9..0000000
--- a/test/mm-speed-test
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2010 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.
-
-import logging
-import logging.handlers
-import os
-import subprocess
-import sys
-import time
-import urllib2
-
-import_path = os.environ.get("SYSROOT", "") + "/usr/lib/flimflam/test"
-sys.path.append(import_path)
-import flimflam
-
-class SpeedTester(object):
- @staticmethod
- def CommandOutput(command):
- p = subprocess.Popen(command, stdout=subprocess.PIPE)
- return p.communicate()[0]
-
- def __init__(self):
- self.keyvals = []
- self.flim = None
-
- def write_perf_keyval(self, d):
- self.keyvals.append(d)
- logging.info(str(d).replace('%', '%%'))
-
- def ExtractPerfField(self, field):
- return [kv[field]
- for kv in self.keyvals
- if field in kv]
-
- def FetchUrl(self, url_pattern=
- 'http://testing-chargen.appspot.com/download?size=%d',
- size=10,
- label=None):
- """Fetch the URL, wirte a dictionary of performance data."""
-
- if not label:
- raise Exception('no label supplied')
-
- url = url_pattern % size
- logging.info('Fetching: %s', url)
- start_time = time.time()
- result = urllib2.urlopen(url)
- bytes_received = len(result.read())
- fetch_time = time.time() - start_time
- if not fetch_time:
- raise Exception('Fetch took 0 time')
-
- if bytes_received != size:
- raise Exception('asked for %d bytes, got %d' %
- (size, bytes_received))
-
- self.write_perf_keyval(
- {'seconds_%s_fetch_time' % label: fetch_time,
- 'bytes_%s_bytes_received' % label: bytes_received,
- 'bits_second_%s_speed' % label: 8 * bytes_received / fetch_time}
- )
-
- def run_once_internal(self, connect_count):
- logging.info('%s', SpeedTester.CommandOutput(['/sbin/route', '-n']))
-
- for _ in xrange(connect_count):
- self.FetchUrl(label='3G', size=1 << 19)
-
- def run_once(self, connect_count):
- self.flim = flimflam.FlimFlam()
- self.run_once_internal(connect_count)
- speeds = self.ExtractPerfField("bits_second_3G_speed")
- logging.info('Speeds: %s', speeds)
- mean = sum(speeds) / len(speeds)
-
- print "=============================="
- print "Mean speed in kbit/second:", mean / 1000
-
-
-if __name__ == '__main__':
- logger = logging.getLogger()
- logger.setLevel(logging.INFO)
- logging.info('Beginning')
- tester = SpeedTester()
- tester.run_once(4)
diff --git a/test/mm-status b/test/mm-status
deleted file mode 100755
index 31eb623..0000000
--- a/test/mm-status
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/bin/dash
-
-. "$(dirname "$0")/mm.sh"
-
-# This is somewhat subtle, and quite disgusting. Here's the story: dbus-send
-# --fixed emits arrays and tuples like:
-# /0 something
-# /1 anotherthing
-# We happen to know that 0 is actually, say, signal strength, and 1 is carrier
-# name, but we get the info back as a tuple. Fortunately, unpacktuple() to the
-# rescue! This function generates and then runs a sed expression which
-# transforms the indexes into proper keys automatically. For the above
-# expression, we might use:
-# unpacktuple SignalStrength Carrier
-# And if we then did:
-# dbus-blahblah GetSomething | unpacktuple SignalStrength Carrier
-# We would end up with nicely-formatted output:
-# SignalStrength: something
-# Carrier: anotherthing
-unpacktuple () {
- local cmd='sed'
- local argidx=0
- while test $# != 0; do
- # Grab a variable name
- local varname=$1
- shift
-
- # Generate an expression that turns the current index into that
- # variable name, and append it.
- cmd="$cmd -e s/^\\/${argidx}/$varname:/"
- argidx=$((argidx+1))
- done
-
- # Indent the result. XXX: variable depth? Do we care?
- $cmd -e 's/^/ /'
-}
-
-stripindexes () {
- sed -e 's/^\/[[:digit:]]\+\///' -e 's/[^[:space:]]*/\0:/' -e 's/^/ /'
-}
-
-pcdma () {
- local mm=$1
- local modem=$2
- echo "CDMA:"
- echo -n " ESN: "
- dbus $mm $modem $IMODEM_CDMA.GetEsn
-
- # GetRegistrationState is... 'gratuitously different' in that it
- # returns a tuple at the top level instead of an array. As such,
- # the unpack here is nasty.
- echo " Registration:"
- echo -n " CDMA-1x: "
- dbus $mm $modem $IMODEM_CDMA.GetRegistrationState | head -n 1
- echo -n " EVDO: "
- dbus $mm $modem $IMODEM_CDMA.GetRegistrationState | tail -n 1
-
- echo " ServingSystem:"
- dbus $mm $modem $IMODEM_CDMA.GetServingSystem \
- | unpacktuple BandClass Band ID
- echo -n " SignalQuality: "
- dbus $mm $modem $IMODEM_CDMA.GetSignalQuality
-}
-
-pgsm () {
- local mm=$1
- local modem=$2
- echo "GSM:"
- echo -n " IMSI: "
- dbus $mm $modem $IMODEM_GSM_CARD.GetImsi
- echo " Registration:"
- dbus $mm $modem $IMODEM_GSM_NETWORK.GetRegistrationInfo \
- | unpacktuple Status OperatorCode OperatorName
- echo -n " SignalQuality: "
- dbus $mm $modem $IMODEM_GSM_NETWORK.GetSignalQuality
-}
-
-hidemdn () {
- [ -z $devmode ] && sed -e '/mdn/s/ 001[0-9]*$/ partial/'
-}
-
-hidemin () {
- [ -z $devmode ] && sed -e '/min/s/ 001[0-9]*$/ partial/'
-}
-
-pmodem () {
- local mm=$1
- local modem=$2
- echo ""
- echo "Modem $modem (manager $mm):"
- echo " GetStatus:"
- dbus $mm $modem $IMODEM_SIMPLE.GetStatus | stripindexes | hidemdn | hidemin
- echo " GetInfo:"
- dbus $mm $modem $IMODEM.GetInfo | unpacktuple Manufacturer Modem Version
- echo " Props:"
- modemprops $mm $modem | stripindexes
- local mtype=$(modemprop $mm $modem Type)
- if [ -z $mtype ]; then
- echo "Modem type unknown; no further information available."
- return
- fi
- if [ $mtype -eq $MTYPE_CDMA ]; then
- pcdma $mm $modem | sed -e 's/^/ /'
- fi
- if [ $mtype -eq $MTYPE_GSM ]; then
- pgsm $mm $modem | sed -e 's/^/ /'
- fi
-}
-
-usage () {
- echo "Usage: $0 [-d]"
- exit 0
-}
-
-if [ $# -gt 0 ]; then
- case "$1" in
- -d)
- devmode=1
- ;;
- *)
- usage
- ;;
- esac
-fi
-
-for mm in $(modemmanagers); do
- for m in $(modems $mm); do
- pmodem $mm $m
- done
-done
diff --git a/test/mm.py b/test/mm.py
deleted file mode 100755
index 13db0ff..0000000
--- a/test/mm.py
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-
-import dbus
-import os
-
-MMPROVIDERS = [ 'org.chromium', 'org.freedesktop' ]
-
-class ModemManager(object):
- INTERFACE = 'org.freedesktop.ModemManager'
- MODEM_INTERFACE = 'org.freedesktop.ModemManager.Modem'
- SIMPLE_MODEM_INTERFACE = 'org.freedesktop.ModemManager.Modem.Simple'
- CDMA_MODEM_INTERFACE = 'org.freedesktop.ModemManager.Modem.Cdma'
- GSM_MODEM_INTERFACE = 'org.freedesktop.ModemManager.Modem.Gsm'
- GOBI_MODEM_INTERFACE = 'org.chromium.ModemManager.Modem.Gobi'
- GSM_CARD_INTERFACE = 'org.freedesktop.ModemManager.Modem.Gsm.Card'
- GSM_SMS_INTERFACE = 'org.freedesktop.ModemManager.Modem.Gsm.SMS'
- GSM_NETWORK_INTERFACE = 'org.freedesktop.ModemManager.Modem.Gsm.Network'
- PROPERTIES_INTERFACE = 'org.freedesktop.DBus.Properties'
-
- GSM_MODEM = 1
- CDMA_MODEM = 2
-
- @staticmethod
- def GetModemInterfaces():
- return [ModemManager.MODEM_INTERFACE,
- ModemManager.SIMPLE_MODEM_INTERFACE,
- ModemManager.CDMA_MODEM_INTERFACE,
- ModemManager.GSM_MODEM_INTERFACE,
- ModemManager.GOBI_MODEM_INTERFACE]
-
- def __init__(self, provider=None):
- self.bus = dbus.SystemBus()
- self.provider = provider or os.getenv('MMPROVIDER') or 'org.chromium'
- self.service = '%s.ModemManager' % self.provider
- self.path = '/%s/ModemManager' % (self.provider.replace('.', '/'))
- self.manager = dbus.Interface(
- self.bus.get_object(self.service, self.path),
- ModemManager.INTERFACE)
-
- def Modem(self, path):
- obj = self.bus.get_object(self.service, path)
- return dbus.Interface(obj, ModemManager.MODEM_INTERFACE)
-
- def SimpleModem(self, path):
- obj = self.bus.get_object(self.service, path)
- return dbus.Interface(obj, ModemManager.SIMPLE_MODEM_INTERFACE)
-
- def CdmaModem(self, path):
- obj = self.bus.get_object(self.service, path)
- return dbus.Interface(obj, ModemManager.CDMA_MODEM_INTERFACE)
-
- def GobiModem(self, path):
- obj = self.bus.get_object(self.service, path)
- return dbus.Interface(obj, ModemManager.GOBI_MODEM_INTERFACE)
-
- def GsmModem(self, path):
- obj = self.bus.get_object(self.service, path)
- return dbus.Interface(obj, ModemManager.GSM_MODEM_INTERFACE)
-
- def GsmCard(self, path):
- obj = self.bus.get_object(self.service, path)
- return dbus.Interface(obj, ModemManager.GSM_CARD_INTERFACE)
-
- def GsmSms(self, path):
- obj = self.bus.get_object(self.service, path)
- return dbus.Interface(obj, ModemManager.GSM_SMS_INTERFACE)
-
- def GsmNetwork(self, path):
- obj = self.bus.get_object(self.service, path)
- return dbus.Interface(obj, ModemManager.GSM_NETWORK_INTERFACE)
-
- def GetAll(self, iface, path):
- obj = self.bus.get_object(self.service, path)
- obj_iface = dbus.Interface(obj, ModemManager.PROPERTIES_INTERFACE)
- return obj_iface.GetAll(iface)
-
- def Properties(self, path):
- props = dict()
- for iface in ModemManager.GetModemInterfaces():
- try:
- d = self.GetAll(iface, path)
- except Exception, _:
- continue
- if d:
- for k, v in d.iteritems():
- props[k] = v
-
- return props
-
-
-def EnumerateDevices(manager=None):
- """ Enumerate all modems in the system
-
- Args:
- manager - the specific manager to use, if None check all known managers
-
- Returns:
- a list of (ModemManager object, modem dbus path)
- """
- if manager:
- managers = [manager]
- else:
- managers = []
- for provider in MMPROVIDERS:
- try:
- managers.append(ModemManager(provider))
- except dbus.exceptions.DBusException, e:
- if (e.get_dbus_name() !=
- 'org.freedesktop.DBus.Error.ServiceUnknown'):
- raise
-
- result = []
- for m in managers:
- for path in m.manager.EnumerateDevices():
- result.append((m, path))
-
- return result
-
-
-def PickOneModem(modem_pattern, manager=None):
- """ Pick a modem
-
- If a machine has a single modem, managed by one one of the
- MMPROVIDERS, return the dbus path and a ModemManager object for
- that modem.
-
- Args:
- modem_pattern - pattern that should match the modem path
- manager - the specific manager to use, if None check all known managers
-
- Returns:
- ModemManager object, modem dbus path
-
- Raises:
- ValueError - if there are no matching modems, or there are more
- than one
- """
- devices = EnumerateDevices(manager)
-
- matches = [(m, path) for m, path in devices if modem_pattern in path]
- if not matches:
- raise ValueError("No modems had substring: " + modem_pattern)
- if len(matches) > 1:
- raise ValueError("Expected only one modem, got: " +
- ", ".join([path for _, path in matches]))
- return matches[0]
diff --git a/test/mm.sh b/test/mm.sh
deleted file mode 100644
index 5496279..0000000
--- a/test/mm.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/dash
-
-IDBUS=org.freedesktop.DBus
-DBUS=/org/freedesktop/DBus
-IDBUS_PROPERTIES=$IDBUS.Properties
-IMM=org.freedesktop.ModemManager
-IMODEM=$IMM.Modem
-IMODEM_SIMPLE=$IMODEM.Simple
-IMODEM_CDMA=$IMODEM.Cdma
-IMODEM_GSM=$IMODEM.Gsm
-IMODEM_GSM_CARD=$IMODEM_GSM.Card
-IMODEM_GSM_NETWORK=$IMODEM_GSM.Network
-IMODEM_GOBI=org.chromium.ModemManager.Modem.Gobi
-IMODEMS="$IMODEM $IMODEM_CDMA $IMODEM_GSM_CARD $IMODEM_GSM_NETWORK $IMODEM_GOBI"
-
-MTYPE_GSM=1
-MTYPE_CDMA=2
-
-iface2rootobj () {
- echo "/$1" | sed -e 's!\.!/!g'
-}
-
-dbus () {
- local dest=$1
- local obj=$2
- local meth=$3
- shift 3
-
- dbus-send --system --print-reply --fixed \
- --dest=$dest "$obj" "$meth" "$@"
-}
-
-modemmanagers () {
- dbus $IDBUS $DBUS $IDBUS.ListNames | awk '/ModemManager/ { print $2 }'
-}
-
-modems () {
- local mm=$1
- dbus $mm $(iface2rootobj $mm) $IMM.EnumerateDevices | awk '{print $2}'
-}
-
-modemprops () {
- local mm=$1
- local modem=$2
- for i in $IMODEMS; do
- dbus $mm $modem $IDBUS_PROPERTIES.GetAll string:$i 2>/dev/null \
- | awk '/[^[:space:]] [^[:space:]]/ {print $N}'
- done
-}
-
-modemprop () {
- local mm=$1
- local modem=$2
- local prop=$3
- modemprops $mm $modem | grep /$prop | awk '{print $2}'
-}
diff --git a/test/mobile_activation.html b/test/mobile_activation.html
deleted file mode 100644
index 91b860c..0000000
--- a/test/mobile_activation.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-<meta charset="utf-8">
-<title>Mobile activation testing page</title>
-
-<style>
-body {
- background: -webkit-gradient(linear, left top, left bottom,
- from(#EBEBEB), to(#CFCFCF));
- font-family: 'Lucida Grande', Helvetica, sans-serif;
- font-size: 10px;
- height: 300px;
- overflow: hidden;
-}
-</style>
-
-<script src="connection_manager.js"></script>
-<script>
-function $(id) {
- return document.getElementById(id);
-}
-
-chromeos.connectionManager.getDeviceInfo(function(device) {
- $('device-info').innerHTML =
- 'carrier = ' + device.carrier + '<br>' +
- 'MEID = ' + device.MEID + '<br>' +
- 'IMEI = ' + device.IMEI + '<br>' +
- 'IMSI = ' + device.IMSI + '<br>' +
- 'ESN = ' + device.ESN + '<br>' +
- 'MDN = ' + device.MDN;
-});
-
-function sendStatus(status) {
- chromeos.connectionManager.setTransactionStatus(status,
- function() {});
-}
-
-</script>
-
-</head>
-<body>
-<h2>Plan Payment Page<h2>
-<div>Press a button below to signal transaction status back to the browser</div>
-<div id='buttons'>
-<button id='ok-btn' onclick="document.location='payment_succeeded.html'">OK</button>
-<button id='fail-btn' onclick="document.location='payment_failed.html'">Failed</button>
-</div>
-<div>
-Device Information:
-<div id="device-info"></div>
-</div>
-</body>
-</html>
diff --git a/test/monitor-flimflam b/test/monitor-flimflam
deleted file mode 100755
index b347f28..0000000
--- a/test/monitor-flimflam
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-
-import gobject
-
-import dbus
-import dbus.mainloop.glib
-
-def property_changed(name, value, path, interface):
- iface = interface[interface.rfind(".") + 1:]
- if name in ["Strength", "Priority"]:
- val = int(value)
- else:
- val = str(value)
- print "{%s} [%s] %s = %s" % (iface, path, name, val)
-
-if __name__ == '__main__':
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
- bus = dbus.SystemBus()
-
- bus.add_signal_receiver(property_changed,
- bus_name="org.chromium.flimflam",
- signal_name = "PropertyChanged",
- path_keyword="path",
- interface_keyword="interface")
-
- mainloop = gobject.MainLoop()
- mainloop.run()
diff --git a/test/monitor-services b/test/monitor-services
deleted file mode 100755
index 36744aa..0000000
--- a/test/monitor-services
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/python
-
-import gobject
-
-import dbus
-import dbus.mainloop.glib
-
-def property_changed(name, value, path, interface):
- iface = interface[interface.rfind(".") + 1:]
- ipath = path[path.rfind("/") + 1:]
- if iface not in ["Service"]:
- return
- if name in ["Profiles", "Services",
- "Devices", "Networks"]:
- val = "["
- for i in value:
- val = val + " " + i[i.rfind("/") + 1:]
- val = val + " ]"
- elif name in ["Strength", "Priority"]:
- val = int(value)
- else:
- val = str(value)
- print "{%s} [%s] %s = %s" % (iface, ipath, name, val)
-
-if __name__ == '__main__':
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
- bus = dbus.SystemBus()
-
- bus.add_signal_receiver(property_changed,
- bus_name="org.chromium.flimflam",
- signal_name = "PropertyChanged",
- path_keyword="path",
- interface_keyword="interface")
-
- mainloop = gobject.MainLoop()
- mainloop.run()
diff --git a/test/payment_failed.html b/test/payment_failed.html
deleted file mode 100644
index 5494d3d..0000000
--- a/test/payment_failed.html
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-<meta charset="utf-8">
-<title>Payment Failed Page</title>
-
-<style>
-body {
- background: -webkit-gradient(linear, left top, left bottom,
- from(#EBEBEB), to(#CFCFCF));
- font-family: 'Lucida Grande', Helvetica, sans-serif;
- font-size: 10px;
- height: 300px;
- overflow: hidden;
-}
-</style>
-
-<script src="connection_manager.js"></script>
-<script>
-function $(id) {
- return document.getElementById(id);
-}
-
-chromeos.connectionManager.getDeviceInfo(function(device) {
- $('device-info').innerHTML =
- 'carrier = ' + device.carrier + '<br>' +
- 'MEID = ' + device.MEID + '<br>' +
- 'IMEI = ' + device.IMEI + '<br>' +
- 'IMSI = ' + device.IMSI + '<br>' +
- 'ESN = ' + device.ESN + '<br>' +
- 'MDN = ' + device.MDN;
-});
-
-function sendStatus(status) {
- chromeos.connectionManager.setTransactionStatus(status,
- function() {});
-}
-
-</script>
-
-</head>
-<body>
-<h2>Payment Failed Page<h2>
-Your payment was not received.
-
-<script>
-// The carrier should invoke this to inform Chrome OS that the payment
-// failed. In practice the carrier does not, so the sendStatus function
-// call is commented out. It is left as a reminder of what should happen.
-// sendStatus('FAILED')
-</script>
-</body>
-</html>
diff --git a/test/payment_succeeded.html b/test/payment_succeeded.html
deleted file mode 100644
index 4bcf51f..0000000
--- a/test/payment_succeeded.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-<meta charset="utf-8">
-<title>Payment Confirmation Page</title>
-
-<style>
-body {
- background: -webkit-gradient(linear, left top, left bottom,
- from(#EBEBEB), to(#CFCFCF));
- font-family: 'Lucida Grande', Helvetica, sans-serif;
- font-size: 10px;
- height: 300px;
- overflow: hidden;
-}
-</style>
-
-<script src="connection_manager.js"></script>
-<script>
-function $(id) {
- return document.getElementById(id);
-}
-
-chromeos.connectionManager.getDeviceInfo(function(device) {
- $('device-info').innerHTML =
- 'carrier = ' + device.carrier + '<br>' +
- 'MEID = ' + device.MEID + '<br>' +
- 'IMEI = ' + device.IMEI + '<br>' +
- 'IMSI = ' + device.IMSI + '<br>' +
- 'ESN = ' + device.ESN + '<br>' +
- 'MDN = ' + device.MDN;
-});
-
-function sendStatus(status) {
- chromeos.connectionManager.setTransactionStatus(status,
- function() {});
-}
-
-</script>
-
-</head>
-<body>
-<h2>Plan Confirmation Page<h2>
-Thank you. Your payment was received.
-<script>
-sendStatus('OK')
-</script>
-</body>
-</html>
diff --git a/test/pin b/test/pin
deleted file mode 100755
index 3dd031b..0000000
--- a/test/pin
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-
-. "$(dirname "$0")"/mm.sh
-
-usage () {
- echo "Usage: $0 <command> [args...]"
- echo " change <old> <new>"
- echo " unlock <pin>"
- echo " disable <pin>"
- echo " enable <pin>"
- exit 0
-}
-
-change () {
- dbus $1 $2 $IMODEM_GSM_CARD.ChangePin string:$3 string:$4
-}
-
-unlock () {
- dbus $1 $2 $IMODEM_GSM_CARD.SendPin string:$3
-}
-
-enable () {
- dbus $1 $2 $IMODEM_GSM_CARD.EnablePin string:$3 boolean:true
-}
-
-disable () {
- dbus $1 $2 $IMODEM_GSM_CARD.EnablePin string:$3 boolean:false
-}
-
-if [ ! -z "$1" ]; then
- cmd="$1" ; shift
-else
- cmd="help"
-fi
-
-case "$cmd" in
- change|unlock|enable|disable)
- ;;
- *)
- usage
- ;;
-esac
-
-for mm in $(modemmanagers); do
- for modem in $(modems $mm); do
- $cmd $mm $modem "$@"
- done
-done
diff --git a/test/pop-profile b/test/pop-profile
deleted file mode 100755
index 43ec0b8..0000000
--- a/test/pop-profile
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) > 2):
- print "usage: %s [identifier]" % sys.argv[0]
- sys.exit(1)
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-if (len(sys.argv) == 2):
- flim.PopProfile(sys.argv[1])
-else:
- flim.PopAnyProfile()
diff --git a/test/push-profile b/test/push-profile
deleted file mode 100755
index 0752077..0000000
--- a/test/push-profile
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Profile identifier required"
- sys.exit(1)
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-profile = flim.PushProfile(sys.argv[1])
-print "Pushed profile %s" % (profile.object_path)
diff --git a/test/rm-ipconfig b/test/rm-ipconfig
deleted file mode 100755
index 5672982..0000000
--- a/test/rm-ipconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <path>" % (sys.argv[0])
- sys.exit(1)
-
-(_, path) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-ipconfig = flim.GetObjectInterface("IPConfig", path)
-ipconfig.Remove()
diff --git a/test/rm-profile b/test/rm-profile
deleted file mode 100755
index 0560ed9..0000000
--- a/test/rm-profile
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Profile ident required"
- sys.exit(1)
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-flim.RemoveProfile(sys.argv[1])
diff --git a/test/rm-service b/test/rm-service
deleted file mode 100755
index b536d03..0000000
--- a/test/rm-service
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <service-path>" % (sys.argv[0])
- sys.exit(1)
-
-(_, path) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-service = flim.FindElementByNameSubstring("Service", path)
-service.Remove()
diff --git a/test/routing.py b/test/routing.py
deleted file mode 100755
index 0b22174..0000000
--- a/test/routing.py
+++ /dev/null
@@ -1,158 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2009 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.
-
-"""Return information about routing table entries
-
-Read and parse the system routing table. There are
-two classes defined here: NetworkRoutes, which contains
-information about all routes, and Route, which describes
-a single routing table entry.
-"""
-
-ROUTES_FILE = "/proc/net/route"
-# The following constants are from <net/route.h>
-RTF_UP = 0x0001
-RTF_GATEWAY = 0x0002
-RTF_HOST = 0x0004
-
-import socket
-import struct
-
-def intToDottedQuad(addr):
- return socket.inet_ntoa(struct.pack('@I', addr))
-
-def convertIpToInt(i):
- """Convert the supplied argument to an int representing an IP address."""
- if isinstance(i, int):
- return i
- return struct.unpack('I', socket.inet_aton(i))[0]
-
-class Route(object):
- def __init__(self, iface, dest, gway, flags, mask):
- self.interface = iface
- self.destination = int(dest, 16)
- self.gateway = int(gway, 16)
- self.flagbits = int(flags, 16)
- self.netmask = int(mask, 16)
-
- def __str__(self):
- flags = ""
- if self.flagbits & RTF_UP:
- flags += "U"
- if self.flagbits & RTF_GATEWAY:
- flags += "G"
- if self.flagbits & RTF_HOST:
- flags += "H"
- return "<%s dest: %s gway: %s mask: %s flags: %s>" % (
- self.interface,
- intToDottedQuad(self.destination),
- intToDottedQuad(self.gateway),
- intToDottedQuad(self.netmask),
- flags)
-
- def isUsable(self):
- return self.flagbits & RTF_UP
-
- def isHostRoute(self):
- return self.flagbits & RTF_HOST
-
- def isGatewayRoute(self):
- return self.flagbits & RTF_GATEWAY
-
- def isInterfaceRoute(self):
- return (self.flagbits & RTF_GATEWAY) == 0
-
- def isDefaultRoute(self):
- return (self.flagbits & RTF_GATEWAY) and self.destination == 0
-
- def matches(self, ip):
- return (ip & self.netmask) == self.destination
-
-class NetworkRoutes(object):
- def __init__(self, routelist=None):
- if not routelist:
- routef = open(ROUTES_FILE)
- routelist = routef.readlines()
- routef.close()
-
- # The first line is headers that will allow us
- # to correctly interpret the values in the following
- # lines
- colMap = {}
- headers = routelist[0].split()
- for (pos, token) in enumerate(headers):
- colMap[token] = pos
-
- self.routes = []
- for routeline in routelist[1:]:
- route = routeline.split()
- interface = route[colMap["Iface"]]
- destination = route[colMap["Destination"]]
- gateway = route[colMap["Gateway"]]
- flags = route[colMap["Flags"]]
- mask = route[colMap["Mask"]]
- self.routes.append(
- Route(interface, destination, gateway, flags, mask))
-
- def hasDefaultRoute(self, interface):
- for rr in self.routes:
- if (rr.isUsable() and
- rr.interface == interface and
- rr.isDefaultRoute()):
- return True
- return False
-
- def getDefaultRoutes(self):
- defroutes = []
- for rr in self.routes:
- if rr.isUsable() and rr.isDefaultRoute():
- defroutes.append(rr)
- return defroutes
-
- def hasInterfaceRoute(self, interface):
- for rr in self.routes:
- if (rr.isUsable() and
- rr.interface == interface and
- rr.isInterfaceRoute()):
- return True
- return False
-
- def getRouteFor(self, ip_as_int_or_string):
- ip = convertIpToInt(ip_as_int_or_string)
- for rr in self.routes:
- if rr.isUsable() and rr.matches(ip):
- return rr
- return None
-
-
-if __name__ == "__main__":
- routes = NetworkRoutes()
- if routes == None:
- print "Failed to read routing table"
- else:
- for each_route in routes.routes:
- print each_route
-
- print "hasDefaultRoute(\"eth0\"):", routes.hasDefaultRoute("eth0")
-
- dflts = routes.getDefaultRoutes()
- if dflts == None:
- print "There are no default routes"
- else:
- print "There are %d default routes" % (len(dflts))
-
-
- print "hasInterfaceRoute(\"eth0\"):", routes.hasInterfaceRoute("eth0")
-
- routes = NetworkRoutes([
- "Iface Destination Gateway Flags RefCnt "
- "Use Metric Mask MTU Window IRTT",
- "ones 00010203 FE010203 0007 0 0 0 00FFFFFF 0 0 0\n",
- "default 00000000 09080706 0007 0 0 0 00000000 0 0 0\n",
- ])
-
- print routes.getRouteFor(0x01010203)
- print routes.getRouteFor("3.2.1.1")
- print routes.getRouteFor(0x08010209)
diff --git a/test/service-order b/test/service-order
deleted file mode 100755
index ccf5586..0000000
--- a/test/service-order
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-
-import sys, dbus, flimflam
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-if (len(sys.argv) < 2):
- print "Service order is %s" % flim.GetServiceOrder()
-else:
- orders = flim.SetServiceOrder(sys.argv[1])
- print "Service order %s => %s" % orders
diff --git a/test/set-address b/test/set-address
deleted file mode 100755
index 3a7e64f..0000000
--- a/test/set-address
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <address>" % (sys.argv[0])
- sys.exit(1)
-
-(_, address) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-for device in flim.GetObjectList("Device"):
- device_properties = device.GetProperties(utf8_strings = True)
-
- for path in device_properties["IPConfigs"]:
- ipconfig = flim.GetObjectInterface("IPConfig", path)
- ipconfig_properties = ipconfig.GetProperties(utf8_strings = True)
-
- if ipconfig_properties["Method"] not in ["ipv4","ipv6"]:
- print "Skip %s; method %s" % (ipconfig.object_path,
- ipconfig_properties["Method"])
- continue
-
- ipconfig.SetProperty("Address", address)
diff --git a/test/set-apn b/test/set-apn
deleted file mode 100755
index 3ed823d..0000000
--- a/test/set-apn
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2011 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.
-#
-# Set the APN to be used when making connections on a cellular
-# service.
-
-import sys
-import dbus, flimflam
-from optparse import OptionParser
-
-usage = '''
-%prog [options] apn service-name
-
-or
-
-%prog --clear service-name'''
-
-parser = OptionParser(usage=usage)
-parser.add_option('-n', '--network_id', type='string',
- dest='network_id',
- default=None,
- help='user name to be used with the APN')
-parser.add_option('-u', '--username', type='string',
- dest='username',
- default=None,
- help='user name to be used with the APN')
-parser.add_option('-p', '--password', type='string',
- dest='password',
- default=None,
- help='password to be used with the APN')
-parser.add_option('-c', '--clear',
- action='store_true', dest='clear_apn',
- default=False,
- help='Clear any APN associated with the named service')
-
-(options, args) = parser.parse_args()
-
-props = dbus.Dictionary(signature="ss")
-
-if not options.clear_apn:
- if len(args) < 1:
- parser.error("The APN and service name must be specified")
- elif len(args) < 2:
- parser.error("The service name must be specified")
- elif len(args) > 2:
- parser.error("Too many arguments")
-
- apn = args[0]
- servicename = args[1]
-
- props['apn'] = apn
- if options.network_id:
- props['network_id'] = options.network_id
- if options.username:
- props['username'] = options.username
- if options.password:
- props['password'] = options.password
-else:
- if len(args) < 1:
- parser.error("The service name must be specified")
- servicename = args[0]
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-service = flim.FindElementByNameSubstring('Service', servicename)
-if not service:
- print "Unknown service %s" % servicename
- sys.exit(2)
-
-if not options.clear_apn:
- service.SetProperty("Cellular.APN", props)
-else:
- service.ClearProperty("Cellular.APN")
diff --git a/test/set-arp-gateway b/test/set-arp-gateway
deleted file mode 100644
index 69a9cb2..0000000
--- a/test/set-arp-gateway
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s [true|false]" % (sys.argv[0])
- sys.exit(1)
-
-do_arp_gw = sys.argv[1].lower()
-if do_arp_gw not in ('true', 'false'):
- print "Argument must be 'true' or 'false'"
- sys.exit(1)
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-flim.SetArpGateway(do_arp_gw == 'true')
diff --git a/test/set-bgscan b/test/set-bgscan
deleted file mode 100644
index 4ed3269..0000000
--- a/test/set-bgscan
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-from optparse import OptionParser
-
-parser = OptionParser('Usage: %prog [options...] [var=value...]')
-parser.add_option('--interface', dest='intf', default='wlan0',
- help='Device name')
-(options, args) = parser.parse_args()
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-device = flim.FindElementByNameSubstring('Device', options.intf)
-if device is None:
- device = flim.FindElementByPropertySubstring('Device', 'Interface',
- options.intf)
-
-if not device:
- print "Device not found."
- sys.exit(1)
-
-attributes = {'ScanInterval': dbus.UInt16,
- 'BgscanMethod': dbus.String,
- 'BgscanShortInterval': dbus.UInt16,
- 'BgscanSignalThreshold': dbus.Int32}
-
-if not args:
- print "Background scan parameters for %s" % device.object_path
- props = device.GetProperties(utf8_strings = True)
- for attr in attributes.keys():
- if attr in props:
- print " %s: %s" % (attr, props[attr])
- sys.exit(0)
-
-for assignment in args:
- print 'Assigning parameters on device %s' % (device.object_path)
- attr, sep, val = assignment.partition('=')
- if sep != '=' or attr not in attributes.keys():
- print 'Bad assignment. Assignment must be in the form:'
- print ' "var=val", where possible "var" are: %s' % attributes.keys()
- sys.exit(1)
- elif val == 'default':
- device.ClearProperty(attr)
- else:
- device.SetProperty(attr, attributes[attr](val))
diff --git a/test/set-country b/test/set-country
deleted file mode 100755
index 03a752a..0000000
--- a/test/set-country
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <country>" % (sys.argv[0])
- sys.exit(1)
-
-(_, country) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-flim.SetCountry(country)
diff --git a/test/set-device-property b/test/set-device-property
deleted file mode 100644
index 204ea6e..0000000
--- a/test/set-device-property
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 4):
- print "Usage: %s <device-name> <property> <value>" % (sys.argv[0])
- sys.exit(1)
-
-(_, name, property_key, value) = sys.argv
-
-flim = flimflam.FlimFlam()
-device = flim.FindElementByNameSubstring('Device', name)
-if property_key in ["BgscanShortInterval", "ScanInterval" ]:
- device.SetProperty(property_key, dbus.Int16(value))
-elif property_key in [ "BgscanSignalThreshold", ]:
- device.SetProperty(property_key, int(value))
-elif property_key in ["Cellular.AllowRoaming", "Powered"]:
- device.SetProperty(property_key,
- dbus.Boolean(value.lower() in ("true", "1")))
-else:
- device.SetProperty(property_key, value)
diff --git a/test/set-ipconfig b/test/set-ipconfig
deleted file mode 100755
index 7d0c617..0000000
--- a/test/set-ipconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 4):
- print "Usage: %s <path> <key> <value>" % (sys.argv[0])
- sys.exit(1)
-
-(_, path, key, value) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-ipconfig = flim.GetObjectInterface("IPConfig", path)
-if key == "Prefixlen":
- ipconfig.SetProperty(key, int(value))
-elif key == "Mtu":
- ipconfig.SetProperty(key, int(value))
-else:
- ipconfig.SetProperty(key, value)
diff --git a/test/set-mtu b/test/set-mtu
deleted file mode 100755
index 5f80e1d..0000000
--- a/test/set-mtu
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s <mtu>" % (sys.argv[0])
- sys.exit(1)
-
-(_, mtu) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-for device in flim.GetObjectList("Device"):
- device_properties = device.GetProperties(utf8_strings = True)
-
- for path in device_properties["IPConfigs"]:
- ipconfig = flim.GetObjectInterface("IPConfig", path)
- ipconfig.SetProperty("Mtu", int(mtu))
diff --git a/test/set-portal-list b/test/set-portal-list
deleted file mode 100755
index e225174..0000000
--- a/test/set-portal-list
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s check-portal-list" % (sys.argv[0])
- sys.exit(1)
-
-(_, portal_list) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-flim.SetCheckPortalList(portal_list)
diff --git a/test/set-portal-url b/test/set-portal-url
deleted file mode 100755
index 2d5d397..0000000
--- a/test/set-portal-url
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 2):
- print "Usage: %s portal-url" % (sys.argv[0])
- sys.exit(1)
-
-(_, url) = sys.argv
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-flim.SetPortalURL(url)
diff --git a/test/set-profile-property b/test/set-profile-property
deleted file mode 100644
index cdf529a..0000000
--- a/test/set-profile-property
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/python
-
-import flimflam, sys
-
-if (len(sys.argv) < 4):
- print "Usage: %s <profile-name> <property> <value>" % (sys.argv[0])
- sys.exit(1)
-
-(_, name, property_key, value) = sys.argv
-
-flim = flimflam.FlimFlam()
-profile = flim.FindElementByNameSubstring('Profile', name)
-profile.SetProperty(property_key, value)
diff --git a/test/set-service-property b/test/set-service-property
deleted file mode 100644
index 6979150..0000000
--- a/test/set-service-property
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) < 4):
- print "Usage: %s <service-name> <property> <value>" % (sys.argv[0])
- sys.exit(1)
-
-(_, name, property_key, value) = sys.argv
-
-flim = flimflam.FlimFlam()
-service = flim.FindElementByNameSubstring('Service', name)
-if property_key in ["Priority"]:
- service.SetProperty(property_key, int(value))
-elif property_key in ["AutoConnect", "WiFi.HiddenSSID", "EAP.UseSystemCAS",
- "SaveCredentials"]:
- service.SetProperty(property_key,
- dbus.Boolean(value.lower() in ("true", "1")))
-else:
- service.SetProperty(property_key, value)
diff --git a/test/show-introspection b/test/show-introspection
deleted file mode 100755
index 4713d0d..0000000
--- a/test/show-introspection
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-
-import dbus
-
-bus = dbus.SystemBus()
-
-flimflam_object = dbus.Interface(bus.get_object("org.chromium.flimflam", '/'),
- "org.freedesktop.DBus.Introspectable")
-print flimflam_object.Introspect()
-
-manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"),
- "org.chromium.flimflam.Manager")
-properties = manager.GetProperties(utf8_strings = True)
-
-for path in properties["Devices"]:
- device = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.freedesktop.DBus.Introspectable")
- print device.Introspect()
-
- device_object = dbus.Interface(
- bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Device")
- devprops = device_object.GetProperties(utf8_strings = True)
- for ipconfig_path in devprops["IPConfigs"]:
- ipconfig = dbus.Interface(
- bus.get_object("org.chromium.flimflam", ipconfig_path),
- "org.freedesktop.DBus.Introspectable")
- print ipconfig.Introspect()
diff --git a/test/stability b/test/stability
deleted file mode 100755
index 65e0835..0000000
--- a/test/stability
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2010 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.
-
-import math
-import optparse
-import sched
-import subprocess
-import sys
-import time
-
-
-def fxrange(start, finish, increment=1.0):
- """Like xrange, but with float arguments."""
- steps = int(math.ceil(float(finish - start) / increment))
-
- if steps < 0:
- raise ValueError
-
- for i in xrange(steps):
- yield start + i * increment
-
-
-def hms(seconds):
- hours = int(seconds / (60 * 60))
- seconds -= hours * 60 * 60
- minutes = int(seconds / 60)
- seconds -= minutes * 60
- return '%d:%02d:%02d' % (hours, minutes, seconds)
-
-
-class PeriodicExperiment(object):
- """Uses the scheduler to run the specified function repeatedly."""
- def __init__(self,
- scheduler=None,
- total_duration=8 * 60 * 60,
- test_interval=60,
- test_function=None):
- self._scheduler = scheduler
- self._total_duration = total_duration
- self._test_interval = test_interval
- self._test_function = test_function
- self._start = self._scheduler.timefunc()
- self._finish = self._start + self._total_duration
-
- def Run(self):
- for start_one in fxrange(self._start,
- self._finish,
- self._test_interval):
- time_remaining = self._finish - start_one
- self._scheduler.enterabs(start_one,
- 1, # Priority
- self._test_function,
- [time_remaining])
- self._scheduler.run()
-
-
-class ManualExperiment(object):
- """Runs the experiment repeatedly, prompting for input each time."""
- def __init__(self, test_function):
- self._test_function = test_function
-
- def Run(self):
- try:
- while True:
- self._test_function(0) # Pass in a fake time remaining
- _ = raw_input('Press return to run the test again. '
- 'Control-c to exit.')
- except KeyboardInterrupt:
- return
-
-class IperfTest(object):
- def __init__(self, filename, servername, individual_length):
- self._file = file(filename, 'a')
- self._servername = servername
- self._individual_length = individual_length
-
- def Run(self, remaining):
- """Run iperf, log output to file, and print."""
- iperf = ['iperf',
- '--client', self._servername,
- # Transfer time in seconds.
- '--time', str(self._individual_length),
- '--reportstyle', 'c' # CSV output
- ]
- print '%s remaining. Running %s' % (hms(remaining), ' '.join(iperf))
- result = subprocess.Popen(iperf,
- stdout=subprocess.PIPE).communicate()[0]
- print result.rstrip()
- sys.stdout.flush()
- self._file.write(result)
- self._file.flush()
-
- def teardown(self):
- self._file.close()
-
-def main():
- default_output = 'stability-' + time.strftime('%Y-%m-%d-%H-%M-%S')
-
- parser = optparse.OptionParser()
- parser.add_option('--server', default=None,
- help='Machine running the iperf server')
- parser.add_option('--test_interval', default=60 * 5, type='int',
- help='Interval (in seconds) between tests')
- parser.add_option('--individual_length', default=10, type='int',
- help='length (in seconds) of each individual test')
- parser.add_option('--total_duration', default=8 * 60 * 60, type='int',
- help='length (in seconds) for entire test')
- parser.add_option('--output', default=default_output,
- help='Output file')
- parser.add_option('--manual', default=False, action='store_true',
- help='Manual mode; wait for input between every test')
-
- (options, _) = parser.parse_args()
-
- if not options.server:
- print 'No server specified. Specify a server with --server=SERVER.'
- exit(2)
-
- if options.individual_length > options.test_interval:
- print ('The length of a given bandwidth test must be lower than the '
- 'interval between tests')
- exit(2)
-
- s = sched.scheduler(time.time, time.sleep)
-
- iperf = IperfTest(filename=options.output,
- servername=options.server,
- individual_length=options.individual_length)
-
- if options.manual:
- e = ManualExperiment(test_function=iperf.Run)
- else:
- e = PeriodicExperiment(scheduler=s,
- total_duration=options.total_duration,
- test_interval=options.test_interval,
- test_function=iperf.Run)
- e.Run()
- iperf.teardown()
-
-if __name__ == '__main__':
- main()
diff --git a/test/start-scanning b/test/start-scanning
deleted file mode 100755
index 3ceebbc..0000000
--- a/test/start-scanning
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-if (len(sys.argv) != 2):
- print "Usage: %s <technology>" % (sys.argv[0])
- sys.exit(1)
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-flim.RequestScan(sys.argv[1])
diff --git a/test/test-compat b/test/test-compat
deleted file mode 100755
index e5494a4..0000000
--- a/test/test-compat
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/python
-
-import dbus
-
-bus = dbus.SystemBus()
-
-manager = dbus.Interface(bus.get_object('org.freedesktop.NetworkManager',
- '/org/freedesktop/NetworkManager'),
- 'org.freedesktop.NetworkManager')
-
-states = [ "unknown", "asleep", "connecting", "connected", "disconnected" ]
-
-state = manager.state()
-
-print "System is %s" % (states[state])
diff --git a/test/test-flimflam b/test/test-flimflam
deleted file mode 100755
index 72ca243..0000000
--- a/test/test-flimflam
+++ /dev/null
@@ -1,375 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import dbus
-import flimflam
-
-bus = dbus.SystemBus()
-
-manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"),
- "org.chromium.flimflam.Manager")
-
-if len(sys.argv) < 2:
- print "Usage: %s <command>" % (sys.argv[0])
- print ""
- print " state"
- print " recheck-portal"
- print " services"
- print " passphrase <service> [passphrase]"
- print " autoconnect <service> [autoconnect]"
- print " connect <service>"
- print " disconnect <service>"
- print " remove <service>"
- print ""
- print " scan [type]"
- print " enable <type>"
- print " disable <type>"
- print " offlinemode [on|off]"
- print ""
- print " dev <interface>"
- print " dev <interface> scan"
- print " dev <interface> networks"
- print " dev <interface> connect <network>"
- print " dev <interface> disconnect [network]"
- print " dev <interface> powered [on|off]"
- sys.exit(1)
-
-def print_properties(object_path, properties):
- print "[ %s ]" % (object_path)
- for key in properties.keys():
- if key == "Networks":
- continue
-
- if key in ["Powered", "Scanning", "Connected",
- "Available", "Remember", "Default"]:
- if properties[key] == dbus.Boolean(1):
- val = "true"
- else:
- val = "false"
- elif key in ["Strength", "Priority"]:
- val = int(properties[key])
- else:
- val = str(properties[key])
-
- print " %s = %s" % (key, val)
-
-def print_networks(networks):
- for object_path in networks:
- network = dbus.Interface(
- bus.get_object("org.chromium.flimflam", object_path),
- "org.chromium.flimflam.Network")
-
- properties = network.GetProperties(utf8_strings = True)
-
- if properties["Connected"] == dbus.Boolean(1):
- connected = "*"
- else:
- connected = " "
-
- if "Name" in properties.keys():
- name = properties["Name"]
- else:
- name = ""
-
- strength = int(properties["Strength"])
-
- details = ""
- try:
- details += "{" + properties["WiFi.Mode"] + "} "
- except Exception, _:
- pass
- try:
- details += "{" + properties["WiFi.Security"] + "} "
- except Exception, _:
- pass
- if "WiFi.Passphrase" in properties.keys():
- if properties["WiFi.Passphrase"] != "":
- details += "{passphrase present}"
-
- print "%s %-26s %3d%% %s" % (connected, name, strength, details)
-
-def select_network(networks, name):
- for object_path in networks:
- network = dbus.Interface(
- bus.get_object("org.chromium.flimflam", object_path),
- "org.chromium.flimflam.Network")
-
- properties = network.GetProperties(utf8_strings = True)
-
- if properties["Name"] != name:
- continue
-
- if properties["Connected"] == dbus.Boolean(1):
- print "Already connected to network %s" % (name)
- break
-
- print "Selecting network %s" % (name)
-
- network.Connect()
-
-def disconnect_network(networks, name):
- for object_path in networks:
- network = dbus.Interface(
- bus.get_object("org.chromium.flimflam", object_path),
- "org.chromium.flimflam.Network")
-
- properties = network.GetProperties(utf8_strings = True)
-
- if name != "" and properties["Name"] != name:
- continue
-
- if properties["Connected"] == dbus.Boolean(1):
- name = properties["Name"]
- print "Disconnecting from network %s" % (name)
- network.Disconnect()
-
-def print_services(services):
- for object_path in services:
- service = dbus.Interface(
- bus.get_object("org.chromium.flimflam", object_path),
- "org.chromium.flimflam.Service")
-
- properties = service.GetProperties(utf8_strings = True)
-
- identifier = object_path[object_path.rfind("/") + 1:]
-
- if properties["Favorite"] == dbus.Boolean(1):
- favorite = "*"
- else:
- favorite = " "
-
- if "Name" in properties.keys():
- name = properties["Name"]
- else:
- name = "{" + properties["Type"] + "}"
-
- print "%s %-26s { %s }" % (favorite, name, identifier)
-
-def main():
- if sys.argv[1] == "state":
- properties = manager.GetProperties(utf8_strings = True)
-
- print "System is %s" % (properties["State"])
-
- elif sys.argv[1] == "recheck-portal":
- manager.RecheckPortal()
- print "Rechecking portal state"
-
- elif sys.argv[1] in ["services", "list", "show"]:
- properties = manager.GetProperties(utf8_strings = True)
-
- print_services(properties["Services"])
-
- elif sys.argv[1] in ["passphrase", "pass"]:
- if (len(sys.argv) < 3):
- print "Need at least service parameter"
- sys.exit(1)
-
- path = "/profile/default/" + sys.argv[2]
-
- service = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Service")
-
- if (len(sys.argv) > 3):
- passphrase = sys.argv[3]
-
- service.SetProperty("Passphrase", passphrase)
-
- print "Passphrase %s set for %s" % (passphrase, sys.argv[2])
- else:
- properties = service.GetProperties(utf8_strings = True)
-
- if "Name" in properties.keys():
- name = properties["Name"]
- else: name = "{" + properties["Type"] + "}"
-
- if "Passphrase" in properties.keys():
- passphrase = properties["Passphrase"]
- else:
- passphrase = "not set"
-
- print "Passphrase for %s is %s" % (name, passphrase)
-
- elif sys.argv[1] in ["autoconnect", "autoconn"]:
- if (len(sys.argv) < 3):
- print "Need at least service parameter"
- sys.exit(1)
-
- path = "/profile/default/" + sys.argv[2]
-
- service = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Service")
-
- if (len(sys.argv) > 3):
- autoconnect = flimflam.make_dbus_boolean(sys.argv[3])
-
- service.SetProperty("AutoConnect", autoconnect)
-
- print "Auto connect %s for %s" % (autoconnect, sys.argv[2])
- else:
- properties = service.GetProperties(utf8_strings = True)
-
- if "Name" in properties.keys():
- name = properties["Name"]
- else:
- name = "{" + properties["Type"] + "}"
-
- if "AutoConnect" in properties.keys():
- autoconnect = properties["AutoConnect"]
- else:
- autoconnect = dbus.Boolean(0)
-
- print "Auto connect %s for %s" % (autoconnect, name)
-
- elif sys.argv[1] in ["connect", "conn"]:
- if (len(sys.argv) < 3):
- print "Need at least service parameter"
- sys.exit(1)
-
- path = "/profile/default/" + sys.argv[2]
-
- service = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Service")
-
- try:
- service.Connect(timeout=60000)
- except dbus.DBusException, error:
- print "%s: %s" % (error.get_dbus_name(), error.message)
-
- elif sys.argv[1] in ["disconnect", "disc"]:
- if (len(sys.argv) < 3):
- print "Need at least service parameter"
- sys.exit(1)
-
- path = "/profile/default/" + sys.argv[2]
-
- service = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Service")
-
- try:
- service.Disconnect()
- except dbus.DBusException, error:
- print "%s: %s" % (error.get_dbus_name(), error.message)
-
- elif sys.argv[1] in ["remove"]:
- if (len(sys.argv) < 3):
- print "Need at least service parameter"
- sys.exit(1)
-
- path = "/profile/default/" + sys.argv[2]
-
- service = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Service")
-
- properties = service.GetProperties(utf8_strings = True)
-
- if properties["Favorite"] == dbus.Boolean(0):
- print "Only favorite services can be removed"
- sys.exit(1)
-
- try:
- service.Remove()
- except dbus.DBusException, error:
- print "%s: %s" % (error.get_dbus_name(), error.message)
-
- elif sys.argv[1] == "scan":
- if len(sys.argv) > 2:
- manager.RequestScan(sys.argv[2])
- else:
- manager.RequestScan("")
-
- elif sys.argv[1] == "enable":
- if len(sys.argv) > 2:
- manager.EnableTechnology(sys.argv[2])
- else:
- manager.EnableTechnology("")
-
- elif sys.argv[1] == "disable":
- if len(sys.argv) > 2:
- manager.DisableTechnology(sys.argv[2])
- else:
- manager.DisableTechnology("")
-
- elif sys.argv[1] in ["offlinemode", "flightmode"]:
- if len(sys.argv) > 2:
- active = flimflam.make_dbus_boolean(sys.argv[2])
- manager.SetProperty("OfflineMode", active)
- else:
- properties = manager.GetProperties(utf8_strings = True)
- print "Offline mode is %s" % (properties["OfflineMode"])
-
- elif sys.argv[1] == "dev":
- properties = manager.GetProperties(utf8_strings = True)
-
- interface = ""
- command = ""
- value = ""
-
- if len(sys.argv) > 2:
- interface = sys.argv[2]
- if len(sys.argv) > 3:
- command = sys.argv[3]
- if len(sys.argv) > 4:
- value = sys.argv[4]
-
- for path in properties["Devices"]:
- device = dbus.Interface(
- bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Device")
-
- properties = device.GetProperties(utf8_strings = True)
-
- if (interface != "" and
- properties.get("Interface", "") != interface and
- path != interface):
- continue
-
- if command == "scan":
- if properties["Type"] in ["wifi", "wimax"]:
- interface = properties["Interface"]
- print "Scan for device %s" % (interface)
- device.ProposeScan()
- else:
- print "No scanning for device %s" % (interface)
- elif command in ["networks", "net"]:
- if "Networks" in properties.keys():
- print_networks(properties["Networks"])
- else:
- print "Device has no networks"
- elif command in ["connect", "conn"] and value != "":
- if "Networks" in properties.keys():
- select_network(properties["Networks"], value)
- else:
- print "Device can't connect networks"
- elif command in ["connect", "conn"]:
- print "Need to specify network"
- elif command in ["disconnect", "disc"] and value != "":
- if "Networks" in properties.keys():
- disconnect_network(properties["Networks"], value)
- else:
- print "Device has no networks"
- elif command in ["discconnect", "disc"]:
- if "Networks" in properties.keys():
- disconnect_network(properties["Networks"], "")
- else:
- print "Device has no networks"
- elif command == "powered" and value != "":
- powered = flimflam.make_dbus_boolean(value)
- device.SetProperty("Powered", powered)
- elif command == "powered":
- interface = properties.get("Interface", "unknown")
- if properties["Powered"] == dbus.Boolean(1):
- powered = "on"
- else:
- powered = "off"
- print "Device %s is powered %s" % (interface, powered)
- elif command == "list" or command == "":
- print_properties(path, properties)
- else:
- print "Unknown command"
-
- else:
- print "Unknown command"
-
-if __name__ == "__main__":
- main()
diff --git a/test/test-manager b/test/test-manager
deleted file mode 100755
index e7b32b7..0000000
--- a/test/test-manager
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/python
-
-import dbus
-
-def print_sub_properties(key, value):
- if key == "Profiles":
- interface = "org.chromium.flimflam.Profile"
- elif key == "Devices":
- interface = "org.chromium.flimflam.Device"
- elif key == "Services":
- interface = "org.chromium.flimflam.Service"
- else:
- return
-
- print "%s" % (key)
- for path in value:
- print " %s" % (path)
- obj = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- interface)
-
- properties = obj.GetProperties(utf8_strings = True)
-
- for key in properties.keys():
- if key in ["Networks", "Services"]:
- continue
-
- if key in ["Powered", "Scanning", "Connected",
- "Available", "Remember", "Default"]:
- if properties[key] == dbus.Boolean(1):
- val = "true"
- else:
- val = "false"
- elif key in ["Strength", "Priority"]:
- val = int(properties[key])
- else:
- val = str(properties[key])
-
- print " %s = %s" % (key, val)
-
- if "Services" in properties.keys():
- remove_prefix = lambda x: x[x.rfind("/") + 1]
- services = [" ".join(
- map(remove_prefix, map(str, properties["Services"])))]
- print " Services = [ %s]" % (services)
-
-def print_properties(properties):
- for key in properties.keys():
- if key in ["Profiles", "Devices", "Services"]:
- print_sub_properties(key, properties[key])
- elif key in ["AvailableTechnologies", "EnabledTechnologies",
- "ConnectedTechnologies"]:
- print "%s" % (key)
- print " [ %s]" % (" ".join(properties[key]))
- elif key in ["OfflineMode"]:
- print "%s" % (key)
- if properties[key] == dbus.Boolean(1):
- print " true"
- else:
- print " false"
- elif key in ["DefaultTechnology"]:
- print "%s" % (key)
- if properties[key] == "":
- print " <none>"
- else:
- print " %s" % (properties[key])
- else:
- print "%s" % (key)
- print " %s" % (properties[key])
-
-bus = dbus.SystemBus()
-
-manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"),
- "org.chromium.flimflam.Manager")
-
-print_properties(manager.GetProperties(utf8_strings = True))
diff --git a/test/test-profile b/test/test-profile
deleted file mode 100755
index fa7589b..0000000
--- a/test/test-profile
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/python
-
-import dbus, flimflam, sys
-
-flim = flimflam.FlimFlam(dbus.SystemBus())
-
-if len(sys.argv) < 2:
- print "Usage: %s <command>" % (sys.argv[0])
- print " create <profile>"
- print " list"
- print " name <profile> [name]"
- print " pop [<profile>]"
- print " push <profile>"
- print " remove <profile>"
- print ""
- print "where <profile> is of the form ident or ~user/ident"
- print "(beware that ~user may need shell quoting)"
- sys.exit(1)
-
-
-def print_profiles():
- active = flim.GetActiveProfile()
- for a_profile in flim.GetObjectList("Profile"):
- if a_profile.object_path == active.object_path:
- isactive = "*"
- else:
- isactive = " "
-
- # TODO(sleffler) handler ~user paths
- identifier = a_profile.object_path[
- a_profile.object_path.rfind("/") + 1:]
-
- profile_properties = a_profile.GetProperties(utf8_strings = True)
- name = profile_properties.get("Name", "<unnamed>")
-
- print "%s %-12s %s" % (isactive, identifier, name)
-
-if sys.argv[1] in ["list", "show"]:
- print_profiles()
-
-elif sys.argv[1] in ["name"]:
- if (len(sys.argv) < 3):
- print "Need at least profile parameter"
- sys.exit(1)
-
- profile = flim.FindElementByNameSubstring('Profile', sys.argv[2])
- if (len(sys.argv) > 3):
- profile.SetProperty("Name", sys.argv[3])
- else:
- properties = profile.GetProperties(utf8_strings = True)
- print "%s" % properties.get("Name", "<unnamed>")
-
-elif sys.argv[1] in ["create"]:
- if (len(sys.argv) < 3):
- print "Profile identifier required"
- sys.exit(1)
-
- flim = flimflam.FlimFlam(dbus.SystemBus())
- profile = flim.CreateProfile(sys.argv[2])
- print "Created profile %s" % (profile.object_path)
-
-elif sys.argv[1] in ["remove"]:
- if (len(sys.argv) < 3):
- print "Profile identifier required"
- sys.exit(1)
-
- flim = flimflam.FlimFlam(dbus.SystemBus())
- flim.RemoveProfile(sys.argv[2])
- print "Removed profile %s" % (sys.argv[2])
-
-elif sys.argv[1] in ["push"]:
- if (len(sys.argv) < 3):
- print "Profile identifier required"
- sys.exit(1)
-
- flim = flimflam.FlimFlam(dbus.SystemBus())
- profile = flim.PushProfile(sys.argv[2])
- print "Pushed profile %s" % (profile.object_path)
-
-elif sys.argv[1] in ["pop"]:
- if (len(sys.argv) == 3):
- flim.PopProfile(sys.argv[2])
- else:
- flim.PopAnyProfile()
-
-else:
- print "Unknown command"
diff --git a/test/usage.html b/test/usage.html
deleted file mode 100644
index 6177daf..0000000
--- a/test/usage.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "status": "OK",
- "restricted": false,
- "version": 1,
- "plans": [
- {
- "planName": "All-You-Can-Eat Day Pass",
- "lastUpdate": "2010-12-21T21:03:24Z",
- "planType": "UNLIMITED",
- "usedBytes": 204200000,
- "startTime": "2010-12-21T13:03:24Z",
- "expirationTime": "2010-12-22T13:03:24Z"
- },
- {
- "planName": "Super-Awesome Chrome OS Promo Plan",
- "lastUpdate": "2010-12-21T21:03:24Z",
- "maxBytes": 102400000,
- "planType": "METERED_FREE",
- "usedBytes": 51200000,
- "startTime": "2010-11-22T13:03:24Z",
- "expirationTime": "2010-12-22T13:03:24Z"
- }
- ]
-}
diff --git a/test/veth b/test/veth
deleted file mode 100644
index d80c368..0000000
--- a/test/veth
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/sh
-# Virtual ethernet interface control script
-# Sometimes, we need a virtual interface of arbitrary name and configuration
-# that we can do dhcp on. This script is for those times.
-
-# Basically,
-# $ veth setup foo 127.0.1
-# $ dhclient foo
-# ...
-# $ veth teardown foo
-# Would set up an ethernet interface called 'foo' whose dhcpd is at 127.0.1.1
-# and which will allocate addresses from 127.0.1.0/24. Note that using anything
-# inside 127.0.0.0/8 is a bad idea here, since lo already handles those.
-
-usage () {
- echo "Usage: $0 <command> [args...]"
- echo " setup <iface> <base> Sets up <iface> for <base>.0/24"
- echo " teardown <iface> Tears down <iface>"
-}
-
-setup () {
- iface="$1"
- base="$2"
- peer_iface="${iface}p"
- lease_file="/tmp/dnsmasq.${iface}.leases"
- pid_file="/tmp/dnsmasq.${iface}.pid"
- ip link add name "$iface" type veth peer name "$peer_iface"
- ifconfig "$peer_iface" "${base}.0/32"
- ifconfig "$peer_iface" up
- ifconfig "$iface" up
- route add -host 255.255.255.255 dev "$peer_iface"
- truncate -s 0 "$lease_file"
- dnsmasq --pid-file="$pid_file" \
- --dhcp-leasefile="$lease_file" \
- --dhcp-range="${base}.2,${base}.254" \
- --port=0 \
- --interface="$peer_iface" \
- --bind-interfaces
-}
-
-teardown () {
- iface="$1"
- pid_file="/tmp/dnsmasq.${iface}.pid"
- [ -f "$pid_file" ] && kill -TERM $(cat "$pid_file")
- route del -host 255.255.255.255
- ip link del "$iface"
-}
-
-if [ -z "$1" ]; then
- usage
- exit 1
-fi
-
-command="$1" ; shift
-case "$command" in
- setup)
- setup "$@"
- ;;
- teardown)
- teardown "$@"
- ;;
- *)
- usage
- ;;
-esac