def test_CellularSmokeNoCallBoxSetup(self):
        self._reset_everything()
        logger.debug('making flimflam object..')
        self.flim = flimflam.FlimFlam()
        logger.debug('Find Cellular Device ...')
        self.device = self.flim.FindCellularDevice()
        logger.debug('Find Celluar Service..')
        self.service = self.flim.FindCellularService()
        logger.debug('Set Auto Connect to False ..')
        self.service.SetProperty('AutoConnect', dbus.Boolean(False))

        logger.debug('Reset all modems ..')
        network.ResetAllModems(self.flim)
        logger.debug('Prepare Modem for LTE..')
        cell_tools.PrepareModemForTechnology('', 'Technology:LTE')

        logger.debug('Make another flimflam..')
        self.flim = flimflam.FlimFlam()
        logger.debug('Sleep for 5...')
        time.sleep(5)
        logger.debug('Connect to Cellular...')
        cell_tools.ConnectToCellular(self.flim, timeout=60)
        logger.debug('Clearing errors...')
        env.emulator.ClearErrors()
        logger.debug('Check connect to cellular ...')
        service = env.CheckedConnectToCellular()
 def test_TurnOnPxtAndConnectToCellularWorks(self):
     self._reset_everything()
     self.flim = flimflam.FlimFlam()
     #self.device = self.flim.FindCellularDevice()
     self.service = self.flim.FindCellularService()
     self.service.SetProperty('AutoConnect', dbus.Boolean(False))
     with environment.DefaultCellularTestContext(config) as c:
         env = c.env
         env.StartDefault(technology_lte)
         self.flim = flimflam.FlimFlam()  # because the manger destroys it?
         cell_tools.ConnectToCellular(self.flim, timeout=60)
Exemplo n.º 3
0
    def run_once(self, config, technology):
        # The DefaultCellularTestContext builds:
        #  * a backchannel ethernet context.  This makes a virtual
        #    device that connects the DUT to the test infrastructure.
        #    It has restrictive routes and is outside of flimflam's
        #    control.  This makes the tests resilient to flimflam
        #    restarts and helps to ensure that the test is actually
        #    sending traffic on the cellular link
        #  * an OtherDeviceShutdownContext, which shuts down other
        #    network devices on the host.  Again, this is to ensure
        #    that test traffic goes over the modem
        #  * A cellular test environment context, which lets us
        #    interact with the cell network.

        with environment.DefaultCellularTestContext(config) as c:
            env = c.env
            flim = flimflam.FlimFlam()
            env.StartDefault(technology)
            network.ResetAllModems(flim)
            cell_tools.PrepareModemForTechnology('', technology)

            # TODO(rochberg) Need to figure out what isn't settling here.
            # Going to wait 'til after ResetAllModems changes land.
            time.sleep(10)

            # Clear all errors before we start.
            # Resetting the modem above may have caused some errors on the
            # 8960 (eg. lost connection, etc).
            env.emulator.ClearErrors()

            service = env.CheckedConnectToCellular()
            env.CheckHttpConnectivity()
            env.CheckedDisconnectFromCellular(service)
Exemplo n.º 4
0
    def init_flimflam(self):
        # Initialize flimflam and device type specific functions.
        self.flim = flimflam.FlimFlam(dbus.SystemBus())
        self.flim.SetDebugTags(SHILL_LOG_SCOPES)

        self.flim.FindCellularService = self.flim.FindCellularService
        self.flim.FindCellularDevice = self.flim.FindCellularDevice
Exemplo n.º 5
0
    def run_once(self, name='wwan', loops=20, seed=None):
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self.bus = dbus.SystemBus()

        main_loop = gobject.MainLoop()

        modem_path = self.FindModemPath()
        if not modem_path:
            raise error.TestFail('No Gobi modem found.')
        print 'Modem: %s' % (modem_path, )
        self.RequestDormancyEvents(modem_path)

        flim = flimflam.FlimFlam()
        device = flim.FindElementByNameSubstring('Device', name)

        if not device:
            device = flim.FindElementByPropertySubstring(
                'Device', 'Interface', name)
        self.bus.add_signal_receiver(self.PropertyChanged,
                                     signal_name='PropertyChanged')
        self.bus.add_signal_receiver(self.DormancyStatus,
                                     signal_name='DormancyStatus')
        self.tester = DormancyTester(main_loop=main_loop,
                                     loops=loops,
                                     flim=flim,
                                     device=device)
        self.tester.run()
Exemplo n.º 6
0
    def run_once(self, **kwargs):
        # Number of connectivity test runs.
        self._connect_count = kwargs.get('connect_count', 5)

        # Number of seconds to sleep between connect and disconnect operations.
        self._sleep_kludge = kwargs.get('sleep_kludge', 5)

        # URL pattern to fetch data from during each connectivity test run.
        self._fetch_url_pattern = \
            kwargs.get('fetch_url_pattern', network.FETCH_URL_PATTERN_FOR_TEST)

        # Timeout in seconds for connect and disconnect operations, and
        # fetching data from a URL.
        self._connect_timeout = kwargs.get('connect_timeout', 10)
        self._disconnect_timeout = kwargs.get('disconnect_timeout', 10)
        self._fetch_timeout = kwargs.get('fetch_timeout', 120)

        # Number of bytes to fetch during each connectivity test run.
        self._bytes_to_fetch = kwargs.get('bytes_to_fetch', 64 * 1024)

        with backchannel.Backchannel():
            with cell_tools.OtherDeviceShutdownContext('wimax'):
                # TODO(benchan): Replace FlimFlam with ShillProxy.
                self._flim = flimflam.FlimFlam()
                self._flim.SetDebugTags(SHILL_LOG_SCOPES)
                self._service = self._flim.FindWimaxService()
                if not self._service:
                    raise error.TestError('Could not find a WiMAX service.')

                with shill_context.ServiceAutoConnectContext(
                        self._flim.FindWimaxService, False):
                    self._disconnect_service()
                    for _ in xrange(self._connect_count):
                        self._test_connectivity()
    def _run_group_backchannel(self):
        """WiFi sub-tests."""

        wifi_ap = 'GoogleGuest'
        wifi_sec = 'none'
        wifi_pw = ''

        flim = flimflam.FlimFlam()
        conn = flim.ConnectService(retries=3,
                                   retry=True,
                                   service_type='wifi',
                                   ssid=wifi_ap,
                                   security=wifi_sec,
                                   passphrase=wifi_pw,
                                   mode='managed')
        if not conn[0]:
            logging.error("Could not connect to WiFi")
            return

        logging.info('Starting Backchannel')
        with backchannel.Backchannel():
            # Wifi needs some time to recover after backchanel is activated
            # TODO (kamrik) remove this sleep, once backchannel handles this
            time.sleep(15)

            cmd = 'ping -c %s www.google.com' % (self._duration_secs)
            self._run_cmd('ping_wifi', cmd)

            # This URL must be visible from WiFi network used for test
            big_file_url = ('http://googleappengine.googlecode.com'
                            '/files/GoogleAppEngine-1.6.2.msi')
            cmd = 'curl %s > /dev/null' % big_file_url
            self._run_cmd('download_wifi', cmd, repeat=self._repeats)
Exemplo n.º 8
0
    def run_once(self, config, technology):
        with environment.DefaultCellularTestContext(config) as c:
            env = c.env
            flim = flimflam.FlimFlam()
            env.StartDefault(technology)
            network.ResetAllModems(flim)
            cell_tools.PrepareModemForTechnology('', technology)

            # TODO(rochberg): Figure out why this is necessary
            time.sleep(10)

            # Clear all errors before we start.
            # Resetting the modem above may have caused some errors on the
            # 8960 (eg. lost connection, etc).
            env.emulator.ClearErrors()

            service = env.CheckedConnectToCellular()

            # TODO(rochberg): Factor this and the counts stuff out
            # so that individual tests don't have to care.
            env.emulator.LogStats()
            env.emulator.ResetDataCounters()

            perf = http_speed.HttpSpeed(
                env.config.cell['perfserver']['download_url_format_string'],
                env.config.cell['perfserver']['upload_url'])

            # TODO(rochberg):  Can/should we these values into the
            # write_perf_keyval dictionary?  Now we just log them.
            env.emulator.GetDataCounters()

            env.CheckedDisconnectFromCellular(service)

            self.write_perf_keyval(perf)
Exemplo n.º 9
0
    def __init__(self, logdir, method=sys_power.do_suspend,
                 throw=False, device_times=False, suspend_state=''):
        """
        Prepare environment for suspending.
        @param suspend_state: Suspend state to enter into. It can be
                              'mem' or 'freeze' or an empty string. If
                              the suspend state is an empty string,
                              system suspends to the default pref.
        """
        self.disconnect_3G_time = 0
        self.successes = []
        self.failures = []
        self._logdir = logdir
        self._suspend = method
        self._throw = throw
        self._reset_pm_print_times = False
        self._restart_tlsdated = False
        self._log_file = None
        self._suspend_state = suspend_state
        if device_times:
            self.device_times = []

        # stop tlsdated, make sure we/hwclock have /dev/rtc for ourselves
        if utils.system_output('initctl status tlsdated').find('start') != -1:
            utils.system('initctl stop tlsdated')
            self._restart_tlsdated = True
            # give process's file descriptors time to asynchronously tear down
            time.sleep(0.1)

        # prime powerd_suspend RTC timestamp saving and make sure hwclock works
        utils.open_write_close(self.HWCLOCK_FILE, '')
        hwclock_output = utils.system_output('hwclock -r --debug --utc',
                                             ignore_status=True)
        if not re.search('Using.*/dev interface to.*clock', hwclock_output):
            raise error.TestError('hwclock cannot find rtc: ' + hwclock_output)

        # activate device suspend timing debug output
        if hasattr(self, 'device_times'):
            if not int(utils.read_one_line('/sys/power/pm_print_times')):
                self._set_pm_print_times(True)
                self._reset_pm_print_times = True

        # Shut down 3G to remove its variability from suspend time measurements
        flim = flimflam.FlimFlam()
        service = flim.FindCellularService(0)
        if service:
            logging.info('Found 3G interface, disconnecting.')
            start_time = time.time()
            (success, status) = flim.DisconnectService(
                    service=service, wait_timeout=60)
            if success:
                logging.info('3G disconnected successfully.')
                self.disconnect_3G_time = time.time() - start_time
            else:
                logging.error('Could not disconnect: %s.', status)
                self.disconnect_3G_time = -1

        self._configure_suspend_state()
 def test_TurnOnPxtAndConnectToCellularWorksAddSmoke(self):
     self._reset_everything()
     self.flim = flimflam.FlimFlam()
     #self.device = self.flim.FindCellularDevice()
     self.service = self.flim.FindCellularService()
     self.service.SetProperty('AutoConnect', dbus.Boolean(False))
     with environment.DefaultCellularTestContext(config) as c:
         env = c.env
         env.StartDefault(technology_lte)
         cell_tools.PrepareModemForTechnology('', technology_lte)
         self.flim = flimflam.FlimFlam()  # because the manger destroys it?
         #network.ResetAllModems(self.flim)
         self.flim = flimflam.FlimFlam()  # because the manger destroys it?
         cell_tools.ConnectToCellular(self.flim, timeout=60)
         env.emulator.ClearErrors()
         service = env.CheckedConnectToCellular()
         #env.CheckHttpConnectivity()
         env.CheckedDisconnectFromCellular(service)
    def _initialize_shill(self):
        """Get access to shill."""
        # CellularProxy.get_proxy() checks to see if shill is running and
        # responding to DBus requests. It returns None if that's not the case.
        self.shill = cellular_proxy.CellularProxy.get_proxy(self.bus)
        if self.shill is None:
            raise error.TestError('Cannot connect to shill, is shill running?')

        # Keep this around to support older tests that haven't migrated to
        # cellular_proxy.
        self.flim = flimflam.FlimFlam()
Exemplo n.º 12
0
    def init_flimflam(self, device_type):
        # Initialize flimflam and device type specific functions.
        self.flim = flimflam.FlimFlam(dbus.SystemBus())
        self.flim.SetDebugTags(SHILL_LOG_SCOPES)

        logging.debug('Using device type: %s' % device_type)
        if device_type == flimflam.FlimFlam.DEVICE_WIMAX:
            self.FindMobileService = self.flim.FindWimaxService
            self.FindMobileDevice = self.flim.FindWimaxDevice
            self.modem_status = self._skip_modem_status
            self.connect_mobile_service = self.connect_wimax
        elif device_type == flimflam.FlimFlam.DEVICE_CELLULAR:
            self.FindMobileService = self.flim.FindCellularService
            self.FindMobileDevice = self.flim.FindCellularDevice
            self.modem_status = self._get_modem_status
            self.connect_mobile_service = self.flim.ConnectService
        else:
            raise error.TestError('Device type %s not supported yet.' %
                                  device_type)
Exemplo n.º 13
0
 def __enter__(self):
     self.device_manager = flimflam.DeviceManager(flimflam.FlimFlam())
     self.device_manager.ShutdownAllExcept(self.device_type)
     return self
Exemplo n.º 14
0
 def __enter__(self):
     self.flim = flimflam.FlimFlam()
     return self
    def run_once(self, config, technologies, wait_for_disc, verify_set_power):

        # This test only works if all the technologies are in the same
        # family. Check that before doing anything else.
        families = set(
            cellular.TechnologyToFamily[tech] for tech in technologies)
        if len(families) > 1:
            raise error.TestError('Specify only one family not: %s' % families)

        # choose a technology other than the one we plan to start with
        technology = technologies[-1]
        with environment.DefaultCellularTestContext(config) as c:
            env = c.env
            flim = flimflam.FlimFlam()
            flim.SetDebugTags('manager+device+modem')
            env.StartDefault(technology)
            network.ResetAllModems(flim)
            logging.info('Preparing for %s' % technology)
            cell_tools.PrepareModemForTechnology('', technology)

            # TODO(jglasgow) Need to figure out what isn't settling here.
            # Going to wait 'til after ResetAllModems changes land.
            time.sleep(10)

            # Clear all errors before we start.
            # Resetting the modem above may have caused some errors on the
            # 8960 (eg. lost connection, etc).
            env.emulator.ClearErrors()

            service = env.CheckedConnectToCellular(timeout=CELLULAR_TIMEOUT)

            # Step through all technologies, forcing a transition
            failed_technologies = []
            manager, modem_path = mm.PickOneModem('')
            cell_modem = manager.GetModem(modem_path)
            for tech in technologies:
                tname = str(tech).replace('Technology:', '')
                if verify_set_power:
                    logging.info('Powering off basestation')
                    env.emulator.SetPower(cellular.Power.OFF)
                    self.TimedPollForCondition(
                        'Power.OFF.%s.deregister_time' % tname,
                        lambda: not cell_modem.ModemIsRegistered(),
                        timeout=CELLULAR_TIMEOUT,
                        exception=_STILL_REGISTERED_ERROR)

                    logging.info('Powering on basestation')
                    env.emulator.SetPower(cellular.Power.DEFAULT)
                    self.TimedPollForCondition(
                        'Power.DEFAULT.%s.register_time' % tname,
                        lambda: cell_modem.ModemIsRegistered(),
                        timeout=CELLULAR_TIMEOUT,
                        exception=_NOT_REGISTERED_ERROR)

                logging.info('Stopping basestation')
                env.emulator.Stop()
                if wait_for_disc:
                    self.TimedPollForCondition(
                        'Stop.%s.deregister_time' % tname,
                        lambda: not cell_modem.ModemIsRegistered(),
                        timeout=CELLULAR_TIMEOUT,
                        exception=_STILL_REGISTERED_ERROR)

                logging.info('Reconfiguring for %s' % tech)
                env.emulator.SetTechnology(tech)
                env.emulator.Start()

                try:
                    self.TimedPollForCondition(
                        'Start.%s.register_time' % tname,
                        lambda: cell_modem.ModemIsRegisteredUsing(tech),
                        timeout=CELLULAR_TIMEOUT,
                        exception=_WrongTech(tech))
                except _WrongTech, wt:
                    failed_technologies.append(
                        (wt.technology, cell_modem.GetAccessTechnology()))